diff options
author | Palmer Dabbelt <palmer@rivosinc.com> | 2024-02-22 15:24:00 -0800 |
---|---|---|
committer | Andreas Schwab <schwab@suse.de> | 2024-03-25 15:17:13 +0100 |
commit | 96d1b9ac2321b565f340ba8f3674597141e3450d (patch) | |
tree | eecd6098943c84de0895e23b1f26e2dc0358318a /sysdeps/riscv | |
parent | dc1a77269c971652a8a5167ec366792eae052e65 (diff) | |
download | glibc-96d1b9ac2321b565f340ba8f3674597141e3450d.zip glibc-96d1b9ac2321b565f340ba8f3674597141e3450d.tar.gz glibc-96d1b9ac2321b565f340ba8f3674597141e3450d.tar.bz2 |
RISC-V: Fix the static-PIE non-relocated object check
The value of l_scope is only valid post relocation, so this original
check was triggering undefined behavior. Instead just directly check to
see if the object has been relocated, at which point using l_scope is
safe.
Reported-by: Andreas Schwab <schwab@suse.de>
Closes: BZ #31317
Fixes: e0590f41fe ("RISC-V: Enable static-pie.")
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'sysdeps/riscv')
-rw-r--r-- | sysdeps/riscv/dl-machine.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h index 0cbb476..b2f2869 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 && l->l_relocated) { /* The __global_pointer$ may not be defined by the linker if the $gp register does not be used to access the global variable |