[lld] dynamic section question.

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