public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug dynamic-link/28066] New: Using static-pie and lld results in runtime crash
@ 2021-07-08 18:46 Houdek.Ryan@fex-emu.org
  2021-07-08 19:09 ` [Bug dynamic-link/28066] " carlos at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Houdek.Ryan@fex-emu.org @ 2021-07-08 18:46 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28066

            Bug ID: 28066
           Summary: Using static-pie and lld results in runtime crash
           Product: glibc
           Version: 2.33
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: Houdek.Ryan@fex-emu.org
                CC: maskray at google dot com
  Target Milestone: ---

Due to how IRELATIVE sections are emitted in to a static-pie elf with LLD.
glibc will crash early in the application boot process.

This ML post had some information on it:
https://sourceware.org/pipermail/libc-alpha/2021-January/121752.html

This patch resolves the compilation crash locally:
https://sourceware.org/git/?p=glibc.git;a=commit;h=c67127a88540f6de4b92370158b5da61bec23f4f

For some more context inside of the bug report. ARCH_SETUP_IREL() attempts
setting up IRELATIVE sections but crashes in this instance. This is seemingly a
difference between lld and ld about these sections being emitted or not and
glibc handling only one case?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug dynamic-link/28066] Using static-pie and lld results in runtime crash
  2021-07-08 18:46 [Bug dynamic-link/28066] New: Using static-pie and lld results in runtime crash Houdek.Ryan@fex-emu.org
@ 2021-07-08 19:09 ` carlos at redhat dot com
  2021-07-08 20:31 ` i at maskray dot me
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: carlos at redhat dot com @ 2021-07-08 19:09 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28066

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com

--- Comment #1 from Carlos O'Donell <carlos at redhat dot com> ---
H.J.'s initial position appears to be that this is a bug in lld and that it
should not emit __rela_iplt_start/__rela_iplt_end for PIE:

https://sourceware.org/pipermail/libc-alpha/2021-January/121755.html

Given that upstream glibc is unable to run such binaries it's hard to argue
that we need to include such compat code.

I'm curious to hear Fangrui's comments on this issue and what direction lld is
considering.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug dynamic-link/28066] Using static-pie and lld results in runtime crash
  2021-07-08 18:46 [Bug dynamic-link/28066] New: Using static-pie and lld results in runtime crash Houdek.Ryan@fex-emu.org
  2021-07-08 19:09 ` [Bug dynamic-link/28066] " carlos at redhat dot com
@ 2021-07-08 20:31 ` i at maskray dot me
  2021-07-08 21:40 ` carlos at redhat dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: i at maskray dot me @ 2021-07-08 20:31 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28066

Fangrui Song <i at maskray dot me> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |i at maskray dot me

--- Comment #2 from Fangrui Song <i at maskray dot me> ---
H.J. Lu and I did not reach a consensus in January.

I think ld.lld defining __rela_iplt_start in -pie mode is a conscious and good
decision.
Taking "csu: Skip ARCH_SETUP_IREL if _dl_relocate_static_pie applied IRELATIVE
relocations" have
two benefits:

* improve readability of the glibc ld.so code
* enable removing a -pie and -no-pie difference in GNU ld

The current code relies on ARCH_SETUP_IREL doing nothing in static-pie mode
(__rela_iplt_start = __rela_iplt_end = 0 (as undefined weak symbols))
but doing something in static no-pie mode.
This is less clear than making the intention explicit in the code:

-  _dl_relocate_static_pie ();
+  int irel_applied = _dl_relocate_static_pie ();

   /* Perform IREL{,A} relocations.  */
-  ARCH_SETUP_IREL ();
+  if (!irel_applied)
+    ARCH_SETUP_IREL ();

Second, if you run `diff =(ld.bfd --verbose) =(ld.bfd --verbose -pie)`, other
than the image base difference,
whether __rela_iplt_start/__rela_iplt_end are defined is the only other
difference.

Defining __rela_iplt_start/__rela_iplt_end in -pie mode can drop this
difference.
In a few years, when the glibc's requirement on GNU ld raises, we can make the
cleanup into GNU ld.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug dynamic-link/28066] Using static-pie and lld results in runtime crash
  2021-07-08 18:46 [Bug dynamic-link/28066] New: Using static-pie and lld results in runtime crash Houdek.Ryan@fex-emu.org
  2021-07-08 19:09 ` [Bug dynamic-link/28066] " carlos at redhat dot com
  2021-07-08 20:31 ` i at maskray dot me
@ 2021-07-08 21:40 ` carlos at redhat dot com
  2021-07-08 22:13 ` i at maskray dot me
  2021-07-09  5:11 ` carlos at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: carlos at redhat dot com @ 2021-07-08 21:40 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28066

--- Comment #3 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Fangrui Song from comment #2)
> Taking "csu: Skip ARCH_SETUP_IREL if _dl_relocate_static_pie applied
> IRELATIVE relocations"

Would you please submit this as an official patch to libc-alpha? That way I can
discuss and review in the next Monday morning patchwork patch queue review
(2021-07-12).

Even though you and HJ did not achieve consensus, the patch as-is is
functionally no different than the existing code. The existing code depends on
specific expectations of the binary artifact which could vary over time, and
it's more robust to be explicit in the steps and operations taken.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug dynamic-link/28066] Using static-pie and lld results in runtime crash
  2021-07-08 18:46 [Bug dynamic-link/28066] New: Using static-pie and lld results in runtime crash Houdek.Ryan@fex-emu.org
                   ` (2 preceding siblings ...)
  2021-07-08 21:40 ` carlos at redhat dot com
@ 2021-07-08 22:13 ` i at maskray dot me
  2021-07-09  5:11 ` carlos at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: i at maskray dot me @ 2021-07-08 22:13 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28066

--- Comment #4 from Fangrui Song <i at maskray dot me> ---
(In reply to Carlos O'Donell from comment #3)
> (In reply to Fangrui Song from comment #2)
> > Taking "csu: Skip ARCH_SETUP_IREL if _dl_relocate_static_pie applied
> > IRELATIVE relocations"
> 
> Would you please submit this as an official patch to libc-alpha? That way I
> can discuss and review in the next Monday morning patchwork patch queue
> review (2021-07-12).
> 
> Even though you and HJ did not achieve consensus, the patch as-is is
> functionally no different than the existing code. The existing code depends
> on specific expectations of the binary artifact which could vary over time,
> and it's more robust to be explicit in the steps and operations taken.

Thanks:) Sent https://sourceware.org/pipermail/libc-alpha/2021-July/128810.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug dynamic-link/28066] Using static-pie and lld results in runtime crash
  2021-07-08 18:46 [Bug dynamic-link/28066] New: Using static-pie and lld results in runtime crash Houdek.Ryan@fex-emu.org
                   ` (3 preceding siblings ...)
  2021-07-08 22:13 ` i at maskray dot me
@ 2021-07-09  5:11 ` carlos at redhat dot com
  4 siblings, 0 replies; 6+ 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=28066

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #5 from Carlos O'Donell <carlos at redhat dot com> ---
Closing this as a duplicate of 27164 (filed in January by Fangrui).

*** This bug has been marked as a duplicate of bug 27164 ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-09  5:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 18:46 [Bug dynamic-link/28066] New: Using static-pie and lld results in runtime crash Houdek.Ryan@fex-emu.org
2021-07-08 19:09 ` [Bug dynamic-link/28066] " carlos at redhat dot com
2021-07-08 20:31 ` i at maskray dot me
2021-07-08 21:40 ` carlos at redhat dot com
2021-07-08 22:13 ` i at maskray dot me
2021-07-09  5:11 ` carlos at redhat dot com

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