[PATCH] csu: Skip ARCH_SETUP_IREL if _dl_relocate_static_pie applied IRELATIVE relocations [BZ #27164]

Carlos O'Donell carlos@redhat.com
Mon Jul 12 14:08:05 GMT 2021


On 7/8/21 6:10 PM, Fangrui Song wrote:
> From: Siva Chandra Reddy <sivachandra@google.com>
> 
> For a static pie, _dl_relocate_static_pie applies IRELATIVE relocations
> so ARCH_SETUP_IREL should not apply relocations again. The code
> currently relies on ld -pie not defining
> __rela_iplt_start/__rela_iplt_end (they end up as 0 as unresolved
> undefined weak symbols).

Correct, this is how PIE and static PIE were designed by HJ.
 
> However, LLD defines __rela_iplt_start/__rela_iplt_end regardless of
> -no-pie or -pie, so in an LLD linked static pie, ARCH_SETUP_IREL would
> re-apply the relocations in the range of [__rela_iplt_start,
> __rela_iplt_end), causing a segfault.

The reason this issue has been raised is that our joint downstream
users are unable to use lld on existing systems to compile and test
static PIE binaries.

Ryan Houdek raised it on IRC, and I asked them to file a bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=28066

The average downstream users may take anywhere from 12-18 months to
get a new glibc in their systems.

If lld were to make the change today that would enable all downstream
users to be able to use lld to compile static PIE without needing to
get an updated glibc.

>From such a perspective the lld change to match binutils enables the
feature for the most number of users the fastest.

> Change _dl_relocate_static_pie to return an int, indicating whether the
> relocations have been applied. This makes the intention clearer and
> makes glibc buildable with LLD>=9.0 if we allow LLD at configure time.
> 
> In addition, this enables a future simplification to GNU ld: we can drop
> a linker script difference between -no-pie and -pie.
> 
> Co-authored-by: Fangrui Song <maskray@google.com>

I'm not inclined to accept this path. Not because I think the patch is
technically wrong, but because fixing lld enables it immediately for the
most number of users (making the patch moot).

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list