diff mbox series

RISC-V: Fix IFUNC resolver cannot access gp pointer

Message ID tencent_FAC760855C3556F07D0BE26AF3386EE02A0A@qq.com
State New
Headers show
Series RISC-V: Fix IFUNC resolver cannot access gp pointer | expand

Commit Message

Yangyu Chen Oct. 15, 2024, 9:48 a.m. UTC
In some cases, a IFUNC resolver may need to access the gp pointer to
resolve the function address, such object may have l_relocated == 0.
In this case, the gp pointer is not set up, and the resolver cannot
access the gp pointer. This patch fixes this issue by relaxing the
check of l_relocated in elf_machine_runtime_setup.

Closes: BZ #32269
Fixes: 96d1b9ac23 ("RISC-V: Fix the static-PIE non-relocated object check")
Signed-off-by: Yangyu Chen <cyy@cyyself.name>
---
 sysdeps/riscv/dl-machine.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Schwab Oct. 15, 2024, 11:08 a.m. UTC | #1
On Okt 15 2024, Yangyu Chen wrote:

> In some cases, a IFUNC resolver may need to access the gp pointer to
> resolve the function address, such object may have l_relocated == 0.
> In this case, the gp pointer is not set up, and the resolver cannot
> access the gp pointer. This patch fixes this issue by relaxing the
> check of l_relocated in elf_machine_runtime_setup.

That can't be right since it reintroduces bug 31317.
diff mbox series

Patch

diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
index b2f28697f7..ffb8c4aaa0 100644
--- a/sysdeps/riscv/dl-machine.h
+++ b/sysdeps/riscv/dl-machine.h
@@ -348,7 +348,7 @@  elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
       gotplt[1] = (ElfW(Addr)) l;
     }
 
-  if (l->l_type == lt_executable && l->l_relocated)
+  if (l->l_type == lt_executable)
     {
       /* The __global_pointer$ may not be defined by the linker if the
 	 $gp register does not be used to access the global variable