[PATCH v2 5/5] Linux: Consolidate auxiliary vector parsing
Adhemerval Zanella
adhemerval.zanella@linaro.org
Fri Feb 11 13:48:41 GMT 2022
On 11/02/2022 10:24, Szabolcs Nagy wrote:
> The 02/11/2022 09:47, Adhemerval Zanella wrote:
>> On 11/02/2022 09:31, Szabolcs Nagy via Libc-alpha wrote:
>>> The 02/03/2022 12:08, Florian Weimer via Libc-alpha wrote
>>>> + dl_parse_auxv_t auxv_values = { 0, };
>>>> + _dl_parse_auxv (av, auxv_values);
>>>
>>> this seems to use memset now on aarch64 before irelative
>>> relocs are resolved in static binaries.
>>>
>>> which causes infinite loops in the iplt (i've also seen
>>> segfaults in the build log).
>>>
>>> i wonder what is a clean fix...
>>>
>>
>> Maybe add inhibit_loop_to_libcall to avoid the memset call.
>
> does not work for me..
> happens at -O0 too
> https://godbolt.org/z/W9r3nffYd
Yeah, this won't help much this situation. Unless we can make gcc *not*
emit this memset call, we will need something like:
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 1977a2be76..49f3fd2a61 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -19,6 +19,10 @@
/* This file defines some things that for the dynamic linker are defined in
rtld.c and dl-sysdep.c in ways appropriate to bootstrap dynamic linking. */
+#ifndef SHARED
+asm ("memset = __memset_generic");
+#endif
+
#include <string.h>
/* Mark symbols hidden in static PIE for early self relocation to work.
Note: string.h may have ifuncs which cannot be hidden on i686. */
$ make -j24 && make test t=elf/tst-tls1-static-non-pie
[...]
PASS: elf/tst-tls1-static-non-pie
original exit status 0
set bar to 1 (LE)
get sum of foo and bar (IE) = 1
get sum of foo and bar (LD or TLSDESC) = 1
get sum of foo and bar (GD or TLSDESC) = 1
I think the best approach would to add a __memset_generic, __memcpy_generic,
and __memmove_generic on all targets and add a header similar to
sysdeps/generic/symbol-hacks.h to activate the redirection when required
(to not pessimize code that would work with the IPTL generated by the
iFUNC).
More information about the Libc-alpha
mailing list