|
20 | 20 | using namespace llvm; |
21 | 21 | using namespace bolt; |
22 | 22 |
|
| 23 | +namespace ELFReserved { |
| 24 | +enum { |
| 25 | + R_RISCV_TPREL_I = 49, |
| 26 | + R_RISCV_TPREL_S = 50, |
| 27 | +}; |
| 28 | +} // namespace ELFReserved |
| 29 | + |
23 | 30 | Triple::ArchType Relocation::Arch; |
24 | 31 |
|
25 | 32 | static bool isSupportedX86(uint64_t Type) { |
@@ -111,6 +118,13 @@ static bool isSupportedRISCV(uint64_t Type) { |
111 | 118 | case ELF::R_RISCV_LO12_I: |
112 | 119 | case ELF::R_RISCV_LO12_S: |
113 | 120 | case ELF::R_RISCV_64: |
| 121 | + case ELF::R_RISCV_TLS_GOT_HI20: |
| 122 | + case ELF::R_RISCV_TPREL_HI20: |
| 123 | + case ELF::R_RISCV_TPREL_ADD: |
| 124 | + case ELF::R_RISCV_TPREL_LO12_I: |
| 125 | + case ELF::R_RISCV_TPREL_LO12_S: |
| 126 | + case ELFReserved::R_RISCV_TPREL_I: |
| 127 | + case ELFReserved::R_RISCV_TPREL_S: |
114 | 128 | return true; |
115 | 129 | } |
116 | 130 | } |
@@ -214,6 +228,7 @@ static size_t getSizeForTypeRISCV(uint64_t Type) { |
214 | 228 | return 4; |
215 | 229 | case ELF::R_RISCV_64: |
216 | 230 | case ELF::R_RISCV_GOT_HI20: |
| 231 | + case ELF::R_RISCV_TLS_GOT_HI20: |
217 | 232 | // See extractValueRISCV for why this is necessary. |
218 | 233 | return 8; |
219 | 234 | } |
@@ -532,6 +547,7 @@ static uint64_t extractValueRISCV(uint64_t Type, uint64_t Contents, |
532 | 547 | case ELF::R_RISCV_BRANCH: |
533 | 548 | return extractBImmRISCV(Contents); |
534 | 549 | case ELF::R_RISCV_GOT_HI20: |
| 550 | + case ELF::R_RISCV_TLS_GOT_HI20: |
535 | 551 | // We need to know the exact address of the GOT entry so we extract the |
536 | 552 | // value from both the AUIPC and L[D|W]. We cannot rely on the symbol in the |
537 | 553 | // relocation for this since it simply refers to the object that is stored |
@@ -600,6 +616,7 @@ static bool isGOTRISCV(uint64_t Type) { |
600 | 616 | default: |
601 | 617 | return false; |
602 | 618 | case ELF::R_RISCV_GOT_HI20: |
| 619 | + case ELF::R_RISCV_TLS_GOT_HI20: |
603 | 620 | return true; |
604 | 621 | } |
605 | 622 | } |
@@ -636,6 +653,14 @@ static bool isTLSRISCV(uint64_t Type) { |
636 | 653 | switch (Type) { |
637 | 654 | default: |
638 | 655 | return false; |
| 656 | + case ELF::R_RISCV_TLS_GOT_HI20: |
| 657 | + case ELF::R_RISCV_TPREL_HI20: |
| 658 | + case ELF::R_RISCV_TPREL_ADD: |
| 659 | + case ELF::R_RISCV_TPREL_LO12_I: |
| 660 | + case ELF::R_RISCV_TPREL_LO12_S: |
| 661 | + case ELFReserved::R_RISCV_TPREL_I: |
| 662 | + case ELFReserved::R_RISCV_TPREL_S: |
| 663 | + return true; |
639 | 664 | } |
640 | 665 | } |
641 | 666 |
|
@@ -733,6 +758,7 @@ static bool isPCRelativeRISCV(uint64_t Type) { |
733 | 758 | case ELF::R_RISCV_RVC_JUMP: |
734 | 759 | case ELF::R_RISCV_RVC_BRANCH: |
735 | 760 | case ELF::R_RISCV_32_PCREL: |
| 761 | + case ELF::R_RISCV_TLS_GOT_HI20: |
736 | 762 | return true; |
737 | 763 | } |
738 | 764 | } |
|
0 commit comments