[lld] r246902 - [elf2] Add 32S and 64 relocations (needed for musl).

Michael J. Spencer via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 4 17:36:03 PDT 2015


Author: mspencer
Date: Fri Sep  4 19:36:03 2015
New Revision: 246902

URL: http://llvm.org/viewvc/llvm-project?rev=246902&view=rev
Log:
[elf2] Add 32S and 64 relocations (needed for musl).

It wasn't obvious what the assembly was to generate these relocations, so I did the test with yaml.

Added:
    lld/trunk/test/elf2/relocations.test
Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=246902&r1=246901&r2=246902&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Sep  4 19:36:03 2015
@@ -271,8 +271,12 @@ template <class ELFT> void OutputSection
                                      SymVA + (RI.r_addend - (P + Offset)));
           break;
         case llvm::ELF::R_X86_64_32:
+        case llvm::ELF::R_X86_64_32S:
           support::endian::write32le(Location, SymVA + RI.r_addend);
           break;
+        case llvm::ELF::R_X86_64_64:
+          support::endian::write64le(Location, SymVA + RI.r_addend);
+          break;
         default:
           llvm::errs() << Twine("unrecognized reloc ") + Twine(Type) << '\n';
           break;

Added: lld/trunk/test/elf2/relocations.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocations.test?rev=246902&view=auto
==============================================================================
--- lld/trunk/test/elf2/relocations.test (added)
+++ lld/trunk/test/elf2/relocations.test Fri Sep  4 19:36:03 2015
@@ -0,0 +1,31 @@
+# RUN: yaml2obj -format elf %s -o %t
+# RUN: lld -flavor gnu2 %t -o %tout
+# RUN: llvm-objdump -s %tout | FileCheck %s
+
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Size:            512
+  - Name:            .rela.text
+    Type:            SHT_RELA
+    Info:            .text
+    Relocations:
+      - Offset:          0x0000000000000000
+        Symbol:          _start
+        Type:            R_X86_64_32S
+      - Offset:          0x0000000000000004
+        Symbol:          _start
+        Type:            R_X86_64_64
+
+Symbols:
+  Global:
+    - Name:            _start
+      Section:         .text
+      Value:           0x42
+
+# CHECK: 0000 42000000 42000000 00000000 00000000




More information about the llvm-commits mailing list