Default entry point for ELF shared objects

Fangrui Song i@maskray.me
Wed Sep 15 16:49:42 GMT 2021


On 2021-09-13, Florian Weimer via Binutils wrote:
>BFD ld currently sets a non-zero entry point address for ELF shared
>objects even if the object does not have a _start symbol.
>
>Is there a reason for this behavior (particularly for ELF ET_DYN
>output)?
>
>On Linux, the kernel will happily load and execute shared objects using
>this entry point address, typically leading to crashes.
>
>If the entry point address in the ELF header were zero, it might be
>possible to detect the missing entry point, and refuse to execute the
>shared object as if it were a program.
>
>Thanks,
>Florian

This behavior is documented at https://sourceware.org/binutils/docs/ld/Entry-Point.html

"the address of the first byte of the ‘.text’ section, if present;"

The rule is quite ad-hoc and I'd support the removal.


More information about the Binutils mailing list