[Bug dynamic-link/31317] [RISCV] static PIE crashes during self relocation
palmer at gcc dot gnu.org
sourceware-bugzilla@sourceware.org
Thu Feb 22 22:53:11 GMT 2024
https://sourceware.org/bugzilla/show_bug.cgi?id=31317
Palmer Dabbelt <palmer at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |adhemerval.zanella at linaro dot o
| |rg
--- Comment #3 from Palmer Dabbelt <palmer at gcc dot gnu.org> ---
(In reply to Andreas Schwab from comment #2)
> l_scope is never null, this condition needs to be removed again. It's
> simply the wrong check.
Sorry, I think I'm a bit lost here. IIUC we don't actually need GP set at this
point for static-PIE, as it's done in _start. So I maybe something like this
diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
index 0cbb476c05..ae38df4bc1 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_scope != NULL)
+ if (l->l_type == lt_executable && scope != NULL)
{
/* The __global_pointer$ may not be defined by the linker if the
$gp register does not be used to access the global variable
@@ -360,7 +360,7 @@ elf_machine_runtime_setup (struct link_map *l, struct
r_scope_elem *scope[],
const ElfW(Sym) *ref = &gp_sym;
_dl_lookup_symbol_x ("__global_pointer$", l, &ref,
- l->l_scope, NULL, 0, 0, NULL);
+ scope, NULL, 0, 0, NULL);
if (ref)
asm (
"mv gp, %0\n"
should do it? This relies on the caller to obtain scope, the static-PIE call
sets it to NULL and the others set it to l_scope.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list