This program: .global _start _start: movl $1, %eax movl $42, %ebx int $0x80 “./clang -nostdlib x.s” Will not get a dynamic section unless -E passed to lld and because of that will segfault. If the .interp section is omitted (static) then the dynamic section isn’t needed and the program will run. Can lld recognize that an .interp is not needed (no DT_NEEDED) and omit the section even when the user/driver adds –dynamic-linker=xxx? Or should the .dynamic section be present as in the case when -E is used? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200522/d3c313e5/attachment.html>
'Fāng-ruì Sòng' via llvm-dev
2020-May-22 20:29 UTC
[llvm-dev] [lld] dynamic section question.
On 2020-05-22, sidneym at codeaurora.org wrote:>This program: > >.global _start > >_start: > > movl $1, %eax > > movl $42, %ebx > > int $0x80 > > > >“./clang -nostdlib x.s” > > > >Will not get a dynamic section unless -E passed to lld and because of that will segfault. If the .interp section is omitted (static) then the dynamic section isn’t needed and the program will run. > > > >Can lld recognize that an .interp is not needed (no DT_NEEDED) and omit the section even when the user/driver adds –dynamic-linker=xxx? Or should the .dynamic section be present as in the case when -E is used?clang passes --dynamic-linker to the linker. GNU ld has quite involved logic not to create .interp It is not at all clear to me that LLD should adopt that. clang -static -nostdlib a.s -o a # is probably more correct. -static suppresses --dynamic-linker