[lld] r246362 - [ELFv2] Implement R_X86_64_32 relocation.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 29 06:15:42 PDT 2015


Author: davide
Date: Sat Aug 29 08:15:42 2015
New Revision: 246362

URL: http://llvm.org/viewvc/llvm-project?rev=246362&view=rev
Log:
[ELFv2] Implement R_X86_64_32 relocation.

Differential Revision:	http://reviews.llvm.org/D12436

Modified:
    lld/trunk/ELF/Writer.cpp
    lld/trunk/test/elf2/relocation.s

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=246362&r1=246361&r2=246362&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Aug 29 08:15:42 2015
@@ -254,11 +254,15 @@ template <class ELFT> void OutputSection
         uint32_t Type = RI.getType(EObj->isMips64EL());
         uintX_t P = this->getVA() + C->getOutputSectionOff();
         uintX_t SymVA = getSymVA<ELFT>(cast<DefinedRegular<ELFT>>(Body));
+        uint8_t *Location = Base + Offset;
         switch (Type) {
         case llvm::ELF::R_X86_64_PC32:
-          support::endian::write32le(Base + Offset,
+          support::endian::write32le(Location,
                                      SymVA + (RI.r_addend - (P + Offset)));
           break;
+        case llvm::ELF::R_X86_64_32:
+          support::endian::write32le(Location, SymVA + RI.r_addend);
+          break;
         default:
           llvm::errs() << Twine("unrecognized reloc ") + Twine(Type) << '\n';
           break;

Modified: lld/trunk/test/elf2/relocation.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation.s?rev=246362&r1=246361&r2=246362&view=diff
==============================================================================
--- lld/trunk/test/elf2/relocation.s (original)
+++ lld/trunk/test/elf2/relocation.s Sat Aug 29 08:15:42 2015
@@ -1,6 +1,6 @@
 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
 // RUN: lld -flavor gnu2 %t -o %t2
-// RUN: llvm-objdump -d %t2 | FileCheck %s
+// RUN: llvm-objdump -t -d %t2 | FileCheck %s
 // REQUIRES: x86
 
 
@@ -14,4 +14,16 @@ _start:
 .global lulz
 lulz:
 
+.global bar
+.text
+bar:
+  movl $bar, %edx // R_X86_64_32
+
+// R_X86_64_32
+// CHECK: bar:
+// CHECK:    1000: ba 00 10 00 00 movl $4096, %edx
+
 // CHECK: e8 04 00 00 00  callq   4
+
+// Also check that symbols match.
+// CHECK: 0000000000001000         .text           00000000 bar




More information about the llvm-commits mailing list