Use __ehdr_start rather than _begin in _dl_start_final
Florian Weimer
fweimer@redhat.com
Sat Apr 30 11:27:16 GMT 2022
* Alan Modra via Libc-alpha:
> On Thu, Apr 28, 2022 at 04:37:53PM +0930, Alan Modra wrote:
>> 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.
>
> Just tst-dl_find_object regresses on a glibc ld.so that uses _begin.
I think _dl_find_dso_for_object will go wrong as well, potentially
misidentifying dlopen/dlsym/atexit callers.
But I think you should proceed with your binutils fix, and we should
backport the glibc fix.
Thanks,
Florian
More information about the Libc-alpha
mailing list