]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - bfd/elfnn-riscv.c
RISC-V: Ouput __global_pointer$ as dynamic symbol when generating dynamic PDE.
authorNelson Chu <nelson.chu@sifive.com>
Wed, 16 Dec 2020 03:03:34 +0000 (19:03 -0800)
committerNelson Chu <nelson.chu@sifive.com>
Tue, 5 Jan 2021 02:18:33 +0000 (10:18 +0800)
commit18b9872261b950a8d10a4ae6ccb8f2acdaebc3e6
tree68413cf74c2d6906d4e7da73f09aa0da31f9fdb2
parent3d52735bab7e6df662381f51ee00b10e170cd6e9
RISC-V: Ouput __global_pointer$ as dynamic symbol when generating dynamic PDE.

When the ifunc resolver is in the executable, we may relax the variables
to gp-relative access instruction in the ifunc resolver, or in other functions
that called by the ifunc resolver.  But this will cause the uninitialized
gp problem since the ifunc need to be resolved at the early runtime, that
is at the pre-load stage, but we set the gp until the startup code.

At first, we try to add a new dynamic tag, DT_RISCV_GP, to stroe the gp value
and let ld.so can init the gp register early, before the pre-load stage.  But
we need to extend the ABI if we want to add a new dynamic tag.  Therefore,
in the psabi discussion, we try another solution, which was suggested by the
lld and FreeBSD linker experts, to let ld.so set the gp earlier - make sure
__global_pointer$ is output as a dynamic symbol when we are generating pde,
since we only do the relaxation for it.  Afterwards, ld.so can search the
DT_SYMTAB to get the gp value, and set the gp register before resolving ifunc.

bfd/
    * elfnn-riscv.c (allocate_dynrelocs): When we are generating pde, make
      sure gp symbol is output as a dynamic symbol.
bfd/ChangeLog
bfd/elfnn-riscv.c