public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "i at maskray dot me" <sourceware-bugzilla@sourceware.org> 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 [thread overview] Message-ID: <bug-27164-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=27164 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 address 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 =(ld.bfd --verbose) =(ld.bfd -pie --verbose) reveals two differences. 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=glibc.git;a=shortlog;h=refs/heads/google/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 version 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. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2021-01-08 17:57 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-08 17:57 i at maskray dot me [this message] 2021-07-09 5:11 ` [Bug dynamic-link/27164] " carlos at redhat dot com 2021-07-11 15:23 ` hjl.tools at gmail dot com 2021-07-15 18:33 ` i at maskray dot me
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-27164-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).