[PATCH v2] RISC-V: Fix IFUNC resolver cannot access gp pointer

Yangyu Chen cyy@cyyself.name
Thu Oct 31 10:35:09 GMT 2024



> On Oct 31, 2024, at 18:32, Florian Weimer <fweimer@redhat.com> wrote:
> 
> * Yangyu Chen:
> 
>> I proposed an idea to bypass the GP initialization by restricting
>> the use of the norelax attribute for all callees of IFUNC. In this
>> case, the linker will retain auipc + load/store instructions to
>> access global variables based on pc-relative address mode instead
>> of relaxing them to a single load/store at a +- 2KB offset from the
>> GP.
> 
> What do you mean by “all callees of IFUNC”?  This issue only affects the
> resolver, not the IFUNC implementation itself.

Oh… I mean the IFUNC resolver generated by compilers for target_clones
feature, which is under the control of the compiler.

> 
> As I said, if the glibc dynamic linker has a reliable way to identify
> the expected GP value, it can set GP before calling the resolver.  That
> requires some form of ABI change, but it would be backwards compatible.
> (We just won't be able to do it if the binary doesn't contain the required
> information, and the __global_pointer$ dynamic symbol is absent as
> well.)
> 
> The technical side should be easy to implement.
> 
> Thanks,
> Florian



More information about the Libc-alpha mailing list