Default entry point for ELF shared objects
Hans-Peter Nilsson
hp@bitrange.com
Thu Sep 16 15:14:39 GMT 2021
On Thu, 16 Sep 2021, Florian Weimer via Binutils wrote:
> * 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,
Even if so, IMHO it should be updated to be "the text segment"
or words to that effect, as the .text *section* is likely just
main code located after .startup or .init or similar.
> but removed for Linux ELF targets, especially ET_DYN output
> objects.
>
> Thanks,
> Florian
>
brgds, H-P
More information about the Binutils
mailing list