public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] RISC-V: Fix the static-PIE non-relocated object check
@ 2024-03-25 14:20 Andreas Schwab
  0 siblings, 0 replies; only message in thread
From: Andreas Schwab @ 2024-03-25 14:20 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=96d1b9ac2321b565f340ba8f3674597141e3450d

commit 96d1b9ac2321b565f340ba8f3674597141e3450d
Author: Palmer Dabbelt <palmer@rivosinc.com>
Date:   Thu Feb 22 15:24:00 2024 -0800

    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>

Diff:
---
 sysdeps/riscv/dl-machine.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
index 0cbb476c05..b2f28697f7 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-25 14:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-25 14:20 [glibc] RISC-V: Fix the static-PIE non-relocated object check Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).