Default entry point for ELF shared objects
Florian Weimer
fweimer@redhat.com
Thu Sep 16 05:01:53 GMT 2021
* Fangrui Song:
> 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.
I saw that. I still wonder where it came from originally. It seems
more like something for a bare-metal target. Maybe it can be kept for
those, but removed for Linux ELF targets, especially ET_DYN output
objects.
Thanks,
Florian
More information about the Binutils
mailing list