From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7362F3858428; Fri, 23 Feb 2024 03:06:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7362F3858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708657617; bh=QWeCh9JD0G0N7a2SLJtTwZ3MQCO6c20kdc3TGn5YuvE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=acy46zfIzXkROhZQnYnjAVIZ/b5qJLswhhYufBtnxZVS50v9eJPBx4vp7cxYamcwW EwEYabvscHocMpDOYXPaW74+e/uJ0ISw4rUkguu7Lv2NRny9/aKn2uzzaJ8uf+u9DE ucXB2ZdJbwjt0XtXSmVQ6SCEe2urTpiFNLHf5XfU= From: "yanzhang.wang at intel dot com" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/31317] [RISCV] static PIE crashes during self relocation Date: Fri, 23 Feb 2024 03:06:56 +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: yanzhang.wang at intel dot com 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: 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 --- Comment #6 from Wang, Yanzhang --- I think the l_relocated is enough too. I have did some investigation about this in the GNU ld and mold. If I understand correctly, the mold will fill the relocated field if the command option --apply-dynamic-relocs is true, whose default value is true. But for GNU ld, this is ignored and skipped at elfnn-riscv.c:riscv_elf_relocate_section sreloc =3D elf_section_data (input_section)->sreloc; riscv_elf_append_rela (output_bfd, sreloc, &outrel); if (!relocate) continue; Although the relative rel has been computed but the relocate is true, so we= do nothing. It seems this is not defined explicit somewhere and all the two different behaviors seems right. For this case, the l_scope in dl_main_map is a pointer and need relocate. In the mold linker, the value in relocated field will be the value of global dl_main_map's location. But in GNU ld, the value will be 0. So we need only to use the l_relocated, it's a value which will not be relo= caed and will be set at the end of _dl_relocate_static_pie. --=20 You are receiving this mail because: You are on the CC list for the bug.=