[lld] r248272 - Handle implicit addends in Elf_Rel.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 06:35:00 PDT 2015


Author: rafael
Date: Tue Sep 22 08:35:00 2015
New Revision: 248272

URL: http://llvm.org/viewvc/llvm-project?rev=248272&view=rev
Log:
Handle implicit addends in Elf_Rel.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/test/elf2/relocation-i686.s

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=248272&r1=248271&r2=248272&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Sep 22 08:35:00 2015
@@ -31,9 +31,10 @@ void InputSection<ELFT>::relocateOne(uin
                                      uintX_t SymVA) {
   uintX_t Offset = Rel.r_offset;
   uint8_t *Location = Buf + Offset;
+  uint32_t Addend = *(support::ulittle32_t *)Location;
   switch (Type) {
   case R_386_32:
-    support::endian::write32le(Location, SymVA);
+    support::endian::write32le(Location, SymVA + Addend);
     break;
   default:
     llvm::errs() << Twine("unrecognized reloc ") + Twine(Type) << '\n';

Modified: lld/trunk/test/elf2/relocation-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation-i686.s?rev=248272&r1=248271&r2=248272&view=diff
==============================================================================
--- lld/trunk/test/elf2/relocation-i686.s (original)
+++ lld/trunk/test/elf2/relocation-i686.s Tue Sep 22 08:35:00 2015
@@ -9,8 +9,8 @@ _start:
 .section       .R_386_32,"ax", at progbits
 .global R_386_32
 R_386_32:
-  movl $R_386_32, %edx
+  movl $R_386_32 + 1, %edx
 
 // CHECK: Disassembly of section .R_386_32:
 // CHECK-NEXT: R_386_32:
-// CHECK-NEXT:  11000: {{.*}} movl $69632, %edx
+// CHECK-NEXT:  11000: {{.*}} movl $69633, %edx




More information about the llvm-commits mailing list