From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 470BD3973064; Fri, 8 Jan 2021 17:57:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 470BD3973064 From: "i at maskray dot me" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/27164] New: csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode Date: Fri, 08 Jan 2021 17:57:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i at maskray dot me X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2021 17:57:31 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27164 Bug ID: 27164 Summary: csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: dynamic-link Assignee: unassigned at sourceware dot org Reporter: i at maskray dot me Target Milestone: --- * In GNU ld, __rela_iplt_start is defined for -no-pie, but not for -pie. * LLD defines __rela_iplt_start, regardless of -no-pie, -pie or -shared. glibc csu/libc-start.c has undefined weak __rela_iplt_start/__rela_iplt_end= and currently requires the two to be equal in static pie mode. Since there are unavoidable R_*_IRELATIVE relocations, this essentially requires __rela_iplt_start and __rela_iplt_end to be 0, i.e. the linker does not define the two symbols in -pie mode. However, this addr= ess can be easily fixed on glibc side by differenciating static pie from static. (Note GNU ld does not currently have -no-pie (its -no-pie is currently -n -o "-pie"), but gold/LLD do have.) binutils commit 3aa14d16c669ca75f9fa4e995a2e2d13069dff3f (2009-06-01) added __rela_iplt_start to ld. That was before glibc gained static pie support (2017; http://sourceware.org/PR19574). With static pie, I think the design of __rela_iplt_start should be revised. diff -u =3D(ld.bfd --verbose) =3D(ld.bfd -pie --verbose) reveals two differ= ences. The image base (__executable_start) is an essential one but the other one (whether __rela_iplt_start is defined) should not be their. In https://sourceware.org/git/?p=3Dglibc.git;a=3Dshortlog;h=3Drefs/heads/googl= e/grte/v5-2.27/master , I find "Make _dl_relocate_static_pie return an int indicating whether it applied relocs." can address the exact glibc csu/libc-start.c issue. I do see that GNU ld may not want a change (probably in a couple of years) because it does not want to gratuitously break unpatched glibc `configure --enable-static-pie`. But once glibc is fixed and the minimum required vers= ion is bumped, the code can be removed from GNU ld. On glibc side, the explicit guard before ARCH_APPLY_IREL also makes things more clear, not relying on subtle zero address __rela_iplt_start. --=20 You are receiving this mail because: You are on the CC list for the bug.=