[llvm] aceea45 - [MC][AArch64] Support .reloc *, BFD_RELOC_{NONE, 16, 32, 64}, *

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 5 21:31:53 PST 2021


Author: Fangrui Song
Date: 2021-03-05T21:31:08-08:00
New Revision: aceea45d8753334fad4c6b958754d63151d4c57c

URL: https://github.com/llvm/llvm-project/commit/aceea45d8753334fad4c6b958754d63151d4c57c
DIFF: https://github.com/llvm/llvm-project/commit/aceea45d8753334fad4c6b958754d63151d4c57c.diff

LOG: [MC][AArch64] Support .reloc *, BFD_RELOC_{NONE,16,32,64}, *

BFD_RELOC_NONE is useful for ld --gc-sections: it provides a generic way indicating a dependency between two sections.

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
    llvm/test/MC/AArch64/reloc-directive.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
index 75a9f2f5c80e..2186ab721148 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -342,6 +342,10 @@ Optional<MCFixupKind> AArch64AsmBackend::getFixupKind(StringRef Name) const {
 #define ELF_RELOC(X, Y)  .Case(#X, Y)
 #include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
 #undef ELF_RELOC
+                      .Case("BFD_RELOC_NONE", ELF::R_AARCH64_NONE)
+                      .Case("BFD_RELOC_16", ELF::R_AARCH64_ABS16)
+                      .Case("BFD_RELOC_32", ELF::R_AARCH64_ABS32)
+                      .Case("BFD_RELOC_64", ELF::R_AARCH64_ABS64)
                       .Default(-1u);
   if (Type == -1u)
     return None;

diff  --git a/llvm/test/MC/AArch64/reloc-directive.s b/llvm/test/MC/AArch64/reloc-directive.s
index 88cb48889d18..09b0f0d3cb9d 100644
--- a/llvm/test/MC/AArch64/reloc-directive.s
+++ b/llvm/test/MC/AArch64/reloc-directive.s
@@ -8,6 +8,10 @@
 # PRINT: .reloc 0, R_AARCH64_ABS64, .data+2
 # PRINT: .reloc 0, R_AARCH64_TLSDESC, foo+3
 # PRINT: .reloc 0, R_AARCH64_IRELATIVE, 5
+# PRINT: .reloc 0, BFD_RELOC_NONE, 9
+# PRINT: .reloc 0, BFD_RELOC_16, 9
+# PRINT: .reloc 0, BFD_RELOC_32, 9
+# PRINT: .reloc 0, BFD_RELOC_64, 9
 .text
   ret
   nop
@@ -20,6 +24,11 @@
   .reloc 0, R_AARCH64_TLSDESC, foo+3
   .reloc 0, R_AARCH64_IRELATIVE, 5
 
+  .reloc 0, BFD_RELOC_NONE, 9
+  .reloc 0, BFD_RELOC_16, 9
+  .reloc 0, BFD_RELOC_32, 9
+  .reloc 0, BFD_RELOC_64, 9
+
 .data
 .globl foo
 foo:
@@ -33,3 +42,7 @@ foo:
 # CHECK-NEXT: 0x0 R_AARCH64_ABS64 .data 0x2
 # CHECK-NEXT: 0x0 R_AARCH64_TLSDESC foo 0x3
 # CHECK-NEXT: 0x0 R_AARCH64_IRELATIVE - 0x5
+# CHECK-NEXT: 0x0 R_AARCH64_NONE - 0x9
+# CHECK-NEXT: 0x0 R_AARCH64_ABS16 - 0x9
+# CHECK-NEXT: 0x0 R_AARCH64_ABS32 - 0x9
+# CHECK-NEXT: 0x0 R_AARCH64_ABS64 - 0x9


        


More information about the llvm-commits mailing list