[PATCH v3] RISC-V: Fix IFUNC resolver cannot access gp pointer
Florian Weimer
fweimer@redhat.com
Mon Jan 13 12:50:58 GMT 2025
* Yangyu Chen:
> 2. There is no ABI grey area now.
>
> From [3] we have: `__global_pointer$` must be exported in the dynamic
> symbol table of dynamically-linked executables if there are any
> GP-relative accesses present in the executable.
If you can link editors to follow this even with version scripts that
use ”local: *”, it will work. But that's a big If.
We've relied on unconditionally exported symbols before, and I don't
think it works very well. See _IO_stdin_used and bug reports related to
that.
> 3. The original bug happens because the NULL value of l->l_scope has
> been solved by this patch.
>
> The root cause of the original bug is l->l_scope is NULL when calling
> elf_machine_runtime_setup in statie-pie. Because we have no scope at
> this time in statie-pie.
>
> However, static-pie doesn't need to do this. It will call `load_gp` at
> entry_point, thus there is no need to lookup symbol and set up gp
> here. We just solve it by adding `#ifdef SHARED`.
Agreed.
This lookup should not use the link map's scope anyway because that
could included preloaded objects with a conflicting definition of
__global_pointer$. You can use _dl_lookup_direct, similar to what
_dl_call_libc_early_init does. It wants the symbol in exactly this
particular object, too.
Thanks,
Florian
More information about the Libc-alpha
mailing list