| author | |
| committer | |
| log | ceb3819c42254c1d379d4a0416009d136bbb0385 |
| tree | e54a495c392e190188ec55f5d48ebce8dcfb26e6 |
| parent | aa964bd555bf7d034b5bfea6275d6edddc35cb8c |
29 files changed, 1105 insertions(+), 544 deletions(-)
lib/libunwind/include/__libunwind_config.h+8-7| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- __libunwind_config.h -----------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -56,7 +56,7 @@ |
| 56 | 56 | # define _LIBUNWIND_CONTEXT_SIZE 167 |
| 57 | 57 | # define _LIBUNWIND_CURSOR_SIZE 179 |
| 58 | 58 | # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64 |
| 59 | # elif defined(__ppc__) | |
| 59 | # elif defined(__powerpc__) | |
| 60 | 60 | # define _LIBUNWIND_TARGET_PPC 1 |
| 61 | 61 | # define _LIBUNWIND_CONTEXT_SIZE 117 |
| 62 | 62 | # define _LIBUNWIND_CURSOR_SIZE 124 |
| ... | ... | @@ -126,11 +126,12 @@ |
| 126 | 126 | # error "Unsupported MIPS ABI and/or environment" |
| 127 | 127 | # endif |
| 128 | 128 | # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS |
| 129 | # elif defined(__sparc__) && defined(__arch64__) | |
| 130 | # define _LIBUNWIND_TARGET_SPARC64 1 | |
| 131 | # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC64 | |
| 132 | # define _LIBUNWIND_CONTEXT_SIZE 33 | |
| 133 | # define _LIBUNWIND_CURSOR_SIZE 45 | |
| 129 | #elif defined(__sparc__) && defined(__arch64__) | |
| 130 | #define _LIBUNWIND_TARGET_SPARC64 1 | |
| 131 | #define _LIBUNWIND_HIGHEST_DWARF_REGISTER \ | |
| 132 | _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC64 | |
| 133 | #define _LIBUNWIND_CONTEXT_SIZE 33 | |
| 134 | #define _LIBUNWIND_CURSOR_SIZE 45 | |
| 134 | 135 | # elif defined(__sparc__) |
| 135 | 136 | #define _LIBUNWIND_TARGET_SPARC 1 |
| 136 | 137 | #define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC |
lib/libunwind/include/libunwind.h+146-72| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===---------------------------- libunwind.h -----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -493,77 +493,150 @@ enum { |
| 493 | 493 | |
| 494 | 494 | // 64-bit ARM64 registers |
| 495 | 495 | enum { |
| 496 | UNW_ARM64_X0 = 0, | |
| 497 | UNW_ARM64_X1 = 1, | |
| 498 | UNW_ARM64_X2 = 2, | |
| 499 | UNW_ARM64_X3 = 3, | |
| 500 | UNW_ARM64_X4 = 4, | |
| 501 | UNW_ARM64_X5 = 5, | |
| 502 | UNW_ARM64_X6 = 6, | |
| 503 | UNW_ARM64_X7 = 7, | |
| 504 | UNW_ARM64_X8 = 8, | |
| 505 | UNW_ARM64_X9 = 9, | |
| 506 | UNW_ARM64_X10 = 10, | |
| 507 | UNW_ARM64_X11 = 11, | |
| 508 | UNW_ARM64_X12 = 12, | |
| 509 | UNW_ARM64_X13 = 13, | |
| 510 | UNW_ARM64_X14 = 14, | |
| 511 | UNW_ARM64_X15 = 15, | |
| 512 | UNW_ARM64_X16 = 16, | |
| 513 | UNW_ARM64_X17 = 17, | |
| 514 | UNW_ARM64_X18 = 18, | |
| 515 | UNW_ARM64_X19 = 19, | |
| 516 | UNW_ARM64_X20 = 20, | |
| 517 | UNW_ARM64_X21 = 21, | |
| 518 | UNW_ARM64_X22 = 22, | |
| 519 | UNW_ARM64_X23 = 23, | |
| 520 | UNW_ARM64_X24 = 24, | |
| 521 | UNW_ARM64_X25 = 25, | |
| 522 | UNW_ARM64_X26 = 26, | |
| 523 | UNW_ARM64_X27 = 27, | |
| 524 | UNW_ARM64_X28 = 28, | |
| 525 | UNW_ARM64_X29 = 29, | |
| 526 | UNW_ARM64_FP = 29, | |
| 527 | UNW_ARM64_X30 = 30, | |
| 528 | UNW_ARM64_LR = 30, | |
| 529 | UNW_ARM64_X31 = 31, | |
| 530 | UNW_ARM64_SP = 31, | |
| 531 | UNW_ARM64_PC = 32, | |
| 532 | // reserved block | |
| 533 | UNW_ARM64_RA_SIGN_STATE = 34, | |
| 496 | UNW_AARCH64_X0 = 0, | |
| 497 | UNW_AARCH64_X1 = 1, | |
| 498 | UNW_AARCH64_X2 = 2, | |
| 499 | UNW_AARCH64_X3 = 3, | |
| 500 | UNW_AARCH64_X4 = 4, | |
| 501 | UNW_AARCH64_X5 = 5, | |
| 502 | UNW_AARCH64_X6 = 6, | |
| 503 | UNW_AARCH64_X7 = 7, | |
| 504 | UNW_AARCH64_X8 = 8, | |
| 505 | UNW_AARCH64_X9 = 9, | |
| 506 | UNW_AARCH64_X10 = 10, | |
| 507 | UNW_AARCH64_X11 = 11, | |
| 508 | UNW_AARCH64_X12 = 12, | |
| 509 | UNW_AARCH64_X13 = 13, | |
| 510 | UNW_AARCH64_X14 = 14, | |
| 511 | UNW_AARCH64_X15 = 15, | |
| 512 | UNW_AARCH64_X16 = 16, | |
| 513 | UNW_AARCH64_X17 = 17, | |
| 514 | UNW_AARCH64_X18 = 18, | |
| 515 | UNW_AARCH64_X19 = 19, | |
| 516 | UNW_AARCH64_X20 = 20, | |
| 517 | UNW_AARCH64_X21 = 21, | |
| 518 | UNW_AARCH64_X22 = 22, | |
| 519 | UNW_AARCH64_X23 = 23, | |
| 520 | UNW_AARCH64_X24 = 24, | |
| 521 | UNW_AARCH64_X25 = 25, | |
| 522 | UNW_AARCH64_X26 = 26, | |
| 523 | UNW_AARCH64_X27 = 27, | |
| 524 | UNW_AARCH64_X28 = 28, | |
| 525 | UNW_AARCH64_X29 = 29, | |
| 526 | UNW_AARCH64_FP = 29, | |
| 527 | UNW_AARCH64_X30 = 30, | |
| 528 | UNW_AARCH64_LR = 30, | |
| 529 | UNW_AARCH64_X31 = 31, | |
| 530 | UNW_AARCH64_SP = 31, | |
| 531 | UNW_AARCH64_PC = 32, | |
| 532 | ||
| 534 | 533 | // reserved block |
| 535 | UNW_ARM64_D0 = 64, | |
| 536 | UNW_ARM64_D1 = 65, | |
| 537 | UNW_ARM64_D2 = 66, | |
| 538 | UNW_ARM64_D3 = 67, | |
| 539 | UNW_ARM64_D4 = 68, | |
| 540 | UNW_ARM64_D5 = 69, | |
| 541 | UNW_ARM64_D6 = 70, | |
| 542 | UNW_ARM64_D7 = 71, | |
| 543 | UNW_ARM64_D8 = 72, | |
| 544 | UNW_ARM64_D9 = 73, | |
| 545 | UNW_ARM64_D10 = 74, | |
| 546 | UNW_ARM64_D11 = 75, | |
| 547 | UNW_ARM64_D12 = 76, | |
| 548 | UNW_ARM64_D13 = 77, | |
| 549 | UNW_ARM64_D14 = 78, | |
| 550 | UNW_ARM64_D15 = 79, | |
| 551 | UNW_ARM64_D16 = 80, | |
| 552 | UNW_ARM64_D17 = 81, | |
| 553 | UNW_ARM64_D18 = 82, | |
| 554 | UNW_ARM64_D19 = 83, | |
| 555 | UNW_ARM64_D20 = 84, | |
| 556 | UNW_ARM64_D21 = 85, | |
| 557 | UNW_ARM64_D22 = 86, | |
| 558 | UNW_ARM64_D23 = 87, | |
| 559 | UNW_ARM64_D24 = 88, | |
| 560 | UNW_ARM64_D25 = 89, | |
| 561 | UNW_ARM64_D26 = 90, | |
| 562 | UNW_ARM64_D27 = 91, | |
| 563 | UNW_ARM64_D28 = 92, | |
| 564 | UNW_ARM64_D29 = 93, | |
| 565 | UNW_ARM64_D30 = 94, | |
| 566 | UNW_ARM64_D31 = 95, | |
| 534 | UNW_AARCH64_RA_SIGN_STATE = 34, | |
| 535 | ||
| 536 | // FP/vector registers | |
| 537 | UNW_AARCH64_V0 = 64, | |
| 538 | UNW_AARCH64_V1 = 65, | |
| 539 | UNW_AARCH64_V2 = 66, | |
| 540 | UNW_AARCH64_V3 = 67, | |
| 541 | UNW_AARCH64_V4 = 68, | |
| 542 | UNW_AARCH64_V5 = 69, | |
| 543 | UNW_AARCH64_V6 = 70, | |
| 544 | UNW_AARCH64_V7 = 71, | |
| 545 | UNW_AARCH64_V8 = 72, | |
| 546 | UNW_AARCH64_V9 = 73, | |
| 547 | UNW_AARCH64_V10 = 74, | |
| 548 | UNW_AARCH64_V11 = 75, | |
| 549 | UNW_AARCH64_V12 = 76, | |
| 550 | UNW_AARCH64_V13 = 77, | |
| 551 | UNW_AARCH64_V14 = 78, | |
| 552 | UNW_AARCH64_V15 = 79, | |
| 553 | UNW_AARCH64_V16 = 80, | |
| 554 | UNW_AARCH64_V17 = 81, | |
| 555 | UNW_AARCH64_V18 = 82, | |
| 556 | UNW_AARCH64_V19 = 83, | |
| 557 | UNW_AARCH64_V20 = 84, | |
| 558 | UNW_AARCH64_V21 = 85, | |
| 559 | UNW_AARCH64_V22 = 86, | |
| 560 | UNW_AARCH64_V23 = 87, | |
| 561 | UNW_AARCH64_V24 = 88, | |
| 562 | UNW_AARCH64_V25 = 89, | |
| 563 | UNW_AARCH64_V26 = 90, | |
| 564 | UNW_AARCH64_V27 = 91, | |
| 565 | UNW_AARCH64_V28 = 92, | |
| 566 | UNW_AARCH64_V29 = 93, | |
| 567 | UNW_AARCH64_V30 = 94, | |
| 568 | UNW_AARCH64_V31 = 95, | |
| 569 | ||
| 570 | // Compatibility aliases | |
| 571 | UNW_ARM64_X0 = UNW_AARCH64_X0, | |
| 572 | UNW_ARM64_X1 = UNW_AARCH64_X1, | |
| 573 | UNW_ARM64_X2 = UNW_AARCH64_X2, | |
| 574 | UNW_ARM64_X3 = UNW_AARCH64_X3, | |
| 575 | UNW_ARM64_X4 = UNW_AARCH64_X4, | |
| 576 | UNW_ARM64_X5 = UNW_AARCH64_X5, | |
| 577 | UNW_ARM64_X6 = UNW_AARCH64_X6, | |
| 578 | UNW_ARM64_X7 = UNW_AARCH64_X7, | |
| 579 | UNW_ARM64_X8 = UNW_AARCH64_X8, | |
| 580 | UNW_ARM64_X9 = UNW_AARCH64_X9, | |
| 581 | UNW_ARM64_X10 = UNW_AARCH64_X10, | |
| 582 | UNW_ARM64_X11 = UNW_AARCH64_X11, | |
| 583 | UNW_ARM64_X12 = UNW_AARCH64_X12, | |
| 584 | UNW_ARM64_X13 = UNW_AARCH64_X13, | |
| 585 | UNW_ARM64_X14 = UNW_AARCH64_X14, | |
| 586 | UNW_ARM64_X15 = UNW_AARCH64_X15, | |
| 587 | UNW_ARM64_X16 = UNW_AARCH64_X16, | |
| 588 | UNW_ARM64_X17 = UNW_AARCH64_X17, | |
| 589 | UNW_ARM64_X18 = UNW_AARCH64_X18, | |
| 590 | UNW_ARM64_X19 = UNW_AARCH64_X19, | |
| 591 | UNW_ARM64_X20 = UNW_AARCH64_X20, | |
| 592 | UNW_ARM64_X21 = UNW_AARCH64_X21, | |
| 593 | UNW_ARM64_X22 = UNW_AARCH64_X22, | |
| 594 | UNW_ARM64_X23 = UNW_AARCH64_X23, | |
| 595 | UNW_ARM64_X24 = UNW_AARCH64_X24, | |
| 596 | UNW_ARM64_X25 = UNW_AARCH64_X25, | |
| 597 | UNW_ARM64_X26 = UNW_AARCH64_X26, | |
| 598 | UNW_ARM64_X27 = UNW_AARCH64_X27, | |
| 599 | UNW_ARM64_X28 = UNW_AARCH64_X28, | |
| 600 | UNW_ARM64_X29 = UNW_AARCH64_X29, | |
| 601 | UNW_ARM64_FP = UNW_AARCH64_FP, | |
| 602 | UNW_ARM64_X30 = UNW_AARCH64_X30, | |
| 603 | UNW_ARM64_LR = UNW_AARCH64_LR, | |
| 604 | UNW_ARM64_X31 = UNW_AARCH64_X31, | |
| 605 | UNW_ARM64_SP = UNW_AARCH64_SP, | |
| 606 | UNW_ARM64_PC = UNW_AARCH64_PC, | |
| 607 | UNW_ARM64_RA_SIGN_STATE = UNW_AARCH64_RA_SIGN_STATE, | |
| 608 | UNW_ARM64_D0 = UNW_AARCH64_V0, | |
| 609 | UNW_ARM64_D1 = UNW_AARCH64_V1, | |
| 610 | UNW_ARM64_D2 = UNW_AARCH64_V2, | |
| 611 | UNW_ARM64_D3 = UNW_AARCH64_V3, | |
| 612 | UNW_ARM64_D4 = UNW_AARCH64_V4, | |
| 613 | UNW_ARM64_D5 = UNW_AARCH64_V5, | |
| 614 | UNW_ARM64_D6 = UNW_AARCH64_V6, | |
| 615 | UNW_ARM64_D7 = UNW_AARCH64_V7, | |
| 616 | UNW_ARM64_D8 = UNW_AARCH64_V8, | |
| 617 | UNW_ARM64_D9 = UNW_AARCH64_V9, | |
| 618 | UNW_ARM64_D10 = UNW_AARCH64_V10, | |
| 619 | UNW_ARM64_D11 = UNW_AARCH64_V11, | |
| 620 | UNW_ARM64_D12 = UNW_AARCH64_V12, | |
| 621 | UNW_ARM64_D13 = UNW_AARCH64_V13, | |
| 622 | UNW_ARM64_D14 = UNW_AARCH64_V14, | |
| 623 | UNW_ARM64_D15 = UNW_AARCH64_V15, | |
| 624 | UNW_ARM64_D16 = UNW_AARCH64_V16, | |
| 625 | UNW_ARM64_D17 = UNW_AARCH64_V17, | |
| 626 | UNW_ARM64_D18 = UNW_AARCH64_V18, | |
| 627 | UNW_ARM64_D19 = UNW_AARCH64_V19, | |
| 628 | UNW_ARM64_D20 = UNW_AARCH64_V20, | |
| 629 | UNW_ARM64_D21 = UNW_AARCH64_V21, | |
| 630 | UNW_ARM64_D22 = UNW_AARCH64_V22, | |
| 631 | UNW_ARM64_D23 = UNW_AARCH64_V23, | |
| 632 | UNW_ARM64_D24 = UNW_AARCH64_V24, | |
| 633 | UNW_ARM64_D25 = UNW_AARCH64_V25, | |
| 634 | UNW_ARM64_D26 = UNW_AARCH64_V26, | |
| 635 | UNW_ARM64_D27 = UNW_AARCH64_V27, | |
| 636 | UNW_ARM64_D28 = UNW_AARCH64_V28, | |
| 637 | UNW_ARM64_D29 = UNW_AARCH64_V29, | |
| 638 | UNW_ARM64_D30 = UNW_AARCH64_V30, | |
| 639 | UNW_ARM64_D31 = UNW_AARCH64_V31, | |
| 567 | 640 | }; |
| 568 | 641 | |
| 569 | 642 | // 32-bit ARM registers. Numbers match DWARF for ARM spec #3.1 Table 1. |
| ... | ... | @@ -645,7 +718,8 @@ enum { |
| 645 | 718 | UNW_ARM_WR14 = 126, |
| 646 | 719 | UNW_ARM_WR15 = 127, |
| 647 | 720 | // 128-133 -- SPSR, SPSR_{FIQ|IRQ|ABT|UND|SVC} |
| 648 | // 134-143 -- Reserved | |
| 721 | // 134-142 -- Reserved | |
| 722 | UNW_ARM_RA_AUTH_CODE = 143, | |
| 649 | 723 | // 144-150 -- R8_USR-R14_USR |
| 650 | 724 | // 151-157 -- R8_FIQ-R14_FIQ |
| 651 | 725 | // 158-159 -- R13_IRQ-R14_IRQ |
lib/libunwind/include/mach-o/compact_unwind_encoding.h+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------ mach-o/compact_unwind_encoding.h ------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libunwind/include/unwind.h+5-193| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------------- unwind.h -----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -56,211 +56,23 @@ typedef enum { |
| 56 | 56 | typedef struct _Unwind_Context _Unwind_Context; // opaque |
| 57 | 57 | |
| 58 | 58 | #if defined(_LIBUNWIND_ARM_EHABI) |
| 59 | typedef uint32_t _Unwind_State; | |
| 60 | ||
| 61 | static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0; | |
| 62 | static const _Unwind_State _US_UNWIND_FRAME_STARTING = 1; | |
| 63 | static const _Unwind_State _US_UNWIND_FRAME_RESUME = 2; | |
| 64 | static const _Unwind_State _US_ACTION_MASK = 3; | |
| 65 | /* Undocumented flag for force unwinding. */ | |
| 66 | static const _Unwind_State _US_FORCE_UNWIND = 8; | |
| 67 | ||
| 68 | typedef uint32_t _Unwind_EHT_Header; | |
| 69 | ||
| 70 | struct _Unwind_Control_Block; | |
| 71 | typedef struct _Unwind_Control_Block _Unwind_Control_Block; | |
| 72 | typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */ | |
| 73 | ||
| 74 | struct _Unwind_Control_Block { | |
| 75 | uint64_t exception_class; | |
| 76 | void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block*); | |
| 77 | ||
| 78 | /* Unwinder cache, private fields for the unwinder's use */ | |
| 79 | struct { | |
| 80 | uint32_t reserved1; /* init reserved1 to 0, then don't touch */ | |
| 81 | uint32_t reserved2; | |
| 82 | uint32_t reserved3; | |
| 83 | uint32_t reserved4; | |
| 84 | uint32_t reserved5; | |
| 85 | } unwinder_cache; | |
| 86 | ||
| 87 | /* Propagation barrier cache (valid after phase 1): */ | |
| 88 | struct { | |
| 89 | uint32_t sp; | |
| 90 | uint32_t bitpattern[5]; | |
| 91 | } barrier_cache; | |
| 92 | ||
| 93 | /* Cleanup cache (preserved over cleanup): */ | |
| 94 | struct { | |
| 95 | uint32_t bitpattern[4]; | |
| 96 | } cleanup_cache; | |
| 97 | ||
| 98 | /* Pr cache (for pr's benefit): */ | |
| 99 | struct { | |
| 100 | uint32_t fnstart; /* function start address */ | |
| 101 | _Unwind_EHT_Header* ehtp; /* pointer to EHT entry header word */ | |
| 102 | uint32_t additional; | |
| 103 | uint32_t reserved1; | |
| 104 | } pr_cache; | |
| 105 | ||
| 106 | long long int :0; /* Enforce the 8-byte alignment */ | |
| 107 | } __attribute__((__aligned__(8))); | |
| 108 | ||
| 109 | typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) | |
| 110 | (_Unwind_State state, | |
| 111 | _Unwind_Exception* exceptionObject, | |
| 112 | struct _Unwind_Context* context); | |
| 113 | ||
| 114 | typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)( | |
| 115 | _Unwind_State state, _Unwind_Exception *exceptionObject, | |
| 116 | struct _Unwind_Context *context); | |
| 59 | #include "unwind_arm_ehabi.h" | |
| 117 | 60 | #else |
| 118 | struct _Unwind_Context; // opaque | |
| 119 | struct _Unwind_Exception; // forward declaration | |
| 120 | typedef struct _Unwind_Exception _Unwind_Exception; | |
| 121 | ||
| 122 | struct _Unwind_Exception { | |
| 123 | uint64_t exception_class; | |
| 124 | void (*exception_cleanup)(_Unwind_Reason_Code reason, | |
| 125 | _Unwind_Exception *exc); | |
| 126 | #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) | |
| 127 | uintptr_t private_[6]; | |
| 128 | #else | |
| 129 | uintptr_t private_1; // non-zero means forced unwind | |
| 130 | uintptr_t private_2; // holds sp that phase1 found for phase2 to use | |
| 61 | #include "unwind_itanium.h" | |
| 131 | 62 | #endif |
| 132 | #if __SIZEOF_POINTER__ == 4 | |
| 133 | // The implementation of _Unwind_Exception uses an attribute mode on the | |
| 134 | // above fields which has the side effect of causing this whole struct to | |
| 135 | // round up to 32 bytes in size (48 with SEH). To be more explicit, we add | |
| 136 | // pad fields added for binary compatibility. | |
| 137 | uint32_t reserved[3]; | |
| 138 | #endif | |
| 139 | // The Itanium ABI requires that _Unwind_Exception objects are "double-word | |
| 140 | // aligned". GCC has interpreted this to mean "use the maximum useful | |
| 141 | // alignment for the target"; so do we. | |
| 142 | } __attribute__((__aligned__)); | |
| 143 | 63 | |
| 144 | 64 | typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) |
| 145 | 65 | (int version, |
| 146 | 66 | _Unwind_Action actions, |
| 147 | uint64_t exceptionClass, | |
| 67 | _Unwind_Exception_Class exceptionClass, | |
| 148 | 68 | _Unwind_Exception* exceptionObject, |
| 149 | 69 | struct _Unwind_Context* context, |
| 150 | void* stop_parameter ); | |
| 151 | ||
| 152 | typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)( | |
| 153 | int version, _Unwind_Action actions, uint64_t exceptionClass, | |
| 154 | _Unwind_Exception *exceptionObject, struct _Unwind_Context *context); | |
| 155 | #endif | |
| 70 | void* stop_parameter); | |
| 156 | 71 | |
| 157 | 72 | #ifdef __cplusplus |
| 158 | 73 | extern "C" { |
| 159 | 74 | #endif |
| 160 | 75 | |
| 161 | // | |
| 162 | // The following are the base functions documented by the C++ ABI | |
| 163 | // | |
| 164 | #ifdef __USING_SJLJ_EXCEPTIONS__ | |
| 165 | extern _Unwind_Reason_Code | |
| 166 | _Unwind_SjLj_RaiseException(_Unwind_Exception *exception_object); | |
| 167 | extern void _Unwind_SjLj_Resume(_Unwind_Exception *exception_object); | |
| 168 | #else | |
| 169 | extern _Unwind_Reason_Code | |
| 170 | _Unwind_RaiseException(_Unwind_Exception *exception_object); | |
| 171 | extern void _Unwind_Resume(_Unwind_Exception *exception_object); | |
| 172 | #endif | |
| 173 | extern void _Unwind_DeleteException(_Unwind_Exception *exception_object); | |
| 174 | ||
| 175 | #if defined(_LIBUNWIND_ARM_EHABI) | |
| 176 | typedef enum { | |
| 177 | _UVRSC_CORE = 0, /* integer register */ | |
| 178 | _UVRSC_VFP = 1, /* vfp */ | |
| 179 | _UVRSC_WMMXD = 3, /* Intel WMMX data register */ | |
| 180 | _UVRSC_WMMXC = 4 /* Intel WMMX control register */ | |
| 181 | } _Unwind_VRS_RegClass; | |
| 182 | ||
| 183 | typedef enum { | |
| 184 | _UVRSD_UINT32 = 0, | |
| 185 | _UVRSD_VFPX = 1, | |
| 186 | _UVRSD_UINT64 = 3, | |
| 187 | _UVRSD_FLOAT = 4, | |
| 188 | _UVRSD_DOUBLE = 5 | |
| 189 | } _Unwind_VRS_DataRepresentation; | |
| 190 | ||
| 191 | typedef enum { | |
| 192 | _UVRSR_OK = 0, | |
| 193 | _UVRSR_NOT_IMPLEMENTED = 1, | |
| 194 | _UVRSR_FAILED = 2 | |
| 195 | } _Unwind_VRS_Result; | |
| 196 | ||
| 197 | extern void _Unwind_Complete(_Unwind_Exception* exception_object); | |
| 198 | ||
| 199 | extern _Unwind_VRS_Result | |
| 200 | _Unwind_VRS_Get(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, | |
| 201 | uint32_t regno, _Unwind_VRS_DataRepresentation representation, | |
| 202 | void *valuep); | |
| 203 | ||
| 204 | extern _Unwind_VRS_Result | |
| 205 | _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, | |
| 206 | uint32_t regno, _Unwind_VRS_DataRepresentation representation, | |
| 207 | void *valuep); | |
| 208 | ||
| 209 | extern _Unwind_VRS_Result | |
| 210 | _Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, | |
| 211 | uint32_t discriminator, | |
| 212 | _Unwind_VRS_DataRepresentation representation); | |
| 213 | #endif | |
| 214 | ||
| 215 | #if !defined(_LIBUNWIND_ARM_EHABI) | |
| 216 | ||
| 217 | extern uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index); | |
| 218 | extern void _Unwind_SetGR(struct _Unwind_Context *context, int index, | |
| 219 | uintptr_t new_value); | |
| 220 | extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *context); | |
| 221 | extern void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t new_value); | |
| 222 | ||
| 223 | #else // defined(_LIBUNWIND_ARM_EHABI) | |
| 224 | ||
| 225 | #if defined(_LIBUNWIND_UNWIND_LEVEL1_EXTERNAL_LINKAGE) | |
| 226 | #define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 extern | |
| 227 | #else | |
| 228 | #define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 static __inline__ | |
| 229 | #endif | |
| 230 | ||
| 231 | // These are de facto helper functions for ARM, which delegate the function | |
| 232 | // calls to _Unwind_VRS_Get/Set(). These are not a part of ARM EHABI | |
| 233 | // specification, thus these function MUST be inlined. Please don't replace | |
| 234 | // these with the "extern" function declaration; otherwise, the program | |
| 235 | // including this <unwind.h> header won't be ABI compatible and will result in | |
| 236 | // link error when we are linking the program with libgcc. | |
| 237 | ||
| 238 | _LIBUNWIND_EXPORT_UNWIND_LEVEL1 | |
| 239 | uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index) { | |
| 240 | uintptr_t value = 0; | |
| 241 | _Unwind_VRS_Get(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); | |
| 242 | return value; | |
| 243 | } | |
| 244 | ||
| 245 | _LIBUNWIND_EXPORT_UNWIND_LEVEL1 | |
| 246 | void _Unwind_SetGR(struct _Unwind_Context *context, int index, | |
| 247 | uintptr_t value) { | |
| 248 | _Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); | |
| 249 | } | |
| 250 | ||
| 251 | _LIBUNWIND_EXPORT_UNWIND_LEVEL1 | |
| 252 | uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { | |
| 253 | // remove the thumb-bit before returning | |
| 254 | return _Unwind_GetGR(context, 15) & (~(uintptr_t)0x1); | |
| 255 | } | |
| 256 | ||
| 257 | _LIBUNWIND_EXPORT_UNWIND_LEVEL1 | |
| 258 | void _Unwind_SetIP(struct _Unwind_Context *context, uintptr_t value) { | |
| 259 | uintptr_t thumb_bit = _Unwind_GetGR(context, 15) & ((uintptr_t)0x1); | |
| 260 | _Unwind_SetGR(context, 15, value | thumb_bit); | |
| 261 | } | |
| 262 | #endif // defined(_LIBUNWIND_ARM_EHABI) | |
| 263 | ||
| 264 | 76 | extern uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context *context); |
| 265 | 77 | extern uintptr_t |
| 266 | 78 | _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context); |
lib/libunwind/include/unwind_arm_ehabi.h created+170| ... | ... | @@ -0,0 +1,170 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | // | |
| 8 | // C++ ABI Level 1 ABI documented at: | |
| 9 | // https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst | |
| 10 | // | |
| 11 | //===----------------------------------------------------------------------===// | |
| 12 | ||
| 13 | #ifndef __ARM_EHABI_UNWIND_H__ | |
| 14 | #define __ARM_EHABI_UNWIND_H__ | |
| 15 | ||
| 16 | typedef uint32_t _Unwind_State; | |
| 17 | ||
| 18 | static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0; | |
| 19 | static const _Unwind_State _US_UNWIND_FRAME_STARTING = 1; | |
| 20 | static const _Unwind_State _US_UNWIND_FRAME_RESUME = 2; | |
| 21 | static const _Unwind_State _US_ACTION_MASK = 3; | |
| 22 | /* Undocumented flag for force unwinding. */ | |
| 23 | static const _Unwind_State _US_FORCE_UNWIND = 8; | |
| 24 | ||
| 25 | typedef uint32_t _Unwind_EHT_Header; | |
| 26 | ||
| 27 | struct _Unwind_Control_Block; | |
| 28 | typedef struct _Unwind_Control_Block _Unwind_Control_Block; | |
| 29 | #define _Unwind_Exception _Unwind_Control_Block /* Alias */ | |
| 30 | typedef uint8_t _Unwind_Exception_Class[8]; | |
| 31 | ||
| 32 | struct _Unwind_Control_Block { | |
| 33 | _Unwind_Exception_Class exception_class; | |
| 34 | void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block*); | |
| 35 | ||
| 36 | /* Unwinder cache, private fields for the unwinder's use */ | |
| 37 | struct { | |
| 38 | uint32_t reserved1; /* init reserved1 to 0, then don't touch */ | |
| 39 | uint32_t reserved2; | |
| 40 | uint32_t reserved3; | |
| 41 | uint32_t reserved4; | |
| 42 | uint32_t reserved5; | |
| 43 | } unwinder_cache; | |
| 44 | ||
| 45 | /* Propagation barrier cache (valid after phase 1): */ | |
| 46 | struct { | |
| 47 | uint32_t sp; | |
| 48 | uint32_t bitpattern[5]; | |
| 49 | } barrier_cache; | |
| 50 | ||
| 51 | /* Cleanup cache (preserved over cleanup): */ | |
| 52 | struct { | |
| 53 | uint32_t bitpattern[4]; | |
| 54 | } cleanup_cache; | |
| 55 | ||
| 56 | /* Pr cache (for pr's benefit): */ | |
| 57 | struct { | |
| 58 | uint32_t fnstart; /* function start address */ | |
| 59 | _Unwind_EHT_Header* ehtp; /* pointer to EHT entry header word */ | |
| 60 | uint32_t additional; | |
| 61 | uint32_t reserved1; | |
| 62 | } pr_cache; | |
| 63 | ||
| 64 | long long int :0; /* Enforce the 8-byte alignment */ | |
| 65 | } __attribute__((__aligned__(8))); | |
| 66 | ||
| 67 | typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)( | |
| 68 | _Unwind_State state, _Unwind_Exception *exceptionObject, | |
| 69 | struct _Unwind_Context *context); | |
| 70 | ||
| 71 | #ifdef __cplusplus | |
| 72 | extern "C" { | |
| 73 | #endif | |
| 74 | ||
| 75 | // | |
| 76 | // The following are the base functions documented by the C++ ABI | |
| 77 | // | |
| 78 | #ifdef __USING_SJLJ_EXCEPTIONS__ | |
| 79 | extern _Unwind_Reason_Code | |
| 80 | _Unwind_SjLj_RaiseException(_Unwind_Exception *exception_object); | |
| 81 | extern void _Unwind_SjLj_Resume(_Unwind_Exception *exception_object); | |
| 82 | #else | |
| 83 | extern _Unwind_Reason_Code | |
| 84 | _Unwind_RaiseException(_Unwind_Exception *exception_object); | |
| 85 | extern void _Unwind_Resume(_Unwind_Exception *exception_object); | |
| 86 | #endif | |
| 87 | extern void _Unwind_DeleteException(_Unwind_Exception *exception_object); | |
| 88 | ||
| 89 | typedef enum { | |
| 90 | _UVRSC_CORE = 0, /* integer register */ | |
| 91 | _UVRSC_VFP = 1, /* vfp */ | |
| 92 | _UVRSC_WMMXD = 3, /* Intel WMMX data register */ | |
| 93 | _UVRSC_WMMXC = 4, /* Intel WMMX control register */ | |
| 94 | _UVRSC_PSEUDO = 5 /* Special purpose pseudo register */ | |
| 95 | } _Unwind_VRS_RegClass; | |
| 96 | ||
| 97 | typedef enum { | |
| 98 | _UVRSD_UINT32 = 0, | |
| 99 | _UVRSD_VFPX = 1, | |
| 100 | _UVRSD_UINT64 = 3, | |
| 101 | _UVRSD_FLOAT = 4, | |
| 102 | _UVRSD_DOUBLE = 5 | |
| 103 | } _Unwind_VRS_DataRepresentation; | |
| 104 | ||
| 105 | typedef enum { | |
| 106 | _UVRSR_OK = 0, | |
| 107 | _UVRSR_NOT_IMPLEMENTED = 1, | |
| 108 | _UVRSR_FAILED = 2 | |
| 109 | } _Unwind_VRS_Result; | |
| 110 | ||
| 111 | extern void _Unwind_Complete(_Unwind_Exception* exception_object); | |
| 112 | ||
| 113 | extern _Unwind_VRS_Result | |
| 114 | _Unwind_VRS_Get(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, | |
| 115 | uint32_t regno, _Unwind_VRS_DataRepresentation representation, | |
| 116 | void *valuep); | |
| 117 | ||
| 118 | extern _Unwind_VRS_Result | |
| 119 | _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, | |
| 120 | uint32_t regno, _Unwind_VRS_DataRepresentation representation, | |
| 121 | void *valuep); | |
| 122 | ||
| 123 | extern _Unwind_VRS_Result | |
| 124 | _Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, | |
| 125 | uint32_t discriminator, | |
| 126 | _Unwind_VRS_DataRepresentation representation); | |
| 127 | ||
| 128 | #if defined(_LIBUNWIND_UNWIND_LEVEL1_EXTERNAL_LINKAGE) | |
| 129 | #define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 extern | |
| 130 | #else | |
| 131 | #define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 static __inline__ | |
| 132 | #endif | |
| 133 | ||
| 134 | // These are de facto helper functions for ARM, which delegate the function | |
| 135 | // calls to _Unwind_VRS_Get/Set(). These are not a part of ARM EHABI | |
| 136 | // specification, thus these function MUST be inlined. Please don't replace | |
| 137 | // these with the "extern" function declaration; otherwise, the program | |
| 138 | // including this <unwind.h> header won't be ABI compatible and will result in | |
| 139 | // link error when we are linking the program with libgcc. | |
| 140 | ||
| 141 | _LIBUNWIND_EXPORT_UNWIND_LEVEL1 | |
| 142 | uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index) { | |
| 143 | uintptr_t value = 0; | |
| 144 | _Unwind_VRS_Get(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); | |
| 145 | return value; | |
| 146 | } | |
| 147 | ||
| 148 | _LIBUNWIND_EXPORT_UNWIND_LEVEL1 | |
| 149 | void _Unwind_SetGR(struct _Unwind_Context *context, int index, | |
| 150 | uintptr_t value) { | |
| 151 | _Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); | |
| 152 | } | |
| 153 | ||
| 154 | _LIBUNWIND_EXPORT_UNWIND_LEVEL1 | |
| 155 | uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { | |
| 156 | // remove the thumb-bit before returning | |
| 157 | return _Unwind_GetGR(context, 15) & (~(uintptr_t)0x1); | |
| 158 | } | |
| 159 | ||
| 160 | _LIBUNWIND_EXPORT_UNWIND_LEVEL1 | |
| 161 | void _Unwind_SetIP(struct _Unwind_Context *context, uintptr_t value) { | |
| 162 | uintptr_t thumb_bit = _Unwind_GetGR(context, 15) & ((uintptr_t)0x1); | |
| 163 | _Unwind_SetGR(context, 15, value | thumb_bit); | |
| 164 | } | |
| 165 | ||
| 166 | #ifdef __cplusplus | |
| 167 | } | |
| 168 | #endif | |
| 169 | ||
| 170 | #endif // __ARM_EHABI_UNWIND_H__ |
lib/libunwind/include/unwind_itanium.h created+76| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | // | |
| 8 | // C++ ABI Level 1 ABI documented at: | |
| 9 | // https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html | |
| 10 | // | |
| 11 | //===----------------------------------------------------------------------===// | |
| 12 | ||
| 13 | #ifndef __ITANIUM_UNWIND_H__ | |
| 14 | #define __ITANIUM_UNWIND_H__ | |
| 15 | ||
| 16 | struct _Unwind_Context; // opaque | |
| 17 | struct _Unwind_Exception; // forward declaration | |
| 18 | typedef struct _Unwind_Exception _Unwind_Exception; | |
| 19 | typedef uint64_t _Unwind_Exception_Class; | |
| 20 | ||
| 21 | struct _Unwind_Exception { | |
| 22 | _Unwind_Exception_Class exception_class; | |
| 23 | void (*exception_cleanup)(_Unwind_Reason_Code reason, | |
| 24 | _Unwind_Exception *exc); | |
| 25 | #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) | |
| 26 | uintptr_t private_[6]; | |
| 27 | #else | |
| 28 | uintptr_t private_1; // non-zero means forced unwind | |
| 29 | uintptr_t private_2; // holds sp that phase1 found for phase2 to use | |
| 30 | #endif | |
| 31 | #if __SIZEOF_POINTER__ == 4 | |
| 32 | // The implementation of _Unwind_Exception uses an attribute mode on the | |
| 33 | // above fields which has the side effect of causing this whole struct to | |
| 34 | // round up to 32 bytes in size (48 with SEH). To be more explicit, we add | |
| 35 | // pad fields added for binary compatibility. | |
| 36 | uint32_t reserved[3]; | |
| 37 | #endif | |
| 38 | // The Itanium ABI requires that _Unwind_Exception objects are "double-word | |
| 39 | // aligned". GCC has interpreted this to mean "use the maximum useful | |
| 40 | // alignment for the target"; so do we. | |
| 41 | } __attribute__((__aligned__)); | |
| 42 | ||
| 43 | typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)( | |
| 44 | int version, _Unwind_Action actions, uint64_t exceptionClass, | |
| 45 | _Unwind_Exception *exceptionObject, struct _Unwind_Context *context); | |
| 46 | ||
| 47 | #ifdef __cplusplus | |
| 48 | extern "C" { | |
| 49 | #endif | |
| 50 | ||
| 51 | // | |
| 52 | // The following are the base functions documented by the C++ ABI | |
| 53 | // | |
| 54 | #ifdef __USING_SJLJ_EXCEPTIONS__ | |
| 55 | extern _Unwind_Reason_Code | |
| 56 | _Unwind_SjLj_RaiseException(_Unwind_Exception *exception_object); | |
| 57 | extern void _Unwind_SjLj_Resume(_Unwind_Exception *exception_object); | |
| 58 | #else | |
| 59 | extern _Unwind_Reason_Code | |
| 60 | _Unwind_RaiseException(_Unwind_Exception *exception_object); | |
| 61 | extern void _Unwind_Resume(_Unwind_Exception *exception_object); | |
| 62 | #endif | |
| 63 | extern void _Unwind_DeleteException(_Unwind_Exception *exception_object); | |
| 64 | ||
| 65 | ||
| 66 | extern uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index); | |
| 67 | extern void _Unwind_SetGR(struct _Unwind_Context *context, int index, | |
| 68 | uintptr_t new_value); | |
| 69 | extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *context); | |
| 70 | extern void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t new_value); | |
| 71 | ||
| 72 | #ifdef __cplusplus | |
| 73 | } | |
| 74 | #endif | |
| 75 | ||
| 76 | #endif // __ITANIUM_UNWIND_H__ |
lib/libunwind/src/AddressSpace.hpp+13-13| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- AddressSpace.hpp ---------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -121,23 +121,23 @@ struct UnwindInfoSections { |
| 121 | 121 | uintptr_t dso_base; |
| 122 | 122 | #endif |
| 123 | 123 | #if defined(_LIBUNWIND_USE_DL_ITERATE_PHDR) |
| 124 | uintptr_t text_segment_length; | |
| 124 | size_t text_segment_length; | |
| 125 | 125 | #endif |
| 126 | 126 | #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) |
| 127 | 127 | uintptr_t dwarf_section; |
| 128 | uintptr_t dwarf_section_length; | |
| 128 | size_t dwarf_section_length; | |
| 129 | 129 | #endif |
| 130 | 130 | #if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX) |
| 131 | 131 | uintptr_t dwarf_index_section; |
| 132 | uintptr_t dwarf_index_section_length; | |
| 132 | size_t dwarf_index_section_length; | |
| 133 | 133 | #endif |
| 134 | 134 | #if defined(_LIBUNWIND_SUPPORT_COMPACT_UNWIND) |
| 135 | 135 | uintptr_t compact_unwind_section; |
| 136 | uintptr_t compact_unwind_section_length; | |
| 136 | size_t compact_unwind_section_length; | |
| 137 | 137 | #endif |
| 138 | 138 | #if defined(_LIBUNWIND_ARM_EHABI) |
| 139 | 139 | uintptr_t arm_section; |
| 140 | uintptr_t arm_section_length; | |
| 140 | size_t arm_section_length; | |
| 141 | 141 | #endif |
| 142 | 142 | }; |
| 143 | 143 | |
| ... | ... | @@ -430,7 +430,7 @@ static bool checkForUnwindInfoSegment(const Elf_Phdr *phdr, size_t image_base, |
| 430 | 430 | // .eh_frame_hdr records the start of .eh_frame, but not its size. |
| 431 | 431 | // Rely on a zero terminator to find the end of the section. |
| 432 | 432 | cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr; |
| 433 | cbdata->sects->dwarf_section_length = UINTPTR_MAX; | |
| 433 | cbdata->sects->dwarf_section_length = SIZE_MAX; | |
| 434 | 434 | return true; |
| 435 | 435 | } |
| 436 | 436 | } |
| ... | ... | @@ -506,22 +506,22 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, |
| 506 | 506 | info.dso_base = (uintptr_t)dyldInfo.mh; |
| 507 | 507 | #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) |
| 508 | 508 | info.dwarf_section = (uintptr_t)dyldInfo.dwarf_section; |
| 509 | info.dwarf_section_length = dyldInfo.dwarf_section_length; | |
| 509 | info.dwarf_section_length = (size_t)dyldInfo.dwarf_section_length; | |
| 510 | 510 | #endif |
| 511 | 511 | info.compact_unwind_section = (uintptr_t)dyldInfo.compact_unwind_section; |
| 512 | info.compact_unwind_section_length = dyldInfo.compact_unwind_section_length; | |
| 512 | info.compact_unwind_section_length = (size_t)dyldInfo.compact_unwind_section_length; | |
| 513 | 513 | return true; |
| 514 | 514 | } |
| 515 | 515 | #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL) |
| 516 | 516 | info.dso_base = 0; |
| 517 | 517 | // Bare metal is statically linked, so no need to ask the dynamic loader |
| 518 | info.dwarf_section_length = (uintptr_t)(&__eh_frame_end - &__eh_frame_start); | |
| 518 | info.dwarf_section_length = (size_t)(&__eh_frame_end - &__eh_frame_start); | |
| 519 | 519 | info.dwarf_section = (uintptr_t)(&__eh_frame_start); |
| 520 | 520 | _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %p length %p", |
| 521 | 521 | (void *)info.dwarf_section, (void *)info.dwarf_section_length); |
| 522 | 522 | #if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX) |
| 523 | 523 | info.dwarf_index_section = (uintptr_t)(&__eh_frame_hdr_start); |
| 524 | info.dwarf_index_section_length = (uintptr_t)(&__eh_frame_hdr_end - &__eh_frame_hdr_start); | |
| 524 | info.dwarf_index_section_length = (size_t)(&__eh_frame_hdr_end - &__eh_frame_hdr_start); | |
| 525 | 525 | _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: index section %p length %p", |
| 526 | 526 | (void *)info.dwarf_index_section, (void *)info.dwarf_index_section_length); |
| 527 | 527 | #endif |
| ... | ... | @@ -530,7 +530,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, |
| 530 | 530 | #elif defined(_LIBUNWIND_ARM_EHABI) && defined(_LIBUNWIND_IS_BAREMETAL) |
| 531 | 531 | // Bare metal is statically linked, so no need to ask the dynamic loader |
| 532 | 532 | info.arm_section = (uintptr_t)(&__exidx_start); |
| 533 | info.arm_section_length = (uintptr_t)(&__exidx_end - &__exidx_start); | |
| 533 | info.arm_section_length = (size_t)(&__exidx_end - &__exidx_start); | |
| 534 | 534 | _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %p length %p", |
| 535 | 535 | (void *)info.arm_section, (void *)info.arm_section_length); |
| 536 | 536 | if (info.arm_section && info.arm_section_length) |
| ... | ... | @@ -584,7 +584,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, |
| 584 | 584 | int length = 0; |
| 585 | 585 | info.arm_section = |
| 586 | 586 | (uintptr_t)dl_unwind_find_exidx((_Unwind_Ptr)targetAddr, &length); |
| 587 | info.arm_section_length = (uintptr_t)length * sizeof(EHABIIndexEntry); | |
| 587 | info.arm_section_length = (size_t)length * sizeof(EHABIIndexEntry); | |
| 588 | 588 | if (info.arm_section && info.arm_section_length) |
| 589 | 589 | return true; |
| 590 | 590 | #elif defined(_LIBUNWIND_USE_DL_ITERATE_PHDR) |
lib/libunwind/src/CompactUnwinder.hpp+38-38| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------------- CompactUnwinder.hpp -----------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -537,65 +537,65 @@ int CompactUnwinder_arm64<A>::stepWithCompactEncodingFrameless( |
| 537 | 537 | uint64_t savedRegisterLoc = registers.getSP() + stackSize; |
| 538 | 538 | |
| 539 | 539 | if (encoding & UNWIND_ARM64_FRAME_X19_X20_PAIR) { |
| 540 | registers.setRegister(UNW_ARM64_X19, addressSpace.get64(savedRegisterLoc)); | |
| 540 | registers.setRegister(UNW_AARCH64_X19, addressSpace.get64(savedRegisterLoc)); | |
| 541 | 541 | savedRegisterLoc -= 8; |
| 542 | registers.setRegister(UNW_ARM64_X20, addressSpace.get64(savedRegisterLoc)); | |
| 542 | registers.setRegister(UNW_AARCH64_X20, addressSpace.get64(savedRegisterLoc)); | |
| 543 | 543 | savedRegisterLoc -= 8; |
| 544 | 544 | } |
| 545 | 545 | if (encoding & UNWIND_ARM64_FRAME_X21_X22_PAIR) { |
| 546 | registers.setRegister(UNW_ARM64_X21, addressSpace.get64(savedRegisterLoc)); | |
| 546 | registers.setRegister(UNW_AARCH64_X21, addressSpace.get64(savedRegisterLoc)); | |
| 547 | 547 | savedRegisterLoc -= 8; |
| 548 | registers.setRegister(UNW_ARM64_X22, addressSpace.get64(savedRegisterLoc)); | |
| 548 | registers.setRegister(UNW_AARCH64_X22, addressSpace.get64(savedRegisterLoc)); | |
| 549 | 549 | savedRegisterLoc -= 8; |
| 550 | 550 | } |
| 551 | 551 | if (encoding & UNWIND_ARM64_FRAME_X23_X24_PAIR) { |
| 552 | registers.setRegister(UNW_ARM64_X23, addressSpace.get64(savedRegisterLoc)); | |
| 552 | registers.setRegister(UNW_AARCH64_X23, addressSpace.get64(savedRegisterLoc)); | |
| 553 | 553 | savedRegisterLoc -= 8; |
| 554 | registers.setRegister(UNW_ARM64_X24, addressSpace.get64(savedRegisterLoc)); | |
| 554 | registers.setRegister(UNW_AARCH64_X24, addressSpace.get64(savedRegisterLoc)); | |
| 555 | 555 | savedRegisterLoc -= 8; |
| 556 | 556 | } |
| 557 | 557 | if (encoding & UNWIND_ARM64_FRAME_X25_X26_PAIR) { |
| 558 | registers.setRegister(UNW_ARM64_X25, addressSpace.get64(savedRegisterLoc)); | |
| 558 | registers.setRegister(UNW_AARCH64_X25, addressSpace.get64(savedRegisterLoc)); | |
| 559 | 559 | savedRegisterLoc -= 8; |
| 560 | registers.setRegister(UNW_ARM64_X26, addressSpace.get64(savedRegisterLoc)); | |
| 560 | registers.setRegister(UNW_AARCH64_X26, addressSpace.get64(savedRegisterLoc)); | |
| 561 | 561 | savedRegisterLoc -= 8; |
| 562 | 562 | } |
| 563 | 563 | if (encoding & UNWIND_ARM64_FRAME_X27_X28_PAIR) { |
| 564 | registers.setRegister(UNW_ARM64_X27, addressSpace.get64(savedRegisterLoc)); | |
| 564 | registers.setRegister(UNW_AARCH64_X27, addressSpace.get64(savedRegisterLoc)); | |
| 565 | 565 | savedRegisterLoc -= 8; |
| 566 | registers.setRegister(UNW_ARM64_X28, addressSpace.get64(savedRegisterLoc)); | |
| 566 | registers.setRegister(UNW_AARCH64_X28, addressSpace.get64(savedRegisterLoc)); | |
| 567 | 567 | savedRegisterLoc -= 8; |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | if (encoding & UNWIND_ARM64_FRAME_D8_D9_PAIR) { |
| 571 | registers.setFloatRegister(UNW_ARM64_D8, | |
| 571 | registers.setFloatRegister(UNW_AARCH64_V8, | |
| 572 | 572 | addressSpace.getDouble(savedRegisterLoc)); |
| 573 | 573 | savedRegisterLoc -= 8; |
| 574 | registers.setFloatRegister(UNW_ARM64_D9, | |
| 574 | registers.setFloatRegister(UNW_AARCH64_V9, | |
| 575 | 575 | addressSpace.getDouble(savedRegisterLoc)); |
| 576 | 576 | savedRegisterLoc -= 8; |
| 577 | 577 | } |
| 578 | 578 | if (encoding & UNWIND_ARM64_FRAME_D10_D11_PAIR) { |
| 579 | registers.setFloatRegister(UNW_ARM64_D10, | |
| 579 | registers.setFloatRegister(UNW_AARCH64_V10, | |
| 580 | 580 | addressSpace.getDouble(savedRegisterLoc)); |
| 581 | 581 | savedRegisterLoc -= 8; |
| 582 | registers.setFloatRegister(UNW_ARM64_D11, | |
| 582 | registers.setFloatRegister(UNW_AARCH64_V11, | |
| 583 | 583 | addressSpace.getDouble(savedRegisterLoc)); |
| 584 | 584 | savedRegisterLoc -= 8; |
| 585 | 585 | } |
| 586 | 586 | if (encoding & UNWIND_ARM64_FRAME_D12_D13_PAIR) { |
| 587 | registers.setFloatRegister(UNW_ARM64_D12, | |
| 587 | registers.setFloatRegister(UNW_AARCH64_V12, | |
| 588 | 588 | addressSpace.getDouble(savedRegisterLoc)); |
| 589 | 589 | savedRegisterLoc -= 8; |
| 590 | registers.setFloatRegister(UNW_ARM64_D13, | |
| 590 | registers.setFloatRegister(UNW_AARCH64_V13, | |
| 591 | 591 | addressSpace.getDouble(savedRegisterLoc)); |
| 592 | 592 | savedRegisterLoc -= 8; |
| 593 | 593 | } |
| 594 | 594 | if (encoding & UNWIND_ARM64_FRAME_D14_D15_PAIR) { |
| 595 | registers.setFloatRegister(UNW_ARM64_D14, | |
| 595 | registers.setFloatRegister(UNW_AARCH64_V14, | |
| 596 | 596 | addressSpace.getDouble(savedRegisterLoc)); |
| 597 | 597 | savedRegisterLoc -= 8; |
| 598 | registers.setFloatRegister(UNW_ARM64_D15, | |
| 598 | registers.setFloatRegister(UNW_AARCH64_V15, | |
| 599 | 599 | addressSpace.getDouble(savedRegisterLoc)); |
| 600 | 600 | savedRegisterLoc -= 8; |
| 601 | 601 | } |
| ... | ... | @@ -604,7 +604,7 @@ int CompactUnwinder_arm64<A>::stepWithCompactEncodingFrameless( |
| 604 | 604 | registers.setSP(savedRegisterLoc); |
| 605 | 605 | |
| 606 | 606 | // set pc to be value in lr |
| 607 | registers.setIP(registers.getRegister(UNW_ARM64_LR)); | |
| 607 | registers.setIP(registers.getRegister(UNW_AARCH64_LR)); | |
| 608 | 608 | |
| 609 | 609 | return UNW_STEP_SUCCESS; |
| 610 | 610 | } |
| ... | ... | @@ -616,65 +616,65 @@ int CompactUnwinder_arm64<A>::stepWithCompactEncodingFrame( |
| 616 | 616 | uint64_t savedRegisterLoc = registers.getFP() - 8; |
| 617 | 617 | |
| 618 | 618 | if (encoding & UNWIND_ARM64_FRAME_X19_X20_PAIR) { |
| 619 | registers.setRegister(UNW_ARM64_X19, addressSpace.get64(savedRegisterLoc)); | |
| 619 | registers.setRegister(UNW_AARCH64_X19, addressSpace.get64(savedRegisterLoc)); | |
| 620 | 620 | savedRegisterLoc -= 8; |
| 621 | registers.setRegister(UNW_ARM64_X20, addressSpace.get64(savedRegisterLoc)); | |
| 621 | registers.setRegister(UNW_AARCH64_X20, addressSpace.get64(savedRegisterLoc)); | |
| 622 | 622 | savedRegisterLoc -= 8; |
| 623 | 623 | } |
| 624 | 624 | if (encoding & UNWIND_ARM64_FRAME_X21_X22_PAIR) { |
| 625 | registers.setRegister(UNW_ARM64_X21, addressSpace.get64(savedRegisterLoc)); | |
| 625 | registers.setRegister(UNW_AARCH64_X21, addressSpace.get64(savedRegisterLoc)); | |
| 626 | 626 | savedRegisterLoc -= 8; |
| 627 | registers.setRegister(UNW_ARM64_X22, addressSpace.get64(savedRegisterLoc)); | |
| 627 | registers.setRegister(UNW_AARCH64_X22, addressSpace.get64(savedRegisterLoc)); | |
| 628 | 628 | savedRegisterLoc -= 8; |
| 629 | 629 | } |
| 630 | 630 | if (encoding & UNWIND_ARM64_FRAME_X23_X24_PAIR) { |
| 631 | registers.setRegister(UNW_ARM64_X23, addressSpace.get64(savedRegisterLoc)); | |
| 631 | registers.setRegister(UNW_AARCH64_X23, addressSpace.get64(savedRegisterLoc)); | |
| 632 | 632 | savedRegisterLoc -= 8; |
| 633 | registers.setRegister(UNW_ARM64_X24, addressSpace.get64(savedRegisterLoc)); | |
| 633 | registers.setRegister(UNW_AARCH64_X24, addressSpace.get64(savedRegisterLoc)); | |
| 634 | 634 | savedRegisterLoc -= 8; |
| 635 | 635 | } |
| 636 | 636 | if (encoding & UNWIND_ARM64_FRAME_X25_X26_PAIR) { |
| 637 | registers.setRegister(UNW_ARM64_X25, addressSpace.get64(savedRegisterLoc)); | |
| 637 | registers.setRegister(UNW_AARCH64_X25, addressSpace.get64(savedRegisterLoc)); | |
| 638 | 638 | savedRegisterLoc -= 8; |
| 639 | registers.setRegister(UNW_ARM64_X26, addressSpace.get64(savedRegisterLoc)); | |
| 639 | registers.setRegister(UNW_AARCH64_X26, addressSpace.get64(savedRegisterLoc)); | |
| 640 | 640 | savedRegisterLoc -= 8; |
| 641 | 641 | } |
| 642 | 642 | if (encoding & UNWIND_ARM64_FRAME_X27_X28_PAIR) { |
| 643 | registers.setRegister(UNW_ARM64_X27, addressSpace.get64(savedRegisterLoc)); | |
| 643 | registers.setRegister(UNW_AARCH64_X27, addressSpace.get64(savedRegisterLoc)); | |
| 644 | 644 | savedRegisterLoc -= 8; |
| 645 | registers.setRegister(UNW_ARM64_X28, addressSpace.get64(savedRegisterLoc)); | |
| 645 | registers.setRegister(UNW_AARCH64_X28, addressSpace.get64(savedRegisterLoc)); | |
| 646 | 646 | savedRegisterLoc -= 8; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | if (encoding & UNWIND_ARM64_FRAME_D8_D9_PAIR) { |
| 650 | registers.setFloatRegister(UNW_ARM64_D8, | |
| 650 | registers.setFloatRegister(UNW_AARCH64_V8, | |
| 651 | 651 | addressSpace.getDouble(savedRegisterLoc)); |
| 652 | 652 | savedRegisterLoc -= 8; |
| 653 | registers.setFloatRegister(UNW_ARM64_D9, | |
| 653 | registers.setFloatRegister(UNW_AARCH64_V9, | |
| 654 | 654 | addressSpace.getDouble(savedRegisterLoc)); |
| 655 | 655 | savedRegisterLoc -= 8; |
| 656 | 656 | } |
| 657 | 657 | if (encoding & UNWIND_ARM64_FRAME_D10_D11_PAIR) { |
| 658 | registers.setFloatRegister(UNW_ARM64_D10, | |
| 658 | registers.setFloatRegister(UNW_AARCH64_V10, | |
| 659 | 659 | addressSpace.getDouble(savedRegisterLoc)); |
| 660 | 660 | savedRegisterLoc -= 8; |
| 661 | registers.setFloatRegister(UNW_ARM64_D11, | |
| 661 | registers.setFloatRegister(UNW_AARCH64_V11, | |
| 662 | 662 | addressSpace.getDouble(savedRegisterLoc)); |
| 663 | 663 | savedRegisterLoc -= 8; |
| 664 | 664 | } |
| 665 | 665 | if (encoding & UNWIND_ARM64_FRAME_D12_D13_PAIR) { |
| 666 | registers.setFloatRegister(UNW_ARM64_D12, | |
| 666 | registers.setFloatRegister(UNW_AARCH64_V12, | |
| 667 | 667 | addressSpace.getDouble(savedRegisterLoc)); |
| 668 | 668 | savedRegisterLoc -= 8; |
| 669 | registers.setFloatRegister(UNW_ARM64_D13, | |
| 669 | registers.setFloatRegister(UNW_AARCH64_V13, | |
| 670 | 670 | addressSpace.getDouble(savedRegisterLoc)); |
| 671 | 671 | savedRegisterLoc -= 8; |
| 672 | 672 | } |
| 673 | 673 | if (encoding & UNWIND_ARM64_FRAME_D14_D15_PAIR) { |
| 674 | registers.setFloatRegister(UNW_ARM64_D14, | |
| 674 | registers.setFloatRegister(UNW_AARCH64_V14, | |
| 675 | 675 | addressSpace.getDouble(savedRegisterLoc)); |
| 676 | 676 | savedRegisterLoc -= 8; |
| 677 | registers.setFloatRegister(UNW_ARM64_D15, | |
| 677 | registers.setFloatRegister(UNW_AARCH64_V15, | |
| 678 | 678 | addressSpace.getDouble(savedRegisterLoc)); |
| 679 | 679 | savedRegisterLoc -= 8; |
| 680 | 680 | } |
lib/libunwind/src/DwarfInstructions.hpp+26-10| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------------- DwarfInstructions.hpp ---------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -67,14 +67,13 @@ private: |
| 67 | 67 | return (pint_t)((sint_t)registers.getRegister((int)prolog.cfaRegister) + |
| 68 | 68 | prolog.cfaRegisterOffset); |
| 69 | 69 | if (prolog.cfaExpression != 0) |
| 70 | return evaluateExpression((pint_t)prolog.cfaExpression, addressSpace, | |
| 70 | return evaluateExpression((pint_t)prolog.cfaExpression, addressSpace, | |
| 71 | 71 | registers, 0); |
| 72 | 72 | assert(0 && "getCFA(): unknown location"); |
| 73 | 73 | __builtin_unreachable(); |
| 74 | 74 | } |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | ||
| 78 | 77 | template <typename R> |
| 79 | 78 | auto getSparcWCookie(const R &r, int) -> decltype(r.getWCookie()) { |
| 80 | 79 | return r.getWCookie(); |
| ... | ... | @@ -92,8 +91,8 @@ typename A::pint_t DwarfInstructions<A, R>::getSavedRegister( |
| 92 | 91 | return (pint_t)addressSpace.getRegister(cfa + (pint_t)savedReg.value); |
| 93 | 92 | |
| 94 | 93 | case CFI_Parser<A>::kRegisterInCFADecrypt: // sparc64 specific |
| 95 | return addressSpace.getP(cfa + (pint_t)savedReg.value) ^ | |
| 96 | getSparcWCookie(registers, 0); | |
| 94 | return (pint_t)(addressSpace.getP(cfa + (pint_t)savedReg.value) ^ | |
| 95 | getSparcWCookie(registers, 0)); | |
| 97 | 96 | |
| 98 | 97 | case CFI_Parser<A>::kRegisterAtExpression: |
| 99 | 98 | return (pint_t)addressSpace.getRegister(evaluateExpression( |
| ... | ... | @@ -127,12 +126,15 @@ double DwarfInstructions<A, R>::getSavedFloatRegister( |
| 127 | 126 | return addressSpace.getDouble( |
| 128 | 127 | evaluateExpression((pint_t)savedReg.value, addressSpace, |
| 129 | 128 | registers, cfa)); |
| 130 | ||
| 129 | case CFI_Parser<A>::kRegisterUndefined: | |
| 130 | return 0.0; | |
| 131 | case CFI_Parser<A>::kRegisterInRegister: | |
| 132 | #ifndef _LIBUNWIND_TARGET_ARM | |
| 133 | return registers.getFloatRegister((int)savedReg.value); | |
| 134 | #endif | |
| 131 | 135 | case CFI_Parser<A>::kRegisterIsExpression: |
| 132 | 136 | case CFI_Parser<A>::kRegisterUnused: |
| 133 | case CFI_Parser<A>::kRegisterUndefined: | |
| 134 | 137 | case CFI_Parser<A>::kRegisterOffsetFromCFA: |
| 135 | case CFI_Parser<A>::kRegisterInRegister: | |
| 136 | 138 | case CFI_Parser<A>::kRegisterInCFADecrypt: |
| 137 | 139 | // FIX ME |
| 138 | 140 | break; |
| ... | ... | @@ -233,7 +235,7 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc, |
| 233 | 235 | // restored. autia1716 is used instead of autia as autia1716 assembles |
| 234 | 236 | // to a NOP on pre-v8.3a architectures. |
| 235 | 237 | if ((R::getArch() == REGISTERS_ARM64) && |
| 236 | prolog.savedRegisters[UNW_ARM64_RA_SIGN_STATE].value && | |
| 238 | prolog.savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value && | |
| 237 | 239 | returnAddress != 0) { |
| 238 | 240 | #if !defined(_LIBUNWIND_IS_NATIVE_ONLY) |
| 239 | 241 | return UNW_ECROSSRASIGNING; |
| ... | ... | @@ -253,6 +255,20 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc, |
| 253 | 255 | } |
| 254 | 256 | #endif |
| 255 | 257 | |
| 258 | #if defined(_LIBUNWIND_IS_NATIVE_ONLY) && defined(_LIBUNWIND_TARGET_ARM) && \ | |
| 259 | defined(__ARM_FEATURE_PAUTH) | |
| 260 | if ((R::getArch() == REGISTERS_ARM) && | |
| 261 | prolog.savedRegisters[UNW_ARM_RA_AUTH_CODE].value) { | |
| 262 | pint_t pac = | |
| 263 | getSavedRegister(addressSpace, registers, cfa, | |
| 264 | prolog.savedRegisters[UNW_ARM_RA_AUTH_CODE]); | |
| 265 | __asm__ __volatile__("autg %0, %1, %2" | |
| 266 | : | |
| 267 | : "r"(pac), "r"(returnAddress), "r"(cfa) | |
| 268 | :); | |
| 269 | } | |
| 270 | #endif | |
| 271 | ||
| 256 | 272 | #if defined(_LIBUNWIND_TARGET_SPARC) |
| 257 | 273 | if (R::getArch() == REGISTERS_SPARC) { |
| 258 | 274 | // Skip call site instruction and delay slot |
| ... | ... | @@ -264,7 +280,7 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc, |
| 264 | 280 | #endif |
| 265 | 281 | |
| 266 | 282 | #if defined(_LIBUNWIND_TARGET_SPARC64) |
| 267 | // Skip call site instruction and delay slot | |
| 283 | // Skip call site instruction and delay slot. | |
| 268 | 284 | if (R::getArch() == REGISTERS_SPARC64) |
| 269 | 285 | returnAddress += 8; |
| 270 | 286 | #endif |
lib/libunwind/src/DwarfParser.hpp+26-14| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------------- DwarfParser.hpp --------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -152,10 +152,11 @@ public: |
| 152 | 152 | }; |
| 153 | 153 | |
| 154 | 154 | static bool findFDE(A &addressSpace, pint_t pc, pint_t ehSectionStart, |
| 155 | uintptr_t sectionLength, pint_t fdeHint, FDE_Info *fdeInfo, | |
| 155 | size_t sectionLength, pint_t fdeHint, FDE_Info *fdeInfo, | |
| 156 | 156 | CIE_Info *cieInfo); |
| 157 | 157 | static const char *decodeFDE(A &addressSpace, pint_t fdeStart, |
| 158 | FDE_Info *fdeInfo, CIE_Info *cieInfo); | |
| 158 | FDE_Info *fdeInfo, CIE_Info *cieInfo, | |
| 159 | bool useCIEInfo = false); | |
| 159 | 160 | static bool parseFDEInstructions(A &addressSpace, const FDE_Info &fdeInfo, |
| 160 | 161 | const CIE_Info &cieInfo, pint_t upToPC, |
| 161 | 162 | int arch, PrologInfo *results); |
| ... | ... | @@ -163,10 +164,14 @@ public: |
| 163 | 164 | static const char *parseCIE(A &addressSpace, pint_t cie, CIE_Info *cieInfo); |
| 164 | 165 | }; |
| 165 | 166 | |
| 166 | /// Parse a FDE into a CIE_Info and an FDE_Info | |
| 167 | /// Parse a FDE into a CIE_Info and an FDE_Info. If useCIEInfo is | |
| 168 | /// true, treat cieInfo as already-parsed CIE_Info (whose start offset | |
| 169 | /// must match the one specified by the FDE) rather than parsing the | |
| 170 | /// one indicated within the FDE. | |
| 167 | 171 | template <typename A> |
| 168 | 172 | const char *CFI_Parser<A>::decodeFDE(A &addressSpace, pint_t fdeStart, |
| 169 | FDE_Info *fdeInfo, CIE_Info *cieInfo) { | |
| 173 | FDE_Info *fdeInfo, CIE_Info *cieInfo, | |
| 174 | bool useCIEInfo) { | |
| 170 | 175 | pint_t p = fdeStart; |
| 171 | 176 | pint_t cfiLength = (pint_t)addressSpace.get32(p); |
| 172 | 177 | p += 4; |
| ... | ... | @@ -182,9 +187,14 @@ const char *CFI_Parser<A>::decodeFDE(A &addressSpace, pint_t fdeStart, |
| 182 | 187 | return "FDE is really a CIE"; // this is a CIE not an FDE |
| 183 | 188 | pint_t nextCFI = p + cfiLength; |
| 184 | 189 | pint_t cieStart = p - ciePointer; |
| 185 | const char *err = parseCIE(addressSpace, cieStart, cieInfo); | |
| 186 | if (err != NULL) | |
| 187 | return err; | |
| 190 | if (useCIEInfo) { | |
| 191 | if (cieInfo->cieStart != cieStart) | |
| 192 | return "CIE start does not match"; | |
| 193 | } else { | |
| 194 | const char *err = parseCIE(addressSpace, cieStart, cieInfo); | |
| 195 | if (err != NULL) | |
| 196 | return err; | |
| 197 | } | |
| 188 | 198 | p += 4; |
| 189 | 199 | // Parse pc begin and range. |
| 190 | 200 | pint_t pcStart = |
| ... | ... | @@ -221,11 +231,11 @@ const char *CFI_Parser<A>::decodeFDE(A &addressSpace, pint_t fdeStart, |
| 221 | 231 | /// Scan an eh_frame section to find an FDE for a pc |
| 222 | 232 | template <typename A> |
| 223 | 233 | bool CFI_Parser<A>::findFDE(A &addressSpace, pint_t pc, pint_t ehSectionStart, |
| 224 | uintptr_t sectionLength, pint_t fdeHint, | |
| 234 | size_t sectionLength, pint_t fdeHint, | |
| 225 | 235 | FDE_Info *fdeInfo, CIE_Info *cieInfo) { |
| 226 | 236 | //fprintf(stderr, "findFDE(0x%llX)\n", (long long)pc); |
| 227 | 237 | pint_t p = (fdeHint != 0) ? fdeHint : ehSectionStart; |
| 228 | const pint_t ehSectionEnd = (sectionLength == UINTPTR_MAX) | |
| 238 | const pint_t ehSectionEnd = (sectionLength == SIZE_MAX) | |
| 229 | 239 | ? static_cast<pint_t>(-1) |
| 230 | 240 | : (ehSectionStart + sectionLength); |
| 231 | 241 | while (p < ehSectionEnd) { |
| ... | ... | @@ -735,8 +745,8 @@ bool CFI_Parser<A>::parseFDEInstructions(A &addressSpace, |
| 735 | 745 | #if defined(_LIBUNWIND_TARGET_AARCH64) |
| 736 | 746 | case REGISTERS_ARM64: { |
| 737 | 747 | int64_t value = |
| 738 | results->savedRegisters[UNW_ARM64_RA_SIGN_STATE].value ^ 0x1; | |
| 739 | results->setRegisterValue(UNW_ARM64_RA_SIGN_STATE, value, | |
| 748 | results->savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value ^ 0x1; | |
| 749 | results->setRegisterValue(UNW_AARCH64_RA_SIGN_STATE, value, | |
| 740 | 750 | initialState); |
| 741 | 751 | _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n"); |
| 742 | 752 | } break; |
| ... | ... | @@ -770,11 +780,13 @@ bool CFI_Parser<A>::parseFDEInstructions(A &addressSpace, |
| 770 | 780 | if (reg == UNW_SPARC_I7) |
| 771 | 781 | results->setRegister( |
| 772 | 782 | reg, kRegisterInCFADecrypt, |
| 773 | ((int64_t)reg - UNW_SPARC_L0) * sizeof(pint_t), initialState); | |
| 783 | static_cast<int64_t>((reg - UNW_SPARC_L0) * sizeof(pint_t)), | |
| 784 | initialState); | |
| 774 | 785 | else |
| 775 | 786 | results->setRegister( |
| 776 | 787 | reg, kRegisterInCFA, |
| 777 | ((int64_t)reg - UNW_SPARC_L0) * sizeof(pint_t), initialState); | |
| 788 | static_cast<int64_t>((reg - UNW_SPARC_L0) * sizeof(pint_t)), | |
| 789 | initialState); | |
| 778 | 790 | } |
| 779 | 791 | _LIBUNWIND_TRACE_DWARF("DW_CFA_GNU_window_save\n"); |
| 780 | 792 | break; |
lib/libunwind/src/EHHeaderParser.hpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- EHHeaderParser.hpp -------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libunwind/src/RWMutex.hpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===----------------------------- Registers.hpp --------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libunwind/src/Registers.hpp+123-84| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===----------------------------- Registers.hpp --------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -15,8 +15,9 @@ |
| 15 | 15 | #include <stdint.h> |
| 16 | 16 | #include <string.h> |
| 17 | 17 | |
| 18 | #include "libunwind.h" | |
| 18 | #include "cet_unwind.h" | |
| 19 | 19 | #include "config.h" |
| 20 | #include "libunwind.h" | |
| 20 | 21 | |
| 21 | 22 | namespace libunwind { |
| 22 | 23 | |
| ... | ... | @@ -43,6 +44,13 @@ enum { |
| 43 | 44 | #if defined(_LIBUNWIND_TARGET_I386) |
| 44 | 45 | class _LIBUNWIND_HIDDEN Registers_x86; |
| 45 | 46 | extern "C" void __libunwind_Registers_x86_jumpto(Registers_x86 *); |
| 47 | ||
| 48 | #if defined(_LIBUNWIND_USE_CET) | |
| 49 | extern "C" void *__libunwind_cet_get_jump_target() { | |
| 50 | return reinterpret_cast<void *>(&__libunwind_Registers_x86_jumpto); | |
| 51 | } | |
| 52 | #endif | |
| 53 | ||
| 46 | 54 | /// Registers_x86 holds the register state of a thread in a 32-bit intel |
| 47 | 55 | /// process. |
| 48 | 56 | class _LIBUNWIND_HIDDEN Registers_x86 { |
| ... | ... | @@ -254,6 +262,13 @@ inline void Registers_x86::setVectorRegister(int, v128) { |
| 254 | 262 | /// process. |
| 255 | 263 | class _LIBUNWIND_HIDDEN Registers_x86_64; |
| 256 | 264 | extern "C" void __libunwind_Registers_x86_64_jumpto(Registers_x86_64 *); |
| 265 | ||
| 266 | #if defined(_LIBUNWIND_USE_CET) | |
| 267 | extern "C" void *__libunwind_cet_get_jump_target() { | |
| 268 | return reinterpret_cast<void *>(&__libunwind_Registers_x86_64_jumpto); | |
| 269 | } | |
| 270 | #endif | |
| 271 | ||
| 257 | 272 | class _LIBUNWIND_HIDDEN Registers_x86_64 { |
| 258 | 273 | public: |
| 259 | 274 | Registers_x86_64(); |
| ... | ... | @@ -340,7 +355,7 @@ inline bool Registers_x86_64::validRegister(int regNum) const { |
| 340 | 355 | return true; |
| 341 | 356 | if (regNum < 0) |
| 342 | 357 | return false; |
| 343 | if (regNum > 15) | |
| 358 | if (regNum > 16) | |
| 344 | 359 | return false; |
| 345 | 360 | return true; |
| 346 | 361 | } |
| ... | ... | @@ -348,6 +363,7 @@ inline bool Registers_x86_64::validRegister(int regNum) const { |
| 348 | 363 | inline uint64_t Registers_x86_64::getRegister(int regNum) const { |
| 349 | 364 | switch (regNum) { |
| 350 | 365 | case UNW_REG_IP: |
| 366 | case UNW_X86_64_RIP: | |
| 351 | 367 | return _registers.__rip; |
| 352 | 368 | case UNW_REG_SP: |
| 353 | 369 | return _registers.__rsp; |
| ... | ... | @@ -390,6 +406,7 @@ inline uint64_t Registers_x86_64::getRegister(int regNum) const { |
| 390 | 406 | inline void Registers_x86_64::setRegister(int regNum, uint64_t value) { |
| 391 | 407 | switch (regNum) { |
| 392 | 408 | case UNW_REG_IP: |
| 409 | case UNW_X86_64_RIP: | |
| 393 | 410 | _registers.__rip = value; |
| 394 | 411 | return; |
| 395 | 412 | case UNW_REG_SP: |
| ... | ... | @@ -450,6 +467,7 @@ inline void Registers_x86_64::setRegister(int regNum, uint64_t value) { |
| 450 | 467 | inline const char *Registers_x86_64::getRegisterName(int regNum) { |
| 451 | 468 | switch (regNum) { |
| 452 | 469 | case UNW_REG_IP: |
| 470 | case UNW_X86_64_RIP: | |
| 453 | 471 | return "rip"; |
| 454 | 472 | case UNW_REG_SP: |
| 455 | 473 | return "rsp"; |
| ... | ... | @@ -1848,7 +1866,7 @@ inline bool Registers_arm64::validRegister(int regNum) const { |
| 1848 | 1866 | return false; |
| 1849 | 1867 | if (regNum > 95) |
| 1850 | 1868 | return false; |
| 1851 | if (regNum == UNW_ARM64_RA_SIGN_STATE) | |
| 1869 | if (regNum == UNW_AARCH64_RA_SIGN_STATE) | |
| 1852 | 1870 | return true; |
| 1853 | 1871 | if ((regNum > 32) && (regNum < 64)) |
| 1854 | 1872 | return false; |
| ... | ... | @@ -1856,15 +1874,15 @@ inline bool Registers_arm64::validRegister(int regNum) const { |
| 1856 | 1874 | } |
| 1857 | 1875 | |
| 1858 | 1876 | inline uint64_t Registers_arm64::getRegister(int regNum) const { |
| 1859 | if (regNum == UNW_REG_IP || regNum == UNW_ARM64_PC) | |
| 1877 | if (regNum == UNW_REG_IP || regNum == UNW_AARCH64_PC) | |
| 1860 | 1878 | return _registers.__pc; |
| 1861 | if (regNum == UNW_REG_SP || regNum == UNW_ARM64_SP) | |
| 1879 | if (regNum == UNW_REG_SP || regNum == UNW_AARCH64_SP) | |
| 1862 | 1880 | return _registers.__sp; |
| 1863 | if (regNum == UNW_ARM64_RA_SIGN_STATE) | |
| 1881 | if (regNum == UNW_AARCH64_RA_SIGN_STATE) | |
| 1864 | 1882 | return _registers.__ra_sign_state; |
| 1865 | if (regNum == UNW_ARM64_FP) | |
| 1883 | if (regNum == UNW_AARCH64_FP) | |
| 1866 | 1884 | return _registers.__fp; |
| 1867 | if (regNum == UNW_ARM64_LR) | |
| 1885 | if (regNum == UNW_AARCH64_LR) | |
| 1868 | 1886 | return _registers.__lr; |
| 1869 | 1887 | if ((regNum >= 0) && (regNum < 29)) |
| 1870 | 1888 | return _registers.__x[regNum]; |
| ... | ... | @@ -1872,15 +1890,15 @@ inline uint64_t Registers_arm64::getRegister(int regNum) const { |
| 1872 | 1890 | } |
| 1873 | 1891 | |
| 1874 | 1892 | inline void Registers_arm64::setRegister(int regNum, uint64_t value) { |
| 1875 | if (regNum == UNW_REG_IP || regNum == UNW_ARM64_PC) | |
| 1893 | if (regNum == UNW_REG_IP || regNum == UNW_AARCH64_PC) | |
| 1876 | 1894 | _registers.__pc = value; |
| 1877 | else if (regNum == UNW_REG_SP || regNum == UNW_ARM64_SP) | |
| 1895 | else if (regNum == UNW_REG_SP || regNum == UNW_AARCH64_SP) | |
| 1878 | 1896 | _registers.__sp = value; |
| 1879 | else if (regNum == UNW_ARM64_RA_SIGN_STATE) | |
| 1897 | else if (regNum == UNW_AARCH64_RA_SIGN_STATE) | |
| 1880 | 1898 | _registers.__ra_sign_state = value; |
| 1881 | else if (regNum == UNW_ARM64_FP) | |
| 1899 | else if (regNum == UNW_AARCH64_FP) | |
| 1882 | 1900 | _registers.__fp = value; |
| 1883 | else if (regNum == UNW_ARM64_LR) | |
| 1901 | else if (regNum == UNW_AARCH64_LR) | |
| 1884 | 1902 | _registers.__lr = value; |
| 1885 | 1903 | else if ((regNum >= 0) && (regNum < 29)) |
| 1886 | 1904 | _registers.__x[regNum] = value; |
| ... | ... | @@ -1894,135 +1912,135 @@ inline const char *Registers_arm64::getRegisterName(int regNum) { |
| 1894 | 1912 | return "pc"; |
| 1895 | 1913 | case UNW_REG_SP: |
| 1896 | 1914 | return "sp"; |
| 1897 | case UNW_ARM64_X0: | |
| 1915 | case UNW_AARCH64_X0: | |
| 1898 | 1916 | return "x0"; |
| 1899 | case UNW_ARM64_X1: | |
| 1917 | case UNW_AARCH64_X1: | |
| 1900 | 1918 | return "x1"; |
| 1901 | case UNW_ARM64_X2: | |
| 1919 | case UNW_AARCH64_X2: | |
| 1902 | 1920 | return "x2"; |
| 1903 | case UNW_ARM64_X3: | |
| 1921 | case UNW_AARCH64_X3: | |
| 1904 | 1922 | return "x3"; |
| 1905 | case UNW_ARM64_X4: | |
| 1923 | case UNW_AARCH64_X4: | |
| 1906 | 1924 | return "x4"; |
| 1907 | case UNW_ARM64_X5: | |
| 1925 | case UNW_AARCH64_X5: | |
| 1908 | 1926 | return "x5"; |
| 1909 | case UNW_ARM64_X6: | |
| 1927 | case UNW_AARCH64_X6: | |
| 1910 | 1928 | return "x6"; |
| 1911 | case UNW_ARM64_X7: | |
| 1929 | case UNW_AARCH64_X7: | |
| 1912 | 1930 | return "x7"; |
| 1913 | case UNW_ARM64_X8: | |
| 1931 | case UNW_AARCH64_X8: | |
| 1914 | 1932 | return "x8"; |
| 1915 | case UNW_ARM64_X9: | |
| 1933 | case UNW_AARCH64_X9: | |
| 1916 | 1934 | return "x9"; |
| 1917 | case UNW_ARM64_X10: | |
| 1935 | case UNW_AARCH64_X10: | |
| 1918 | 1936 | return "x10"; |
| 1919 | case UNW_ARM64_X11: | |
| 1937 | case UNW_AARCH64_X11: | |
| 1920 | 1938 | return "x11"; |
| 1921 | case UNW_ARM64_X12: | |
| 1939 | case UNW_AARCH64_X12: | |
| 1922 | 1940 | return "x12"; |
| 1923 | case UNW_ARM64_X13: | |
| 1941 | case UNW_AARCH64_X13: | |
| 1924 | 1942 | return "x13"; |
| 1925 | case UNW_ARM64_X14: | |
| 1943 | case UNW_AARCH64_X14: | |
| 1926 | 1944 | return "x14"; |
| 1927 | case UNW_ARM64_X15: | |
| 1945 | case UNW_AARCH64_X15: | |
| 1928 | 1946 | return "x15"; |
| 1929 | case UNW_ARM64_X16: | |
| 1947 | case UNW_AARCH64_X16: | |
| 1930 | 1948 | return "x16"; |
| 1931 | case UNW_ARM64_X17: | |
| 1949 | case UNW_AARCH64_X17: | |
| 1932 | 1950 | return "x17"; |
| 1933 | case UNW_ARM64_X18: | |
| 1951 | case UNW_AARCH64_X18: | |
| 1934 | 1952 | return "x18"; |
| 1935 | case UNW_ARM64_X19: | |
| 1953 | case UNW_AARCH64_X19: | |
| 1936 | 1954 | return "x19"; |
| 1937 | case UNW_ARM64_X20: | |
| 1955 | case UNW_AARCH64_X20: | |
| 1938 | 1956 | return "x20"; |
| 1939 | case UNW_ARM64_X21: | |
| 1957 | case UNW_AARCH64_X21: | |
| 1940 | 1958 | return "x21"; |
| 1941 | case UNW_ARM64_X22: | |
| 1959 | case UNW_AARCH64_X22: | |
| 1942 | 1960 | return "x22"; |
| 1943 | case UNW_ARM64_X23: | |
| 1961 | case UNW_AARCH64_X23: | |
| 1944 | 1962 | return "x23"; |
| 1945 | case UNW_ARM64_X24: | |
| 1963 | case UNW_AARCH64_X24: | |
| 1946 | 1964 | return "x24"; |
| 1947 | case UNW_ARM64_X25: | |
| 1965 | case UNW_AARCH64_X25: | |
| 1948 | 1966 | return "x25"; |
| 1949 | case UNW_ARM64_X26: | |
| 1967 | case UNW_AARCH64_X26: | |
| 1950 | 1968 | return "x26"; |
| 1951 | case UNW_ARM64_X27: | |
| 1969 | case UNW_AARCH64_X27: | |
| 1952 | 1970 | return "x27"; |
| 1953 | case UNW_ARM64_X28: | |
| 1971 | case UNW_AARCH64_X28: | |
| 1954 | 1972 | return "x28"; |
| 1955 | case UNW_ARM64_FP: | |
| 1973 | case UNW_AARCH64_FP: | |
| 1956 | 1974 | return "fp"; |
| 1957 | case UNW_ARM64_LR: | |
| 1975 | case UNW_AARCH64_LR: | |
| 1958 | 1976 | return "lr"; |
| 1959 | case UNW_ARM64_SP: | |
| 1977 | case UNW_AARCH64_SP: | |
| 1960 | 1978 | return "sp"; |
| 1961 | case UNW_ARM64_PC: | |
| 1979 | case UNW_AARCH64_PC: | |
| 1962 | 1980 | return "pc"; |
| 1963 | case UNW_ARM64_D0: | |
| 1981 | case UNW_AARCH64_V0: | |
| 1964 | 1982 | return "d0"; |
| 1965 | case UNW_ARM64_D1: | |
| 1983 | case UNW_AARCH64_V1: | |
| 1966 | 1984 | return "d1"; |
| 1967 | case UNW_ARM64_D2: | |
| 1985 | case UNW_AARCH64_V2: | |
| 1968 | 1986 | return "d2"; |
| 1969 | case UNW_ARM64_D3: | |
| 1987 | case UNW_AARCH64_V3: | |
| 1970 | 1988 | return "d3"; |
| 1971 | case UNW_ARM64_D4: | |
| 1989 | case UNW_AARCH64_V4: | |
| 1972 | 1990 | return "d4"; |
| 1973 | case UNW_ARM64_D5: | |
| 1991 | case UNW_AARCH64_V5: | |
| 1974 | 1992 | return "d5"; |
| 1975 | case UNW_ARM64_D6: | |
| 1993 | case UNW_AARCH64_V6: | |
| 1976 | 1994 | return "d6"; |
| 1977 | case UNW_ARM64_D7: | |
| 1995 | case UNW_AARCH64_V7: | |
| 1978 | 1996 | return "d7"; |
| 1979 | case UNW_ARM64_D8: | |
| 1997 | case UNW_AARCH64_V8: | |
| 1980 | 1998 | return "d8"; |
| 1981 | case UNW_ARM64_D9: | |
| 1999 | case UNW_AARCH64_V9: | |
| 1982 | 2000 | return "d9"; |
| 1983 | case UNW_ARM64_D10: | |
| 2001 | case UNW_AARCH64_V10: | |
| 1984 | 2002 | return "d10"; |
| 1985 | case UNW_ARM64_D11: | |
| 2003 | case UNW_AARCH64_V11: | |
| 1986 | 2004 | return "d11"; |
| 1987 | case UNW_ARM64_D12: | |
| 2005 | case UNW_AARCH64_V12: | |
| 1988 | 2006 | return "d12"; |
| 1989 | case UNW_ARM64_D13: | |
| 2007 | case UNW_AARCH64_V13: | |
| 1990 | 2008 | return "d13"; |
| 1991 | case UNW_ARM64_D14: | |
| 2009 | case UNW_AARCH64_V14: | |
| 1992 | 2010 | return "d14"; |
| 1993 | case UNW_ARM64_D15: | |
| 2011 | case UNW_AARCH64_V15: | |
| 1994 | 2012 | return "d15"; |
| 1995 | case UNW_ARM64_D16: | |
| 2013 | case UNW_AARCH64_V16: | |
| 1996 | 2014 | return "d16"; |
| 1997 | case UNW_ARM64_D17: | |
| 2015 | case UNW_AARCH64_V17: | |
| 1998 | 2016 | return "d17"; |
| 1999 | case UNW_ARM64_D18: | |
| 2017 | case UNW_AARCH64_V18: | |
| 2000 | 2018 | return "d18"; |
| 2001 | case UNW_ARM64_D19: | |
| 2019 | case UNW_AARCH64_V19: | |
| 2002 | 2020 | return "d19"; |
| 2003 | case UNW_ARM64_D20: | |
| 2021 | case UNW_AARCH64_V20: | |
| 2004 | 2022 | return "d20"; |
| 2005 | case UNW_ARM64_D21: | |
| 2023 | case UNW_AARCH64_V21: | |
| 2006 | 2024 | return "d21"; |
| 2007 | case UNW_ARM64_D22: | |
| 2025 | case UNW_AARCH64_V22: | |
| 2008 | 2026 | return "d22"; |
| 2009 | case UNW_ARM64_D23: | |
| 2027 | case UNW_AARCH64_V23: | |
| 2010 | 2028 | return "d23"; |
| 2011 | case UNW_ARM64_D24: | |
| 2029 | case UNW_AARCH64_V24: | |
| 2012 | 2030 | return "d24"; |
| 2013 | case UNW_ARM64_D25: | |
| 2031 | case UNW_AARCH64_V25: | |
| 2014 | 2032 | return "d25"; |
| 2015 | case UNW_ARM64_D26: | |
| 2033 | case UNW_AARCH64_V26: | |
| 2016 | 2034 | return "d26"; |
| 2017 | case UNW_ARM64_D27: | |
| 2035 | case UNW_AARCH64_V27: | |
| 2018 | 2036 | return "d27"; |
| 2019 | case UNW_ARM64_D28: | |
| 2037 | case UNW_AARCH64_V28: | |
| 2020 | 2038 | return "d28"; |
| 2021 | case UNW_ARM64_D29: | |
| 2039 | case UNW_AARCH64_V29: | |
| 2022 | 2040 | return "d29"; |
| 2023 | case UNW_ARM64_D30: | |
| 2041 | case UNW_AARCH64_V30: | |
| 2024 | 2042 | return "d30"; |
| 2025 | case UNW_ARM64_D31: | |
| 2043 | case UNW_AARCH64_V31: | |
| 2026 | 2044 | return "d31"; |
| 2027 | 2045 | default: |
| 2028 | 2046 | return "unknown register"; |
| ... | ... | @@ -2030,21 +2048,21 @@ inline const char *Registers_arm64::getRegisterName(int regNum) { |
| 2030 | 2048 | } |
| 2031 | 2049 | |
| 2032 | 2050 | inline bool Registers_arm64::validFloatRegister(int regNum) const { |
| 2033 | if (regNum < UNW_ARM64_D0) | |
| 2051 | if (regNum < UNW_AARCH64_V0) | |
| 2034 | 2052 | return false; |
| 2035 | if (regNum > UNW_ARM64_D31) | |
| 2053 | if (regNum > UNW_AARCH64_V31) | |
| 2036 | 2054 | return false; |
| 2037 | 2055 | return true; |
| 2038 | 2056 | } |
| 2039 | 2057 | |
| 2040 | 2058 | inline double Registers_arm64::getFloatRegister(int regNum) const { |
| 2041 | 2059 | assert(validFloatRegister(regNum)); |
| 2042 | return _vectorHalfRegisters[regNum - UNW_ARM64_D0]; | |
| 2060 | return _vectorHalfRegisters[regNum - UNW_AARCH64_V0]; | |
| 2043 | 2061 | } |
| 2044 | 2062 | |
| 2045 | 2063 | inline void Registers_arm64::setFloatRegister(int regNum, double value) { |
| 2046 | 2064 | assert(validFloatRegister(regNum)); |
| 2047 | _vectorHalfRegisters[regNum - UNW_ARM64_D0] = value; | |
| 2065 | _vectorHalfRegisters[regNum - UNW_AARCH64_V0] = value; | |
| 2048 | 2066 | } |
| 2049 | 2067 | |
| 2050 | 2068 | inline bool Registers_arm64::validVectorRegister(int) const { |
| ... | ... | @@ -2123,6 +2141,10 @@ private: |
| 2123 | 2141 | uint32_t __pc; // Program counter r15 |
| 2124 | 2142 | }; |
| 2125 | 2143 | |
| 2144 | struct PseudoRegisters { | |
| 2145 | uint32_t __pac; // Return Authentication Code (PAC) | |
| 2146 | }; | |
| 2147 | ||
| 2126 | 2148 | static void saveVFPWithFSTMD(void*); |
| 2127 | 2149 | static void saveVFPWithFSTMX(void*); |
| 2128 | 2150 | static void saveVFPv3(void*); |
| ... | ... | @@ -2139,6 +2161,7 @@ private: |
| 2139 | 2161 | |
| 2140 | 2162 | // ARM registers |
| 2141 | 2163 | GPRs _registers; |
| 2164 | PseudoRegisters _pseudo_registers; | |
| 2142 | 2165 | |
| 2143 | 2166 | // We save floating point registers lazily because we can't know ahead of |
| 2144 | 2167 | // time which ones are used. See EHABI #4.7. |
| ... | ... | @@ -2176,6 +2199,7 @@ inline Registers_arm::Registers_arm(const void *registers) |
| 2176 | 2199 | "arm registers do not fit into unw_context_t"); |
| 2177 | 2200 | // See __unw_getcontext() note about data. |
| 2178 | 2201 | memcpy(&_registers, registers, sizeof(_registers)); |
| 2202 | memset(&_pseudo_registers, 0, sizeof(_pseudo_registers)); | |
| 2179 | 2203 | memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad)); |
| 2180 | 2204 | memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31)); |
| 2181 | 2205 | #if defined(__ARM_WMMX) |
| ... | ... | @@ -2191,6 +2215,7 @@ inline Registers_arm::Registers_arm() |
| 2191 | 2215 | _saved_vfp_d0_d15(false), |
| 2192 | 2216 | _saved_vfp_d16_d31(false) { |
| 2193 | 2217 | memset(&_registers, 0, sizeof(_registers)); |
| 2218 | memset(&_pseudo_registers, 0, sizeof(_pseudo_registers)); | |
| 2194 | 2219 | memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad)); |
| 2195 | 2220 | memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31)); |
| 2196 | 2221 | #if defined(__ARM_WMMX) |
| ... | ... | @@ -2218,6 +2243,11 @@ inline bool Registers_arm::validRegister(int regNum) const { |
| 2218 | 2243 | return true; |
| 2219 | 2244 | #endif |
| 2220 | 2245 | |
| 2246 | #ifdef __ARM_FEATURE_PAUTH | |
| 2247 | if (regNum == UNW_ARM_RA_AUTH_CODE) | |
| 2248 | return true; | |
| 2249 | #endif | |
| 2250 | ||
| 2221 | 2251 | return false; |
| 2222 | 2252 | } |
| 2223 | 2253 | |
| ... | ... | @@ -2244,6 +2274,11 @@ inline uint32_t Registers_arm::getRegister(int regNum) const { |
| 2244 | 2274 | } |
| 2245 | 2275 | #endif |
| 2246 | 2276 | |
| 2277 | #ifdef __ARM_FEATURE_PAUTH | |
| 2278 | if (regNum == UNW_ARM_RA_AUTH_CODE) | |
| 2279 | return _pseudo_registers.__pac; | |
| 2280 | #endif | |
| 2281 | ||
| 2247 | 2282 | _LIBUNWIND_ABORT("unsupported arm register"); |
| 2248 | 2283 | } |
| 2249 | 2284 | |
| ... | ... | @@ -2279,6 +2314,11 @@ inline void Registers_arm::setRegister(int regNum, uint32_t value) { |
| 2279 | 2314 | } |
| 2280 | 2315 | #endif |
| 2281 | 2316 | |
| 2317 | if (regNum == UNW_ARM_RA_AUTH_CODE) { | |
| 2318 | _pseudo_registers.__pac = value; | |
| 2319 | return; | |
| 2320 | } | |
| 2321 | ||
| 2282 | 2322 | _LIBUNWIND_ABORT("unsupported arm register"); |
| 2283 | 2323 | } |
| 2284 | 2324 | |
| ... | ... | @@ -3547,7 +3587,6 @@ inline const char *Registers_sparc::getRegisterName(int regNum) { |
| 3547 | 3587 | } |
| 3548 | 3588 | #endif // _LIBUNWIND_TARGET_SPARC |
| 3549 | 3589 | |
| 3550 | ||
| 3551 | 3590 | #if defined(_LIBUNWIND_TARGET_SPARC64) |
| 3552 | 3591 | /// Registers_sparc64 holds the register state of a thread in a 64-bit |
| 3553 | 3592 | /// sparc process. |
lib/libunwind/src/Unwind-EHABI.cpp+212-10| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------------- Unwind-EHABI.cpp -------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -187,9 +187,14 @@ static _Unwind_Reason_Code unwindOneFrame(_Unwind_State state, |
| 187 | 187 | if (result != _URC_CONTINUE_UNWIND) |
| 188 | 188 | return result; |
| 189 | 189 | |
| 190 | if (__unw_step(reinterpret_cast<unw_cursor_t *>(context)) != UNW_STEP_SUCCESS) | |
| 190 | switch (__unw_step(reinterpret_cast<unw_cursor_t *>(context))) { | |
| 191 | case UNW_STEP_SUCCESS: | |
| 192 | return _URC_CONTINUE_UNWIND; | |
| 193 | case UNW_STEP_END: | |
| 194 | return _URC_END_OF_STACK; | |
| 195 | default: | |
| 191 | 196 | return _URC_FAILURE; |
| 192 | return _URC_CONTINUE_UNWIND; | |
| 197 | } | |
| 193 | 198 | } |
| 194 | 199 | |
| 195 | 200 | // Generates mask discriminator for _Unwind_VRS_Pop, e.g. for _UVRSC_CORE / |
| ... | ... | @@ -256,6 +261,7 @@ _Unwind_VRS_Interpret(_Unwind_Context *context, const uint32_t *data, |
| 256 | 261 | size_t offset, size_t len) { |
| 257 | 262 | bool wrotePC = false; |
| 258 | 263 | bool finish = false; |
| 264 | bool hasReturnAddrAuthCode = false; | |
| 259 | 265 | while (offset < len && !finish) { |
| 260 | 266 | uint8_t byte = getByte(data, offset++); |
| 261 | 267 | if ((byte & 0x80) == 0) { |
| ... | ... | @@ -342,6 +348,10 @@ _Unwind_VRS_Interpret(_Unwind_Context *context, const uint32_t *data, |
| 342 | 348 | break; |
| 343 | 349 | } |
| 344 | 350 | case 0xb4: |
| 351 | hasReturnAddrAuthCode = true; | |
| 352 | _Unwind_VRS_Pop(context, _UVRSC_PSEUDO, | |
| 353 | 0 /* Return Address Auth Code */, _UVRSD_UINT32); | |
| 354 | break; | |
| 345 | 355 | case 0xb5: |
| 346 | 356 | case 0xb6: |
| 347 | 357 | case 0xb7: |
| ... | ... | @@ -417,6 +427,16 @@ _Unwind_VRS_Interpret(_Unwind_Context *context, const uint32_t *data, |
| 417 | 427 | if (!wrotePC) { |
| 418 | 428 | uint32_t lr; |
| 419 | 429 | _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_LR, _UVRSD_UINT32, &lr); |
| 430 | #ifdef __ARM_FEATURE_PAUTH | |
| 431 | if (hasReturnAddrAuthCode) { | |
| 432 | uint32_t sp; | |
| 433 | uint32_t pac; | |
| 434 | _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp); | |
| 435 | _Unwind_VRS_Get(context, _UVRSC_PSEUDO, UNW_ARM_RA_AUTH_CODE, | |
| 436 | _UVRSD_UINT32, &pac); | |
| 437 | __asm__ __volatile__("autg %0, %1, %2" : : "r"(pac), "r"(lr), "r"(sp) :); | |
| 438 | } | |
| 439 | #endif | |
| 420 | 440 | _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_IP, _UVRSD_UINT32, &lr); |
| 421 | 441 | } |
| 422 | 442 | return _URC_CONTINUE_UNWIND; |
| ... | ... | @@ -463,6 +483,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 463 | 483 | return _URC_FATAL_PHASE1_ERROR; |
| 464 | 484 | } |
| 465 | 485 | |
| 486 | #ifndef NDEBUG | |
| 466 | 487 | // When tracing, print state information. |
| 467 | 488 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 468 | 489 | char functionBuf[512]; |
| ... | ... | @@ -481,6 +502,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 481 | 502 | frameInfo.start_ip, functionName, |
| 482 | 503 | frameInfo.lsda, frameInfo.handler); |
| 483 | 504 | } |
| 505 | #endif | |
| 484 | 506 | |
| 485 | 507 | // If there is a personality routine, ask it if it will want to stop at |
| 486 | 508 | // this frame. |
| ... | ... | @@ -582,6 +604,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor |
| 582 | 604 | return _URC_FATAL_PHASE2_ERROR; |
| 583 | 605 | } |
| 584 | 606 | |
| 607 | #ifndef NDEBUG | |
| 585 | 608 | // When tracing, print state information. |
| 586 | 609 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 587 | 610 | char functionBuf[512]; |
| ... | ... | @@ -598,11 +621,12 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor |
| 598 | 621 | functionName, sp, frameInfo.lsda, |
| 599 | 622 | frameInfo.handler); |
| 600 | 623 | } |
| 624 | #endif | |
| 601 | 625 | |
| 602 | 626 | // If there is a personality routine, tell it we are unwinding. |
| 603 | 627 | if (frameInfo.handler != 0) { |
| 604 | 628 | _Unwind_Personality_Fn p = |
| 605 | (_Unwind_Personality_Fn)(long)(frameInfo.handler); | |
| 629 | (_Unwind_Personality_Fn)(intptr_t)(frameInfo.handler); | |
| 606 | 630 | struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor); |
| 607 | 631 | // EHABI #7.2 |
| 608 | 632 | exception_object->pr_cache.fnstart = frameInfo.start_ip; |
| ... | ... | @@ -670,6 +694,123 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor |
| 670 | 694 | return _URC_FATAL_PHASE2_ERROR; |
| 671 | 695 | } |
| 672 | 696 | |
| 697 | static _Unwind_Reason_Code | |
| 698 | unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, | |
| 699 | _Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, | |
| 700 | void *stop_parameter) { | |
| 701 | bool endOfStack = false; | |
| 702 | // See comment at the start of unwind_phase1 regarding VRS integrity. | |
| 703 | __unw_init_local(cursor, uc); | |
| 704 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_force(ex_ojb=%p)", | |
| 705 | static_cast<void *>(exception_object)); | |
| 706 | // Walk each frame until we reach where search phase said to stop | |
| 707 | while (!endOfStack) { | |
| 708 | // Update info about this frame. | |
| 709 | unw_proc_info_t frameInfo; | |
| 710 | if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) { | |
| 711 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): __unw_step " | |
| 712 | "failed => _URC_END_OF_STACK", | |
| 713 | (void *)exception_object); | |
| 714 | return _URC_FATAL_PHASE2_ERROR; | |
| 715 | } | |
| 716 | ||
| 717 | #ifndef NDEBUG | |
| 718 | // When tracing, print state information. | |
| 719 | if (_LIBUNWIND_TRACING_UNWINDING) { | |
| 720 | char functionBuf[512]; | |
| 721 | const char *functionName = functionBuf; | |
| 722 | unw_word_t offset; | |
| 723 | if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf), | |
| 724 | &offset) != UNW_ESUCCESS) || | |
| 725 | (frameInfo.start_ip + offset > frameInfo.end_ip)) | |
| 726 | functionName = ".anonymous."; | |
| 727 | _LIBUNWIND_TRACE_UNWINDING( | |
| 728 | "unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIxPTR | |
| 729 | ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR, | |
| 730 | (void *)exception_object, frameInfo.start_ip, functionName, | |
| 731 | frameInfo.lsda, frameInfo.handler); | |
| 732 | } | |
| 733 | #endif | |
| 734 | ||
| 735 | // Call stop function at each frame. | |
| 736 | _Unwind_Action action = | |
| 737 | (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE); | |
| 738 | _Unwind_Reason_Code stopResult = | |
| 739 | (*stop)(1, action, exception_object->exception_class, exception_object, | |
| 740 | (_Unwind_Context *)(cursor), stop_parameter); | |
| 741 | _LIBUNWIND_TRACE_UNWINDING( | |
| 742 | "unwind_phase2_forced(ex_ojb=%p): stop function returned %d", | |
| 743 | (void *)exception_object, stopResult); | |
| 744 | if (stopResult != _URC_NO_REASON) { | |
| 745 | _LIBUNWIND_TRACE_UNWINDING( | |
| 746 | "unwind_phase2_forced(ex_ojb=%p): stopped by stop function", | |
| 747 | (void *)exception_object); | |
| 748 | return _URC_FATAL_PHASE2_ERROR; | |
| 749 | } | |
| 750 | ||
| 751 | // If there is a personality routine, tell it we are unwinding. | |
| 752 | if (frameInfo.handler != 0) { | |
| 753 | _Unwind_Personality_Fn p = | |
| 754 | (_Unwind_Personality_Fn)(uintptr_t)(frameInfo.handler); | |
| 755 | struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor); | |
| 756 | // EHABI #7.2 | |
| 757 | exception_object->pr_cache.fnstart = frameInfo.start_ip; | |
| 758 | exception_object->pr_cache.ehtp = | |
| 759 | (_Unwind_EHT_Header *)frameInfo.unwind_info; | |
| 760 | exception_object->pr_cache.additional = frameInfo.flags; | |
| 761 | _Unwind_Reason_Code personalityResult = | |
| 762 | (*p)(_US_FORCE_UNWIND | _US_UNWIND_FRAME_STARTING, exception_object, | |
| 763 | context); | |
| 764 | switch (personalityResult) { | |
| 765 | case _URC_CONTINUE_UNWIND: | |
| 766 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " | |
| 767 | "personality returned " | |
| 768 | "_URC_CONTINUE_UNWIND", | |
| 769 | (void *)exception_object); | |
| 770 | // Destructors called, continue unwinding | |
| 771 | break; | |
| 772 | case _URC_INSTALL_CONTEXT: | |
| 773 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " | |
| 774 | "personality returned " | |
| 775 | "_URC_INSTALL_CONTEXT", | |
| 776 | (void *)exception_object); | |
| 777 | // We may get control back if landing pad calls _Unwind_Resume(). | |
| 778 | __unw_resume(cursor); | |
| 779 | break; | |
| 780 | case _URC_END_OF_STACK: | |
| 781 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " | |
| 782 | "personality returned " | |
| 783 | "_URC_END_OF_STACK", | |
| 784 | (void *)exception_object); | |
| 785 | // Personalty routine did the step and it can't step forward. | |
| 786 | endOfStack = true; | |
| 787 | break; | |
| 788 | default: | |
| 789 | // Personality routine returned an unknown result code. | |
| 790 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " | |
| 791 | "personality returned %d, " | |
| 792 | "_URC_FATAL_PHASE2_ERROR", | |
| 793 | (void *)exception_object, personalityResult); | |
| 794 | return _URC_FATAL_PHASE2_ERROR; | |
| 795 | } | |
| 796 | } | |
| 797 | } | |
| 798 | ||
| 799 | // Call stop function one last time and tell it we've reached the end | |
| 800 | // of the stack. | |
| 801 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop " | |
| 802 | "function with _UA_END_OF_STACK", | |
| 803 | (void *)exception_object); | |
| 804 | _Unwind_Action lastAction = | |
| 805 | (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK); | |
| 806 | (*stop)(1, lastAction, exception_object->exception_class, exception_object, | |
| 807 | (struct _Unwind_Context *)(cursor), stop_parameter); | |
| 808 | ||
| 809 | // Clean up phase did not resume at the frame that the search phase said it | |
| 810 | // would. | |
| 811 | return _URC_FATAL_PHASE2_ERROR; | |
| 812 | } | |
| 813 | ||
| 673 | 814 | /// Called by __cxa_throw. Only returns if there is a fatal error. |
| 674 | 815 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 675 | 816 | _Unwind_RaiseException(_Unwind_Exception *exception_object) { |
| ... | ... | @@ -717,10 +858,13 @@ _Unwind_Resume(_Unwind_Exception *exception_object) { |
| 717 | 858 | unw_cursor_t cursor; |
| 718 | 859 | __unw_getcontext(&uc); |
| 719 | 860 | |
| 720 | // _Unwind_RaiseException on EHABI will always set the reserved1 field to 0, | |
| 721 | // which is in the same position as private_1 below. | |
| 722 | // TODO(ajwong): Who wronte the above? Why is it true? | |
| 723 | unwind_phase2(&uc, &cursor, exception_object, true); | |
| 861 | if (exception_object->unwinder_cache.reserved1) | |
| 862 | unwind_phase2_forced( | |
| 863 | &uc, &cursor, exception_object, | |
| 864 | (_Unwind_Stop_Fn)exception_object->unwinder_cache.reserved1, | |
| 865 | (void *)exception_object->unwinder_cache.reserved3); | |
| 866 | else | |
| 867 | unwind_phase2(&uc, &cursor, exception_object, true); | |
| 724 | 868 | |
| 725 | 869 | // Clients assume _Unwind_Resume() does not return, so all we can do is abort. |
| 726 | 870 | _LIBUNWIND_ABORT("_Unwind_Resume() can't return"); |
| ... | ... | @@ -812,6 +956,15 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, |
| 812 | 956 | case _UVRSC_WMMXD: |
| 813 | 957 | break; |
| 814 | 958 | #endif |
| 959 | case _UVRSC_PSEUDO: | |
| 960 | // There's only one pseudo-register, PAC, with regno == 0. | |
| 961 | if (representation != _UVRSD_UINT32 || regno != 0) | |
| 962 | return _UVRSR_FAILED; | |
| 963 | return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_RA_AUTH_CODE), | |
| 964 | *(unw_word_t *)valuep) == UNW_ESUCCESS | |
| 965 | ? _UVRSR_OK | |
| 966 | : _UVRSR_FAILED; | |
| 967 | break; | |
| 815 | 968 | } |
| 816 | 969 | _LIBUNWIND_ABORT("unsupported register class"); |
| 817 | 970 | } |
| ... | ... | @@ -866,6 +1019,15 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context, |
| 866 | 1019 | case _UVRSC_WMMXD: |
| 867 | 1020 | break; |
| 868 | 1021 | #endif |
| 1022 | case _UVRSC_PSEUDO: | |
| 1023 | // There's only one pseudo-register, PAC, with regno == 0. | |
| 1024 | if (representation != _UVRSD_UINT32 || regno != 0) | |
| 1025 | return _UVRSR_FAILED; | |
| 1026 | return __unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_RA_AUTH_CODE), | |
| 1027 | (unw_word_t *)valuep) == UNW_ESUCCESS | |
| 1028 | ? _UVRSR_OK | |
| 1029 | : _UVRSR_FAILED; | |
| 1030 | break; | |
| 869 | 1031 | } |
| 870 | 1032 | _LIBUNWIND_ABORT("unsupported register class"); |
| 871 | 1033 | } |
| ... | ... | @@ -963,10 +1125,45 @@ _Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, |
| 963 | 1125 | return _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, |
| 964 | 1126 | &sp); |
| 965 | 1127 | } |
| 1128 | case _UVRSC_PSEUDO: { | |
| 1129 | if (representation != _UVRSD_UINT32 || discriminator != 0) | |
| 1130 | return _UVRSR_FAILED; | |
| 1131 | // Return Address Authentication code (PAC) - discriminator 0 | |
| 1132 | uint32_t *sp; | |
| 1133 | if (_Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, | |
| 1134 | &sp) != _UVRSR_OK) { | |
| 1135 | return _UVRSR_FAILED; | |
| 1136 | } | |
| 1137 | uint32_t pac = *sp++; | |
| 1138 | _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp); | |
| 1139 | return _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_RA_AUTH_CODE, | |
| 1140 | _UVRSD_UINT32, &pac); | |
| 1141 | } | |
| 966 | 1142 | } |
| 967 | 1143 | _LIBUNWIND_ABORT("unsupported register class"); |
| 968 | 1144 | } |
| 969 | 1145 | |
| 1146 | /// Not used by C++. | |
| 1147 | /// Unwinds stack, calling "stop" function at each frame. | |
| 1148 | /// Could be used to implement longjmp(). | |
| 1149 | _LIBUNWIND_EXPORT _Unwind_Reason_Code | |
| 1150 | _Unwind_ForcedUnwind(_Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, | |
| 1151 | void *stop_parameter) { | |
| 1152 | _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)", | |
| 1153 | (void *)exception_object, (void *)(uintptr_t)stop); | |
| 1154 | unw_context_t uc; | |
| 1155 | unw_cursor_t cursor; | |
| 1156 | __unw_getcontext(&uc); | |
| 1157 | ||
| 1158 | // Mark that this is a forced unwind, so _Unwind_Resume() can do | |
| 1159 | // the right thing. | |
| 1160 | exception_object->unwinder_cache.reserved1 = (uintptr_t)stop; | |
| 1161 | exception_object->unwinder_cache.reserved3 = (uintptr_t)stop_parameter; | |
| 1162 | ||
| 1163 | return unwind_phase2_forced(&uc, &cursor, exception_object, stop, | |
| 1164 | stop_parameter); | |
| 1165 | } | |
| 1166 | ||
| 970 | 1167 | /// Called by personality handler during phase 2 to find the start of the |
| 971 | 1168 | /// function. |
| 972 | 1169 | _LIBUNWIND_EXPORT uintptr_t |
| ... | ... | @@ -997,9 +1194,14 @@ extern "C" _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 997 | 1194 | __gnu_unwind_frame(_Unwind_Exception *exception_object, |
| 998 | 1195 | struct _Unwind_Context *context) { |
| 999 | 1196 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 1000 | if (__unw_step(cursor) != UNW_STEP_SUCCESS) | |
| 1197 | switch (__unw_step(cursor)) { | |
| 1198 | case UNW_STEP_SUCCESS: | |
| 1199 | return _URC_OK; | |
| 1200 | case UNW_STEP_END: | |
| 1201 | return _URC_END_OF_STACK; | |
| 1202 | default: | |
| 1001 | 1203 | return _URC_FAILURE; |
| 1002 | return _URC_OK; | |
| 1204 | } | |
| 1003 | 1205 | } |
| 1004 | 1206 | |
| 1005 | 1207 | #endif // defined(_LIBUNWIND_ARM_EHABI) |
lib/libunwind/src/Unwind-EHABI.h+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- Unwind-EHABI.hpp ---------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libunwind/src/Unwind-seh.cpp+5-5| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------------- Unwind-seh.cpp ---------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -28,8 +28,6 @@ |
| 28 | 28 | #include "libunwind_ext.h" |
| 29 | 29 | #include "UnwindCursor.hpp" |
| 30 | 30 | |
| 31 | #pragma clang diagnostic ignored "-Wdll-attribute-on-redeclaration" | |
| 32 | ||
| 33 | 31 | using namespace libunwind; |
| 34 | 32 | |
| 35 | 33 | #define STATUS_USER_DEFINED (1u << 29) |
| ... | ... | @@ -171,8 +169,8 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, |
| 171 | 169 | __unw_get_reg(&cursor, UNW_ARM_R1, &exc->private_[3]); |
| 172 | 170 | #elif defined(__aarch64__) |
| 173 | 171 | exc->private_[2] = disp->TargetPc; |
| 174 | __unw_get_reg(&cursor, UNW_ARM64_X0, &retval); | |
| 175 | __unw_get_reg(&cursor, UNW_ARM64_X1, &exc->private_[3]); | |
| 172 | __unw_get_reg(&cursor, UNW_AARCH64_X0, &retval); | |
| 173 | __unw_get_reg(&cursor, UNW_AARCH64_X1, &exc->private_[3]); | |
| 176 | 174 | #endif |
| 177 | 175 | __unw_get_reg(&cursor, UNW_REG_IP, &target); |
| 178 | 176 | ms_exc->ExceptionCode = STATUS_GCC_UNWIND; |
| ... | ... | @@ -246,6 +244,7 @@ unwind_phase2_forced(unw_context_t *uc, |
| 246 | 244 | return _URC_FATAL_PHASE2_ERROR; |
| 247 | 245 | } |
| 248 | 246 | |
| 247 | #ifndef NDEBUG | |
| 249 | 248 | // When tracing, print state information. |
| 250 | 249 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 251 | 250 | char functionBuf[512]; |
| ... | ... | @@ -261,6 +260,7 @@ unwind_phase2_forced(unw_context_t *uc, |
| 261 | 260 | (void *)exception_object, frameInfo.start_ip, functionName, |
| 262 | 261 | frameInfo.lsda, frameInfo.handler); |
| 263 | 262 | } |
| 263 | #endif | |
| 264 | 264 | |
| 265 | 265 | // Call stop function at each frame. |
| 266 | 266 | _Unwind_Action action = |
lib/libunwind/src/Unwind-sjlj.c+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------------- Unwind-sjlj.c ----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libunwind/src/UnwindCursor.hpp+61-43| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- UnwindCursor.hpp ---------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #ifndef __UNWINDCURSOR_HPP__ |
| 12 | 12 | #define __UNWINDCURSOR_HPP__ |
| 13 | 13 | |
| 14 | #include "cet_unwind.h" | |
| 14 | 15 | #include <stdint.h> |
| 15 | 16 | #include <stdio.h> |
| 16 | 17 | #include <stdlib.h> |
| ... | ... | @@ -449,6 +450,12 @@ public: |
| 449 | 450 | #ifdef __arm__ |
| 450 | 451 | virtual void saveVFPAsX() { _LIBUNWIND_ABORT("saveVFPAsX not implemented"); } |
| 451 | 452 | #endif |
| 453 | ||
| 454 | #if defined(_LIBUNWIND_USE_CET) | |
| 455 | virtual void *get_registers() { | |
| 456 | _LIBUNWIND_ABORT("get_registers not implemented"); | |
| 457 | } | |
| 458 | #endif | |
| 452 | 459 | }; |
| 453 | 460 | |
| 454 | 461 | #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32) |
| ... | ... | @@ -620,12 +627,12 @@ UnwindCursor<A, R>::UnwindCursor(unw_context_t *context, A &as) |
| 620 | 627 | _msContext.D[i - UNW_ARM_D0] = d.w; |
| 621 | 628 | } |
| 622 | 629 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 623 | for (int i = UNW_ARM64_X0; i <= UNW_ARM64_X30; ++i) | |
| 624 | _msContext.X[i - UNW_ARM64_X0] = r.getRegister(i); | |
| 630 | for (int i = UNW_AARCH64_X0; i <= UNW_ARM64_X30; ++i) | |
| 631 | _msContext.X[i - UNW_AARCH64_X0] = r.getRegister(i); | |
| 625 | 632 | _msContext.Sp = r.getRegister(UNW_REG_SP); |
| 626 | 633 | _msContext.Pc = r.getRegister(UNW_REG_IP); |
| 627 | for (int i = UNW_ARM64_D0; i <= UNW_ARM64_D31; ++i) | |
| 628 | _msContext.V[i - UNW_ARM64_D0].D[0] = r.getFloatRegister(i); | |
| 634 | for (int i = UNW_AARCH64_V0; i <= UNW_ARM64_D31; ++i) | |
| 635 | _msContext.V[i - UNW_AARCH64_V0].D[0] = r.getFloatRegister(i); | |
| 629 | 636 | #endif |
| 630 | 637 | } |
| 631 | 638 | |
| ... | ... | @@ -648,9 +655,11 @@ bool UnwindCursor<A, R>::validReg(int regNum) { |
| 648 | 655 | #if defined(_LIBUNWIND_TARGET_X86_64) |
| 649 | 656 | if (regNum >= UNW_X86_64_RAX && regNum <= UNW_X86_64_R15) return true; |
| 650 | 657 | #elif defined(_LIBUNWIND_TARGET_ARM) |
| 651 | if (regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15) return true; | |
| 658 | if ((regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15) || | |
| 659 | regNum == UNW_ARM_RA_AUTH_CODE) | |
| 660 | return true; | |
| 652 | 661 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 653 | if (regNum >= UNW_ARM64_X0 && regNum <= UNW_ARM64_X30) return true; | |
| 662 | if (regNum >= UNW_AARCH64_X0 && regNum <= UNW_ARM64_X30) return true; | |
| 654 | 663 | #endif |
| 655 | 664 | return false; |
| 656 | 665 | } |
| ... | ... | @@ -699,7 +708,7 @@ unw_word_t UnwindCursor<A, R>::getReg(int regNum) { |
| 699 | 708 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 700 | 709 | case UNW_REG_SP: return _msContext.Sp; |
| 701 | 710 | case UNW_REG_IP: return _msContext.Pc; |
| 702 | default: return _msContext.X[regNum - UNW_ARM64_X0]; | |
| 711 | default: return _msContext.X[regNum - UNW_AARCH64_X0]; | |
| 703 | 712 | #endif |
| 704 | 713 | } |
| 705 | 714 | _LIBUNWIND_ABORT("unsupported register"); |
| ... | ... | @@ -749,37 +758,37 @@ void UnwindCursor<A, R>::setReg(int regNum, unw_word_t value) { |
| 749 | 758 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 750 | 759 | case UNW_REG_SP: _msContext.Sp = value; break; |
| 751 | 760 | case UNW_REG_IP: _msContext.Pc = value; break; |
| 752 | case UNW_ARM64_X0: | |
| 753 | case UNW_ARM64_X1: | |
| 754 | case UNW_ARM64_X2: | |
| 755 | case UNW_ARM64_X3: | |
| 756 | case UNW_ARM64_X4: | |
| 757 | case UNW_ARM64_X5: | |
| 758 | case UNW_ARM64_X6: | |
| 759 | case UNW_ARM64_X7: | |
| 760 | case UNW_ARM64_X8: | |
| 761 | case UNW_ARM64_X9: | |
| 762 | case UNW_ARM64_X10: | |
| 763 | case UNW_ARM64_X11: | |
| 764 | case UNW_ARM64_X12: | |
| 765 | case UNW_ARM64_X13: | |
| 766 | case UNW_ARM64_X14: | |
| 767 | case UNW_ARM64_X15: | |
| 768 | case UNW_ARM64_X16: | |
| 769 | case UNW_ARM64_X17: | |
| 770 | case UNW_ARM64_X18: | |
| 771 | case UNW_ARM64_X19: | |
| 772 | case UNW_ARM64_X20: | |
| 773 | case UNW_ARM64_X21: | |
| 774 | case UNW_ARM64_X22: | |
| 775 | case UNW_ARM64_X23: | |
| 776 | case UNW_ARM64_X24: | |
| 777 | case UNW_ARM64_X25: | |
| 778 | case UNW_ARM64_X26: | |
| 779 | case UNW_ARM64_X27: | |
| 780 | case UNW_ARM64_X28: | |
| 781 | case UNW_ARM64_FP: | |
| 782 | case UNW_ARM64_LR: _msContext.X[regNum - UNW_ARM64_X0] = value; break; | |
| 761 | case UNW_AARCH64_X0: | |
| 762 | case UNW_AARCH64_X1: | |
| 763 | case UNW_AARCH64_X2: | |
| 764 | case UNW_AARCH64_X3: | |
| 765 | case UNW_AARCH64_X4: | |
| 766 | case UNW_AARCH64_X5: | |
| 767 | case UNW_AARCH64_X6: | |
| 768 | case UNW_AARCH64_X7: | |
| 769 | case UNW_AARCH64_X8: | |
| 770 | case UNW_AARCH64_X9: | |
| 771 | case UNW_AARCH64_X10: | |
| 772 | case UNW_AARCH64_X11: | |
| 773 | case UNW_AARCH64_X12: | |
| 774 | case UNW_AARCH64_X13: | |
| 775 | case UNW_AARCH64_X14: | |
| 776 | case UNW_AARCH64_X15: | |
| 777 | case UNW_AARCH64_X16: | |
| 778 | case UNW_AARCH64_X17: | |
| 779 | case UNW_AARCH64_X18: | |
| 780 | case UNW_AARCH64_X19: | |
| 781 | case UNW_AARCH64_X20: | |
| 782 | case UNW_AARCH64_X21: | |
| 783 | case UNW_AARCH64_X22: | |
| 784 | case UNW_AARCH64_X23: | |
| 785 | case UNW_AARCH64_X24: | |
| 786 | case UNW_AARCH64_X25: | |
| 787 | case UNW_AARCH64_X26: | |
| 788 | case UNW_AARCH64_X27: | |
| 789 | case UNW_AARCH64_X28: | |
| 790 | case UNW_AARCH64_FP: | |
| 791 | case UNW_AARCH64_LR: _msContext.X[regNum - UNW_ARM64_X0] = value; break; | |
| 783 | 792 | #endif |
| 784 | 793 | default: |
| 785 | 794 | _LIBUNWIND_ABORT("unsupported register"); |
| ... | ... | @@ -792,7 +801,7 @@ bool UnwindCursor<A, R>::validFloatReg(int regNum) { |
| 792 | 801 | if (regNum >= UNW_ARM_S0 && regNum <= UNW_ARM_S31) return true; |
| 793 | 802 | if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) return true; |
| 794 | 803 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 795 | if (regNum >= UNW_ARM64_D0 && regNum <= UNW_ARM64_D31) return true; | |
| 804 | if (regNum >= UNW_AARCH64_V0 && regNum <= UNW_ARM64_D31) return true; | |
| 796 | 805 | #else |
| 797 | 806 | (void)regNum; |
| 798 | 807 | #endif |
| ... | ... | @@ -820,7 +829,7 @@ unw_fpreg_t UnwindCursor<A, R>::getFloatReg(int regNum) { |
| 820 | 829 | } |
| 821 | 830 | _LIBUNWIND_ABORT("unsupported float register"); |
| 822 | 831 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 823 | return _msContext.V[regNum - UNW_ARM64_D0].D[0]; | |
| 832 | return _msContext.V[regNum - UNW_AARCH64_V0].D[0]; | |
| 824 | 833 | #else |
| 825 | 834 | (void)regNum; |
| 826 | 835 | _LIBUNWIND_ABORT("float registers unimplemented"); |
| ... | ... | @@ -848,7 +857,7 @@ void UnwindCursor<A, R>::setFloatReg(int regNum, unw_fpreg_t value) { |
| 848 | 857 | } |
| 849 | 858 | _LIBUNWIND_ABORT("unsupported float register"); |
| 850 | 859 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 851 | _msContext.V[regNum - UNW_ARM64_D0].D[0] = value; | |
| 860 | _msContext.V[regNum - UNW_AARCH64_V0].D[0] = value; | |
| 852 | 861 | #else |
| 853 | 862 | (void)regNum; |
| 854 | 863 | (void)value; |
| ... | ... | @@ -901,6 +910,9 @@ public: |
| 901 | 910 | virtual void saveVFPAsX(); |
| 902 | 911 | #endif |
| 903 | 912 | |
| 913 | #if defined(_LIBUNWIND_USE_CET) | |
| 914 | virtual void *get_registers() { return &_registers; } | |
| 915 | #endif | |
| 904 | 916 | // libunwind does not and should not depend on C++ library which means that we |
| 905 | 917 | // need our own defition of inline placement new. |
| 906 | 918 | static void *operator new(size_t, UnwindCursor<A, R> *p) { return p; } |
| ... | ... | @@ -2077,7 +2089,7 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_arm64 &) { |
| 2077 | 2089 | for (int i = 0; i <= 30; ++i) { |
| 2078 | 2090 | uint64_t value = _addressSpace.get64(sigctx + kOffsetGprs + |
| 2079 | 2091 | static_cast<pint_t>(i * 8)); |
| 2080 | _registers.setRegister(UNW_ARM64_X0 + i, value); | |
| 2092 | _registers.setRegister(UNW_AARCH64_X0 + i, value); | |
| 2081 | 2093 | } |
| 2082 | 2094 | _registers.setSP(_addressSpace.get64(sigctx + kOffsetSp)); |
| 2083 | 2095 | _registers.setIP(_addressSpace.get64(sigctx + kOffsetPc)); |
| ... | ... | @@ -2141,6 +2153,12 @@ bool UnwindCursor<A, R>::getFunctionName(char *buf, size_t bufLen, |
| 2141 | 2153 | buf, bufLen, offset); |
| 2142 | 2154 | } |
| 2143 | 2155 | |
| 2156 | #if defined(_LIBUNWIND_USE_CET) | |
| 2157 | extern "C" void *__libunwind_cet_get_registers(unw_cursor_t *cursor) { | |
| 2158 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; | |
| 2159 | return co->get_registers(); | |
| 2160 | } | |
| 2161 | #endif | |
| 2144 | 2162 | } // namespace libunwind |
| 2145 | 2163 | |
| 2146 | 2164 | #endif // __UNWINDCURSOR_HPP__ |
lib/libunwind/src/UnwindLevel1-gcc-ext.c+11-22| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------- UnwindLevel1-gcc-ext.c -------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -22,36 +22,27 @@ |
| 22 | 22 | #include "Unwind-EHABI.h" |
| 23 | 23 | #include "unwind.h" |
| 24 | 24 | |
| 25 | #pragma clang diagnostic ignored "-Wdll-attribute-on-redeclaration" | |
| 26 | ||
| 27 | 25 | #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS) |
| 28 | 26 | |
| 29 | 27 | #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) |
| 30 | #define private_1 private_[0] | |
| 28 | #define PRIVATE_1 private_[0] | |
| 29 | #elif defined(_LIBUNWIND_ARM_EHABI) | |
| 30 | #define PRIVATE_1 unwinder_cache.reserved1 | |
| 31 | #else | |
| 32 | #define PRIVATE_1 private_1 | |
| 31 | 33 | #endif |
| 32 | 34 | |
| 33 | 35 | /// Called by __cxa_rethrow(). |
| 34 | 36 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 35 | 37 | _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) { |
| 36 | #if defined(_LIBUNWIND_ARM_EHABI) | |
| 37 | _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%ld", | |
| 38 | (void *)exception_object, | |
| 39 | (long)exception_object->unwinder_cache.reserved1); | |
| 40 | #else | |
| 41 | _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR, | |
| 42 | (void *)exception_object, | |
| 43 | (intptr_t)exception_object->private_1); | |
| 44 | #endif | |
| 38 | _LIBUNWIND_TRACE_API( | |
| 39 | "_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR, | |
| 40 | (void *)exception_object, (intptr_t)exception_object->PRIVATE_1); | |
| 45 | 41 | |
| 46 | #if defined(_LIBUNWIND_ARM_EHABI) | |
| 47 | // _Unwind_RaiseException on EHABI will always set the reserved1 field to 0, | |
| 48 | // which is in the same position as private_1 below. | |
| 49 | return _Unwind_RaiseException(exception_object); | |
| 50 | #else | |
| 51 | 42 | // If this is non-forced and a stopping place was found, then this is a |
| 52 | 43 | // re-throw. |
| 53 | 44 | // Call _Unwind_RaiseException() as if this was a new exception |
| 54 | if (exception_object->private_1 == 0) { | |
| 45 | if (exception_object->PRIVATE_1 == 0) { | |
| 55 | 46 | return _Unwind_RaiseException(exception_object); |
| 56 | 47 | // Will return if there is no catch clause, so that __cxa_rethrow can call |
| 57 | 48 | // std::terminate(). |
| ... | ... | @@ -62,10 +53,8 @@ _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) { |
| 62 | 53 | _Unwind_Resume(exception_object); |
| 63 | 54 | _LIBUNWIND_ABORT("_Unwind_Resume_or_Rethrow() called _Unwind_RaiseException()" |
| 64 | 55 | " which unexpectedly returned"); |
| 65 | #endif | |
| 66 | 56 | } |
| 67 | 57 | |
| 68 | ||
| 69 | 58 | /// Called by personality handler during phase 2 to get base address for data |
| 70 | 59 | /// relative encodings. |
| 71 | 60 | _LIBUNWIND_EXPORT uintptr_t |
| ... | ... | @@ -120,7 +109,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { |
| 120 | 109 | // Create a mock exception object for force unwinding. |
| 121 | 110 | _Unwind_Exception ex; |
| 122 | 111 | memset(&ex, '\0', sizeof(ex)); |
| 123 | ex.exception_class = 0x434C4E47554E5700; // CLNGUNW\0 | |
| 112 | strcpy((char *)&ex.exception_class, "CLNGUNW"); | |
| 124 | 113 | #endif |
| 125 | 114 | |
| 126 | 115 | // walk each frame |
lib/libunwind/src/UnwindLevel1.c+52-6| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- UnwindLevel1.c -----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -25,17 +25,48 @@ |
| 25 | 25 | #include <stdio.h> |
| 26 | 26 | #include <string.h> |
| 27 | 27 | |
| 28 | #include "cet_unwind.h" | |
| 28 | 29 | #include "config.h" |
| 29 | 30 | #include "libunwind.h" |
| 30 | 31 | #include "libunwind_ext.h" |
| 31 | 32 | #include "unwind.h" |
| 32 | 33 | |
| 33 | #pragma clang diagnostic ignored "-Wdll-attribute-on-redeclaration" | |
| 34 | ||
| 35 | 34 | #if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__) |
| 36 | 35 | |
| 37 | 36 | #ifndef _LIBUNWIND_SUPPORT_SEH_UNWIND |
| 38 | 37 | |
| 38 | // When CET is enabled, each "call" instruction will push return address to | |
| 39 | // CET shadow stack, each "ret" instruction will pop current CET shadow stack | |
| 40 | // top and compare it with target address which program will return. | |
| 41 | // In exception handing, some stack frames will be skipped before jumping to | |
| 42 | // landing pad and we must adjust CET shadow stack accordingly. | |
| 43 | // _LIBUNWIND_POP_CET_SSP is used to adjust CET shadow stack pointer and we | |
| 44 | // directly jump to __libunwind_Registerts_x86/x86_64_jumpto instead of using | |
| 45 | // a regular function call to avoid pushing to CET shadow stack again. | |
| 46 | #if !defined(_LIBUNWIND_USE_CET) | |
| 47 | #define __unw_phase2_resume(cursor, fn) __unw_resume((cursor)) | |
| 48 | #elif defined(_LIBUNWIND_TARGET_I386) | |
| 49 | #define __unw_phase2_resume(cursor, fn) \ | |
| 50 | do { \ | |
| 51 | _LIBUNWIND_POP_CET_SSP((fn)); \ | |
| 52 | void *cetRegContext = __libunwind_cet_get_registers((cursor)); \ | |
| 53 | void *cetJumpAddress = __libunwind_cet_get_jump_target(); \ | |
| 54 | __asm__ volatile("push %%edi\n\t" \ | |
| 55 | "sub $4, %%esp\n\t" \ | |
| 56 | "jmp *%%edx\n\t" :: "D"(cetRegContext), \ | |
| 57 | "d"(cetJumpAddress)); \ | |
| 58 | } while (0) | |
| 59 | #elif defined(_LIBUNWIND_TARGET_X86_64) | |
| 60 | #define __unw_phase2_resume(cursor, fn) \ | |
| 61 | do { \ | |
| 62 | _LIBUNWIND_POP_CET_SSP((fn)); \ | |
| 63 | void *cetRegContext = __libunwind_cet_get_registers((cursor)); \ | |
| 64 | void *cetJumpAddress = __libunwind_cet_get_jump_target(); \ | |
| 65 | __asm__ volatile("jmpq *%%rdx\n\t" :: "D"(cetRegContext), \ | |
| 66 | "d"(cetJumpAddress)); \ | |
| 67 | } while (0) | |
| 68 | #endif | |
| 69 | ||
| 39 | 70 | static _Unwind_Reason_Code |
| 40 | 71 | unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) { |
| 41 | 72 | __unw_init_local(cursor, uc); |
| ... | ... | @@ -70,6 +101,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 70 | 101 | return _URC_FATAL_PHASE1_ERROR; |
| 71 | 102 | } |
| 72 | 103 | |
| 104 | #ifndef NDEBUG | |
| 73 | 105 | // When tracing, print state information. |
| 74 | 106 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 75 | 107 | char functionBuf[512]; |
| ... | ... | @@ -87,6 +119,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 87 | 119 | (void *)exception_object, pc, frameInfo.start_ip, functionName, |
| 88 | 120 | frameInfo.lsda, frameInfo.handler); |
| 89 | 121 | } |
| 122 | #endif | |
| 90 | 123 | |
| 91 | 124 | // If there is a personality routine, ask it if it will want to stop at |
| 92 | 125 | // this frame. |
| ... | ... | @@ -137,6 +170,9 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 137 | 170 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)", |
| 138 | 171 | (void *)exception_object); |
| 139 | 172 | |
| 173 | // uc is initialized by __unw_getcontext in the parent frame. The first stack | |
| 174 | // frame walked is unwind_phase2. | |
| 175 | unsigned framesWalked = 1; | |
| 140 | 176 | // Walk each frame until we reach where search phase said to stop. |
| 141 | 177 | while (true) { |
| 142 | 178 | |
| ... | ... | @@ -169,6 +205,7 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 169 | 205 | return _URC_FATAL_PHASE2_ERROR; |
| 170 | 206 | } |
| 171 | 207 | |
| 208 | #ifndef NDEBUG | |
| 172 | 209 | // When tracing, print state information. |
| 173 | 210 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 174 | 211 | char functionBuf[512]; |
| ... | ... | @@ -185,7 +222,9 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 185 | 222 | functionName, sp, frameInfo.lsda, |
| 186 | 223 | frameInfo.handler); |
| 187 | 224 | } |
| 225 | #endif | |
| 188 | 226 | |
| 227 | ++framesWalked; | |
| 189 | 228 | // If there is a personality routine, tell it we are unwinding. |
| 190 | 229 | if (frameInfo.handler != 0) { |
| 191 | 230 | _Unwind_Personality_Fn p = |
| ... | ... | @@ -225,8 +264,9 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 225 | 264 | ", sp=0x%" PRIxPTR, |
| 226 | 265 | (void *)exception_object, pc, sp); |
| 227 | 266 | } |
| 228 | __unw_resume(cursor); | |
| 229 | // __unw_resume() only returns if there was an error. | |
| 267 | ||
| 268 | __unw_phase2_resume(cursor, framesWalked); | |
| 269 | // __unw_phase2_resume() only returns if there was an error. | |
| 230 | 270 | return _URC_FATAL_PHASE2_ERROR; |
| 231 | 271 | default: |
| 232 | 272 | // Personality routine returned an unknown result code. |
| ... | ... | @@ -248,6 +288,9 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
| 248 | 288 | _Unwind_Stop_Fn stop, void *stop_parameter) { |
| 249 | 289 | __unw_init_local(cursor, uc); |
| 250 | 290 | |
| 291 | // uc is initialized by __unw_getcontext in the parent frame. The first stack | |
| 292 | // frame walked is unwind_phase2_forced. | |
| 293 | unsigned framesWalked = 1; | |
| 251 | 294 | // Walk each frame until we reach where search phase said to stop |
| 252 | 295 | while (__unw_step(cursor) > 0) { |
| 253 | 296 | |
| ... | ... | @@ -260,6 +303,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
| 260 | 303 | return _URC_FATAL_PHASE2_ERROR; |
| 261 | 304 | } |
| 262 | 305 | |
| 306 | #ifndef NDEBUG | |
| 263 | 307 | // When tracing, print state information. |
| 264 | 308 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 265 | 309 | char functionBuf[512]; |
| ... | ... | @@ -275,6 +319,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
| 275 | 319 | (void *)exception_object, frameInfo.start_ip, functionName, |
| 276 | 320 | frameInfo.lsda, frameInfo.handler); |
| 277 | 321 | } |
| 322 | #endif | |
| 278 | 323 | |
| 279 | 324 | // Call stop function at each frame. |
| 280 | 325 | _Unwind_Action action = |
| ... | ... | @@ -292,6 +337,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
| 292 | 337 | return _URC_FATAL_PHASE2_ERROR; |
| 293 | 338 | } |
| 294 | 339 | |
| 340 | ++framesWalked; | |
| 295 | 341 | // If there is a personality routine, tell it we are unwinding. |
| 296 | 342 | if (frameInfo.handler != 0) { |
| 297 | 343 | _Unwind_Personality_Fn p = |
| ... | ... | @@ -316,7 +362,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
| 316 | 362 | "_URC_INSTALL_CONTEXT", |
| 317 | 363 | (void *)exception_object); |
| 318 | 364 | // We may get control back if landing pad calls _Unwind_Resume(). |
| 319 | __unw_resume(cursor); | |
| 365 | __unw_phase2_resume(cursor, framesWalked); | |
| 320 | 366 | break; |
| 321 | 367 | default: |
| 322 | 368 | // Personality routine returned an unknown result code. |
lib/libunwind/src/UnwindRegistersRestore.S+18-6| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------- UnwindRegistersRestore.S ------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -25,6 +25,8 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_jumpto) |
| 25 | 25 | # + return address + |
| 26 | 26 | # +-----------------------+ <-- SP |
| 27 | 27 | # + + |
| 28 | ||
| 29 | _LIBUNWIND_CET_ENDBR | |
| 28 | 30 | movl 4(%esp), %eax |
| 29 | 31 | # set up eax and ret on new stack location |
| 30 | 32 | movl 28(%eax), %edx # edx holds new stack pointer |
| ... | ... | @@ -46,7 +48,8 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_jumpto) |
| 46 | 48 | # skip ss |
| 47 | 49 | # skip eflags |
| 48 | 50 | pop %eax # eax was already pushed on new stack |
| 49 | ret # eip was already pushed on new stack | |
| 51 | pop %ecx | |
| 52 | jmp *%ecx | |
| 50 | 53 | # skip cs |
| 51 | 54 | # skip ds |
| 52 | 55 | # skip es |
| ... | ... | @@ -70,6 +73,7 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_64_jumpto) |
| 70 | 73 | # On entry, thread_state pointer is in rdi |
| 71 | 74 | #endif |
| 72 | 75 | |
| 76 | _LIBUNWIND_CET_ENDBR | |
| 73 | 77 | movq 56(%rdi), %rax # rax holds new stack pointer |
| 74 | 78 | subq $16, %rax |
| 75 | 79 | movq %rax, 56(%rdi) |
| ... | ... | @@ -119,7 +123,8 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_64_jumpto) |
| 119 | 123 | #endif |
| 120 | 124 | movq 56(%rdi), %rsp # cut back rsp to new location |
| 121 | 125 | pop %rdi # rdi was saved here earlier |
| 122 | ret # rip was saved here | |
| 126 | pop %rcx | |
| 127 | jmpq *%rcx | |
| 123 | 128 | |
| 124 | 129 | |
| 125 | 130 | #elif defined(__powerpc64__) |
| ... | ... | @@ -389,7 +394,7 @@ Lnovec: |
| 389 | 394 | PPC64_LR(3) |
| 390 | 395 | bctr |
| 391 | 396 | |
| 392 | #elif defined(__ppc__) | |
| 397 | #elif defined(__powerpc__) | |
| 393 | 398 | |
| 394 | 399 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv) |
| 395 | 400 | // |
| ... | ... | @@ -655,7 +660,13 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv) |
| 655 | 660 | ldr sp, [lr, #52] |
| 656 | 661 | ldr lr, [lr, #60] @ restore pc into lr |
| 657 | 662 | #endif |
| 663 | #if defined(__ARM_FEATURE_BTI_DEFAULT) && !defined(__ARM_ARCH_ISA_ARM) | |
| 664 | // 'bx' is not BTI setting when used with lr, therefore r12 is used instead | |
| 665 | mov r12, lr | |
| 666 | JMP(r12) | |
| 667 | #else | |
| 658 | 668 | JMP(lr) |
| 669 | #endif | |
| 659 | 670 | |
| 660 | 671 | @ |
| 661 | 672 | @ static void libunwind::Registers_arm::restoreVFPWithFLDMD(unw_fpreg_t* values) |
| ... | ... | @@ -800,11 +811,12 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv) |
| 800 | 811 | l.lwz r30,120(r3) |
| 801 | 812 | l.lwz r31,124(r3) |
| 802 | 813 | |
| 814 | # load new pc into ra | |
| 815 | l.lwz r9, 128(r3) | |
| 816 | ||
| 803 | 817 | # at last, restore r3 |
| 804 | 818 | l.lwz r3, 12(r3) |
| 805 | 819 | |
| 806 | # load new pc into ra | |
| 807 | l.lwz r9, 128(r3) | |
| 808 | 820 | # jump to pc |
| 809 | 821 | l.jr r9 |
| 810 | 822 | l.nop |
lib/libunwind/src/UnwindRegistersSave.S+8-3| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ UnwindRegistersSave.S -----------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -27,6 +27,8 @@ |
| 27 | 27 | # + + |
| 28 | 28 | # |
| 29 | 29 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) |
| 30 | ||
| 31 | _LIBUNWIND_CET_ENDBR | |
| 30 | 32 | push %eax |
| 31 | 33 | movl 8(%esp), %eax |
| 32 | 34 | movl %ebx, 4(%eax) |
| ... | ... | @@ -70,6 +72,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) |
| 70 | 72 | #define TMP %rsi |
| 71 | 73 | #endif |
| 72 | 74 | |
| 75 | _LIBUNWIND_CET_ENDBR | |
| 73 | 76 | movq %rax, (PTR) |
| 74 | 77 | movq %rbx, 8(PTR) |
| 75 | 78 | movq %rcx, 16(PTR) |
| ... | ... | @@ -556,7 +559,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) |
| 556 | 559 | blr |
| 557 | 560 | |
| 558 | 561 | |
| 559 | #elif defined(__ppc__) | |
| 562 | #elif defined(__powerpc__) | |
| 560 | 563 | |
| 561 | 564 | // |
| 562 | 565 | // extern int unw_getcontext(unw_context_t* thread_state) |
| ... | ... | @@ -600,9 +603,11 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) |
| 600 | 603 | stw 30,128(3) |
| 601 | 604 | stw 31,132(3) |
| 602 | 605 | |
| 606 | #if defined(__ALTIVEC__) | |
| 603 | 607 | // save VRSave register |
| 604 | 608 | mfspr 0, 256 |
| 605 | 609 | stw 0, 156(3) |
| 610 | #endif | |
| 606 | 611 | // save CR registers |
| 607 | 612 | mfcr 0 |
| 608 | 613 | stw 0, 136(3) |
| ... | ... | @@ -766,7 +771,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) |
| 766 | 771 | @ |
| 767 | 772 | @ On entry: |
| 768 | 773 | @ thread_state pointer is in r0 |
| 769 | @ | |
| 774 | @ | |
| 770 | 775 | @ Per EHABI #4.7 this only saves the core integer registers. |
| 771 | 776 | @ EHABI #7.4.5 notes that in general all VRS registers should be restored |
| 772 | 777 | @ however this is very hard to do for VFP registers because it is unknown |
lib/libunwind/src/Unwind_AppleExtras.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------- Unwind_AppleExtras.cpp -------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libunwind/src/assembly.h+20-2| ... | ... | @@ -15,6 +15,13 @@ |
| 15 | 15 | #ifndef UNWIND_ASSEMBLY_H |
| 16 | 16 | #define UNWIND_ASSEMBLY_H |
| 17 | 17 | |
| 18 | #if defined(__linux__) && defined(__CET__) | |
| 19 | #include <cet.h> | |
| 20 | #define _LIBUNWIND_CET_ENDBR _CET_ENDBR | |
| 21 | #else | |
| 22 | #define _LIBUNWIND_CET_ENDBR | |
| 23 | #endif | |
| 24 | ||
| 18 | 25 | #if defined(__powerpc64__) |
| 19 | 26 | #define SEPARATOR ; |
| 20 | 27 | #define PPC64_OFFS_SRR0 0 |
| ... | ... | @@ -74,7 +81,7 @@ |
| 74 | 81 | #define PPC64_OPD2 |
| 75 | 82 | #endif |
| 76 | 83 | |
| 77 | #if defined(__ARM_FEATURE_BTI_DEFAULT) | |
| 84 | #if defined(__aarch64__) && defined(__ARM_FEATURE_BTI_DEFAULT) | |
| 78 | 85 | .pushsection ".note.gnu.property", "a" SEPARATOR \ |
| 79 | 86 | .balign 8 SEPARATOR \ |
| 80 | 87 | .long 4 SEPARATOR \ |
| ... | ... | @@ -92,6 +99,17 @@ |
| 92 | 99 | #define AARCH64_BTI |
| 93 | 100 | #endif |
| 94 | 101 | |
| 102 | #if !defined(__aarch64__) | |
| 103 | #ifdef __ARM_FEATURE_PAC_DEFAULT | |
| 104 | .eabi_attribute Tag_PAC_extension, 2 | |
| 105 | .eabi_attribute Tag_PACRET_use, 1 | |
| 106 | #endif | |
| 107 | #ifdef __ARM_FEATURE_BTI_DEFAULT | |
| 108 | .eabi_attribute Tag_BTI_extension, 1 | |
| 109 | .eabi_attribute Tag_BTI_use, 1 | |
| 110 | #endif | |
| 111 | #endif | |
| 112 | ||
| 95 | 113 | #define GLUE2(a, b) a ## b |
| 96 | 114 | #define GLUE(a, b) GLUE2(a, b) |
| 97 | 115 | #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) |
| ... | ... | @@ -216,7 +234,7 @@ |
| 216 | 234 | #endif |
| 217 | 235 | #endif /* __arm__ */ |
| 218 | 236 | |
| 219 | #if defined(__ppc__) || defined(__powerpc64__) | |
| 237 | #if defined(__powerpc__) | |
| 220 | 238 | #define PPC_LEFT_SHIFT(index) << (index) |
| 221 | 239 | #endif |
| 222 | 240 |
lib/libunwind/src/cet_unwind.h created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef LIBUNWIND_CET_UNWIND_H | |
| 11 | #define LIBUNWIND_CET_UNWIND_H | |
| 12 | ||
| 13 | #include "libunwind.h" | |
| 14 | ||
| 15 | // Currently, CET is implemented on Linux x86 platforms. | |
| 16 | #if defined(_LIBUNWIND_TARGET_LINUX) && defined(__CET__) && defined(__SHSTK__) | |
| 17 | #define _LIBUNWIND_USE_CET 1 | |
| 18 | #endif | |
| 19 | ||
| 20 | #if defined(_LIBUNWIND_USE_CET) | |
| 21 | #include <cet.h> | |
| 22 | #include <immintrin.h> | |
| 23 | ||
| 24 | #define _LIBUNWIND_POP_CET_SSP(x) \ | |
| 25 | do { \ | |
| 26 | unsigned long ssp = _get_ssp(); \ | |
| 27 | if (ssp != 0) { \ | |
| 28 | unsigned int tmp = (x); \ | |
| 29 | while (tmp > 255) { \ | |
| 30 | _inc_ssp(255); \ | |
| 31 | tmp -= 255; \ | |
| 32 | } \ | |
| 33 | _inc_ssp(tmp); \ | |
| 34 | } \ | |
| 35 | } while (0) | |
| 36 | #endif | |
| 37 | ||
| 38 | extern void *__libunwind_cet_get_registers(unw_cursor_t *); | |
| 39 | extern void *__libunwind_cet_get_jump_target(); | |
| 40 | ||
| 41 | #endif |
lib/libunwind/src/config.h+2-2| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===----------------------------- config.h -------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -105,7 +105,7 @@ |
| 105 | 105 | #define _LIBUNWIND_BUILD_SJLJ_APIS |
| 106 | 106 | #endif |
| 107 | 107 | |
| 108 | #if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) | |
| 108 | #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) | |
| 109 | 109 | #define _LIBUNWIND_SUPPORT_FRAME_APIS |
| 110 | 110 | #endif |
| 111 | 111 |
lib/libunwind/src/dwarf2.h+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------------- dwarf2.h -----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libunwind/src/libunwind.cpp+33-6| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------------- libunwind.cpp ----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | |
| 12 | 12 | #include <libunwind.h> |
| 13 | 13 | |
| 14 | #include "libunwind_ext.h" | |
| 15 | 14 | #include "config.h" |
| 15 | #include "libunwind_ext.h" | |
| 16 | 16 | |
| 17 | 17 | #include <stdlib.h> |
| 18 | 18 | |
| ... | ... | @@ -30,8 +30,6 @@ |
| 30 | 30 | #include "AddressSpace.hpp" |
| 31 | 31 | #include "UnwindCursor.hpp" |
| 32 | 32 | |
| 33 | #pragma clang diagnostic ignored "-Wdll-attribute-on-redeclaration" | |
| 34 | ||
| 35 | 33 | using namespace libunwind; |
| 36 | 34 | |
| 37 | 35 | /// internal object to represent this processes address space |
| ... | ... | @@ -53,7 +51,7 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor, |
| 53 | 51 | # define REGISTER_KIND Registers_x86_64 |
| 54 | 52 | #elif defined(__powerpc64__) |
| 55 | 53 | # define REGISTER_KIND Registers_ppc64 |
| 56 | #elif defined(__ppc__) | |
| 54 | #elif defined(__powerpc__) | |
| 57 | 55 | # define REGISTER_KIND Registers_ppc |
| 58 | 56 | #elif defined(__aarch64__) |
| 59 | 57 | # define REGISTER_KIND Registers_arm64 |
| ... | ... | @@ -70,7 +68,7 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor, |
| 70 | 68 | #elif defined(__mips__) |
| 71 | 69 | # warning The MIPS architecture is not supported with this ABI and environment! |
| 72 | 70 | #elif defined(__sparc__) && defined(__arch64__) |
| 73 | # define REGISTER_KIND Registers_sparc64 | |
| 71 | #define REGISTER_KIND Registers_sparc64 | |
| 74 | 72 | #elif defined(__sparc__) |
| 75 | 73 | # define REGISTER_KIND Registers_sparc |
| 76 | 74 | #elif defined(__riscv) |
| ... | ... | @@ -296,6 +294,35 @@ void __unw_remove_dynamic_fde(unw_word_t fde) { |
| 296 | 294 | // fde is own mh_group |
| 297 | 295 | DwarfFDECache<LocalAddressSpace>::removeAllIn((LocalAddressSpace::pint_t)fde); |
| 298 | 296 | } |
| 297 | ||
| 298 | void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start) { | |
| 299 | // The eh_frame section start serves as the mh_group | |
| 300 | unw_word_t mh_group = eh_frame_start; | |
| 301 | CFI_Parser<LocalAddressSpace>::CIE_Info cieInfo; | |
| 302 | CFI_Parser<LocalAddressSpace>::FDE_Info fdeInfo; | |
| 303 | auto p = (LocalAddressSpace::pint_t)eh_frame_start; | |
| 304 | while (true) { | |
| 305 | if (CFI_Parser<LocalAddressSpace>::decodeFDE( | |
| 306 | LocalAddressSpace::sThisAddressSpace, p, &fdeInfo, &cieInfo, | |
| 307 | true) == NULL) { | |
| 308 | DwarfFDECache<LocalAddressSpace>::add((LocalAddressSpace::pint_t)mh_group, | |
| 309 | fdeInfo.pcStart, fdeInfo.pcEnd, | |
| 310 | fdeInfo.fdeStart); | |
| 311 | p += fdeInfo.fdeLength; | |
| 312 | } else if (CFI_Parser<LocalAddressSpace>::parseCIE( | |
| 313 | LocalAddressSpace::sThisAddressSpace, p, &cieInfo) == NULL) { | |
| 314 | p += cieInfo.cieLength; | |
| 315 | } else | |
| 316 | return; | |
| 317 | } | |
| 318 | } | |
| 319 | ||
| 320 | void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start) { | |
| 321 | // The eh_frame section start serves as the mh_group | |
| 322 | DwarfFDECache<LocalAddressSpace>::removeAllIn( | |
| 323 | (LocalAddressSpace::pint_t)eh_frame_start); | |
| 324 | } | |
| 325 | ||
| 299 | 326 | #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) |
| 300 | 327 | #endif // !defined(__USING_SJLJ_EXCEPTIONS__) |
| 301 | 328 |
lib/libunwind/src/libunwind_ext.h+4-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ libunwind_ext.h -----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -51,6 +51,9 @@ extern void __unw_iterate_dwarf_unwind_cache(void (*func)( |
| 51 | 51 | extern void __unw_add_dynamic_fde(unw_word_t fde); |
| 52 | 52 | extern void __unw_remove_dynamic_fde(unw_word_t fde); |
| 53 | 53 | |
| 54 | extern void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start); | |
| 55 | extern void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start); | |
| 56 | ||
| 54 | 57 | #if defined(_LIBUNWIND_ARM_EHABI) |
| 55 | 58 | extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*); |
| 56 | 59 | extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context, |