From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AFA5A3858424; Thu, 22 Feb 2024 22:53:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFA5A3858424 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708642392; bh=ZSgvVRap2LUlgrcRcuiKqcwG+YUnkK6vNsxyR2JPa1s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yDPPHhYfcKO4GUB8cLwkg9BcqEbV1594VqSAAaad272Dh/YqARuNcJSPCtaUIOWUr dqV6dVM82PbNER8ov3QtysFL4vENrvDYTGnMsYY5qEBFkLzLw/eAi9ipHSy6ue2lli 4QLBu6TaZiqFrL+tIKVtwKY9t+y3o7uTU/Saa0pM= From: "palmer at gcc dot gnu.org" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/31317] [RISCV] static PIE crashes during self relocation Date: Thu, 22 Feb 2024 22:53:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: 2.39 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: palmer at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31317 Palmer Dabbelt changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |adhemerval.zanella at lina= ro dot o | |rg --- Comment #3 from Palmer Dabbelt --- (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 th= is 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] =3D (ElfW(Addr)) l; } - if (l->l_type =3D=3D lt_executable && l->l_scope !=3D NULL) + if (l->l_type =3D=3D lt_executable && scope !=3D 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 =3D &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 ca= ll sets it to NULL and the others set it to l_scope. --=20 You are receiving this mail because: You are on the CC list for the bug.=