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

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).