<div dir="ltr">I defined add32(uint8_t *Location, uint32_t Addend) to handle cases like this. You might want to do the same thing. (COFF is LE-only so all functions implicitly assumes LE, but for ELF you need to define both LE and BE, though.)</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 22, 2015 at 6:35 AM, Rafael Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Tue Sep 22 08:35:00 2015<br>
New Revision: 248272<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248272&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248272&view=rev</a><br>
Log:<br>
Handle implicit addends in Elf_Rel.<br>
<br>
Modified:<br>
    lld/trunk/ELF/InputSection.cpp<br>
    lld/trunk/test/elf2/relocation-i686.s<br>
<br>
Modified: lld/trunk/ELF/InputSection.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=248272&r1=248271&r2=248272&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=248272&r1=248271&r2=248272&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/InputSection.cpp (original)<br>
+++ lld/trunk/ELF/InputSection.cpp Tue Sep 22 08:35:00 2015<br>
@@ -31,9 +31,10 @@ void InputSection<ELFT>::relocateOne(uin<br>
                                      uintX_t SymVA) {<br>
   uintX_t Offset = Rel.r_offset;<br>
   uint8_t *Location = Buf + Offset;<br>
+  uint32_t Addend = *(support::ulittle32_t *)Location;<br>
   switch (Type) {<br>
   case R_386_32:<br>
-    support::endian::write32le(Location, SymVA);<br>
+    support::endian::write32le(Location, SymVA + Addend);<br>
     break;<br>
   default:<br>
     llvm::errs() << Twine("unrecognized reloc ") + Twine(Type) << '\n';<br>
<br>
Modified: lld/trunk/test/elf2/relocation-i686.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation-i686.s?rev=248272&r1=248271&r2=248272&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation-i686.s?rev=248272&r1=248271&r2=248272&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/relocation-i686.s (original)<br>
+++ lld/trunk/test/elf2/relocation-i686.s Tue Sep 22 08:35:00 2015<br>
@@ -9,8 +9,8 @@ _start:<br>
 .section       .R_386_32,"ax",@progbits<br>
 .global R_386_32<br>
 R_386_32:<br>
-  movl $R_386_32, %edx<br>
+  movl $R_386_32 + 1, %edx<br>
<br>
 // CHECK: Disassembly of section .R_386_32:<br>
 // CHECK-NEXT: R_386_32:<br>
-// CHECK-NEXT:  11000: {{.*}} movl $69632, %edx<br>
+// CHECK-NEXT:  11000: {{.*}} movl $69633, %edx<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>