Use __ehdr_start rather than _begin in _dl_start_final
Alan Modra
amodra@gmail.com
Thu Apr 28 07:07:53 GMT 2022
On Wed, Apr 27, 2022 at 03:54:27PM -0300, Adhemerval Zanella wrote:
>
>
> On 27/04/2022 09:35, Alan Modra via Libc-alpha wrote:
> > __ehdr_start is already used in rltld.c:dl_main, and can serve the
> > same purpose as _begin. Besides tidying the code, using linker
> > defined section relative symbols rather than "-defsym _begin=0" better
> > reflects the intent of _dl_start_final use of _begin, which is to
> > refer to the load address of ld.so rather than absolute address zero.
> >
> > The motive for this patch is to finally tidy ppc32 GNU ld treatment of
> > absolute symbols. On ppc32, the reference to _begin generates a GOT
> > entry. A GOT entry for an absolute symbol shouldn't be dynamically
> > relocated, so this usage in glibc of an absolute _begin will fail once
> > I fix ppc32 ld. Note that on many other targets, including ppc64, gcc
> > generates pc relative or got-pointer relative addressing for _begin.
> > ie. the compiler assumes _begin is *not* at an absolute address, and
> > generally linkers go along with that.
>
> Does it mean that once you fix it, newer binutils will start to fail
> to build older glibc releases for powerpc32?
Not necessarily. I found these issues with absolute symbols in glibc
by inspecting object files. Possibly dl_rtld_map.l_map_start == 0
causes no problem, I'll know when I have set up a test environment for
ppc32 that lets me build and run a ppc32 glibc.
--
Alan Modra
Australia Development Lab, IBM
More information about the Libc-alpha
mailing list