This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] aarch64: Check PIC instead of SHARED in start.S
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: nd at arm dot com, GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 06 Oct 2017 11:56:03 +0100
- Subject: Re: [PATCH] aarch64: Check PIC instead of SHARED in start.S
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
- Nodisclaimer: True
- References: <20170929213203.GG2482@gmail.com> <59D2102A.8090106@arm.com> <CAMe9rOrO8POL0WsCZ0t-2+jy3qXGikRYBvmpPPa8TVeAFwn_ng@mail.gmail.com> <59D368C9.3030005@arm.com> <59D3AD6A.9060000@arm.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 03/10/17 16:31, Szabolcs Nagy wrote:
> On 03/10/17 11:39, Szabolcs Nagy wrote:
>> On 02/10/17 12:20, H.J. Lu wrote:
>>> On 10/2/17, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>>> On 29/09/17 22:32, H.J. Lu wrote:
>>>>> Since start.o may be compiled as PIC, we should check PIC instead of
>>>>> SHARED.
>>>>>
>>>>> OK for master?
>>>>>
>>>>
>>>> i believe that the compile/link tests worked..
>>>
>>> Does static PIE of hjl/pie/static branch run on arm and aarch64?
>>>
>>
>> no, if i build with --enable-static-pie the install step
>> fails when the static linked sln runs.
>>
>> there are relative relocs against the func ptrs that are
>> loaded from GOT in the startup code, but execution fails
>> even before those are used because there are R*_JUMP_SLOT
>> and R*_GLOB_DAT relocs which are not processed correctly.
>>
>> in particular in
>> if (__pthread_initialize_minimal != NULL)
>> __pthread_initialize_minimal ();
>> the symbol value loaded from GOT is non-NULL even though
>> there is no pthread linked in, that is probably a linker bug.
>>
>
> it seems weak extern symbol is accessed via got and at
> link time that is not relaxed to 0 with -static -pie
> and the got entry is not initialized to 0 either.
aarch64 dl-machine.h has
struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
ElfW(Addr) value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
x86_64 has
struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
ElfW(Addr) value = (sym == NULL ? 0
: (ElfW(Addr)) sym_map->l_addr + sym->st_value);
sym_map is always == BOOTSTRAP_MAP in case of static pie, so
tye sym_map == NULL check is not true on aarch64 case for weak
undef symbols.
so either targets need to be fixed to not use sym_map check
for detecting undef weak (powerpc32, powerpc64, aarch64,
i386, arm, sh, sparc32, sparc64) or RESOLVE_MAP should not
be unconditionally set to BOOTSTRAP_MAP in _dl_relocate_static_pie
(since that is not true for undef symbols)