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?
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.
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.
(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.
(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
Closing this as a duplicate of 27164 (filed in January by Fangrui). *** This bug has been marked as a duplicate of bug 27164 ***