HA: [lld] r250169 - This patch implements basic variant of lazy loading for x86_x64 and for X86 targets.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 10:20:34 PDT 2015


>От: Rui Ueyama [ruiu at google.com]
>Отправлено: 15 октября 2015 г. 2:13
>Кому: George Rimar
>Копия: llvm-commits
>Тема: Re: [lld] r250169 - This patch implements basic variant of lazy loading for x86_x64 and for X86 targets.
>
>You need to disable threads using -DLLVM_ENABLE_THREADS=false.
>
>Even with that flag LLD's tests would fail. All LLVM and Clang tests should pass, so please use them as a test.
>

Hi, I just want to share some results about lazy linking.
Today I reproduced the issue on minimal sample. Actually is just an empty main() and any DSO :)
I initialized .got.plt zero to reference .dynamic section (that was missing in the patch) and also fixed one
issue (DT_PLTGOT was pointing to got and not to got.plt). 

After that linking mechanism looks to be almost alive. Using gdb I was able to debug and review dispatching stuff. 
PLT and .got.plt looks configured correctly. GOT[0] initialized to .dynamic section, other 2 reserved GOT[1] and GOT[2] adresses are initialized by
dynamic linker in the same way and values as it works for ld case. 
But unfortunately I faced runtime assertion error from dynamic linker side:

0x0000000000011024 in _start ()
(gdb) stepi
0x00000000000111c0 in __libc_start_main at plt ()
(gdb) stepi
0x00000000000111c6 in __libc_start_main at plt ()
(gdb) stepi
0x00000000000111cb in __libc_start_main at plt ()
(gdb) stepi
0x00000000000111b0 in ?? ()
(gdb) stepi
0x00000000000111b6 in ?? ()
(gdb) stepi
_dl_runtime_resolve () at ../sysdeps/x86_64/dl-trampoline.S:58
58	../sysdeps/x86_64/dl-trampoline.S: No such file or directory.
(gdb) stepi
61	in ../sysdeps/x86_64/dl-trampoline.S
(gdb) stepi
62	in ../sysdeps/x86_64/dl-trampoline.S
(gdb) continue
Continuing.
Inconsistency detected by ld.so: ../elf/dl-runtime.c: 79: _dl_fixup: Assertion `((reloc->r_info) & 0xffffffff) == 7' failed!
[Inferior 1 (process 8071) exited with code 0177]

So looks something is wrong with relocation for __libc_start_main. At the same I think it is 7 as expected when readelf the binary.

Relocation section '.rela.plt' at offset 0x350 contains 1 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000012198  000100000007 R_X86_64_JUMP_SLO 0000000000000000 __libc_start_main + 0

I extracted the exact commandline that clang gives to lld and going to continue debugging that.

Best regards,
George.


More information about the llvm-commits mailing list