[lld] r248272 - Handle implicit addends in Elf_Rel.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 18:00:16 PDT 2015


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.)

On Tue, Sep 22, 2015 at 6:35 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> 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
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150923/a2388c8a/attachment.html>


More information about the llvm-commits mailing list