public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug dynamic-link/27164] New: csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode @ 2021-01-08 17:57 i at maskray dot me 2021-07-09 5:11 ` [Bug dynamic-link/27164] " carlos at redhat dot com ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: i at maskray dot me @ 2021-01-08 17:57 UTC (permalink / raw) To: glibc-bugs 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug dynamic-link/27164] csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode 2021-01-08 17:57 [Bug dynamic-link/27164] New: csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode i at maskray dot me @ 2021-07-09 5:11 ` 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 2 siblings, 0 replies; 4+ messages in thread From: carlos at redhat dot com @ 2021-07-09 5:11 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=27164 Carlos O'Donell <carlos at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |Houdek.Ryan@fex-emu.org --- Comment #1 from Carlos O'Donell <carlos at redhat dot com> --- *** Bug 28066 has been marked as a duplicate of this bug. *** -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug dynamic-link/27164] csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode 2021-01-08 17:57 [Bug dynamic-link/27164] New: csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode i at maskray dot me 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 2 siblings, 0 replies; 4+ messages in thread From: hjl.tools at gmail dot com @ 2021-07-11 15:23 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=27164 H.J. Lu <hjl.tools at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hjl.tools at gmail dot com --- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> --- Glibc uses DT_XXX to handle relocations, including IFUNC relocations. Since there is no need to relocate static executable and there is no DT_XXX in static executable, I added __rela_iplt_start/__rela_iplt_end to handle IFUNC in static executable which doesn't need relocation. Since DT_XXX is used to handle relocations, including IFUNC relocations, in static PIE, linker shouldn't define __rela_iplt_start/__rela_iplt_end when DT_XXX is created. Please fix the lld bug. -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug dynamic-link/27164] csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode 2021-01-08 17:57 [Bug dynamic-link/27164] New: csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode i at maskray dot me 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 2 siblings, 0 replies; 4+ messages in thread From: i at maskray dot me @ 2021-07-15 18:33 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=27164 --- Comment #3 from Fangrui Song <i at maskray dot me> --- I worked around the glibc csu/libc-start.c ARCH_APPLY_IREL issue (unclear semantics) and unneeded diff -u =(ld.bfd --verbose) =(ld.bfd -pie --verbose) difference in ld.lld f8cb78e99aae9aa3f89f7bfe667db2c5b767f21f ([ELF] Don't define __rela_iplt_start for -pie/-shared) (target: LLD 13.0.0) but my complaint remains for glibc: https://sourceware.org/pipermail/libc-alpha/2021-July/128981.html -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-15 18:33 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-01-08 17:57 [Bug dynamic-link/27164] New: csu/libc-start.c should not call ARCH_APPLY_IREL in static pie mode i at maskray dot me 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
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).