[PATCH 2.43] csu: Include dl-symbol-redir-ifunc.h in libc-start.c (BZ 34744)
Fernando Sanchez
fernando.sanchez@chainguard.dev
Tue Oct 13 16:17:42 GMT 2026
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
1c9988e525 ("rtld: cache cpuid results on the stack for intel") adds
struct intel_cpuid_cache (276 bytes) to the stack in dl_init_cacheinfo.
With -ftrivial-auto-var-init=zero (here enabled by gcc -fhardened), gcc
zeroes it with a call to memset. In static PIE, init_cpu_features runs
from __libc_start_main before IRELATIVE relocations are applied, so the
call goes through the unresolved memset PLT slot and faults. Any
static-pie program linked against a glibc built this way crashes at
startup on Intel CPUs, including elf/ldconfig.
On master, csu/libc-start.c includes dl-symbol-redir-ifunc.h since
6adb7400fd ("aarch64: Fix static PIE CPU feature detection (BZ 34205)"),
which maps memset to the baseline implementation. This is the
csu/libc-start.c hunk of that commit; the rest of 6adb7400fd does not
apply to release/2.43/master.
Signed-off-by: Fernando Sanchez <fernando.sanchez@chainguard.dev>
(cherry picked from commit 6adb7400fd9de486b5fb3db799c9fabee1ab5786)
---
Tested on x86_64 (Intel Xeon Platinum 8581C), gcc 16.2 with -fhardened
on by default, binutils 2.47, configured with --enable-bind-now
--enable-cet --enable-stack-protector=strong:
- without the patch: elf/ldconfig crashes at startup, and in our CI
builds of the branch gmon/tst-gmon-static-pie segfaults
- with the patch: ldconfig exits 0, the memset call in
init_cpu_features binds to __memset_sse2_unaligned, and
gmon/tst-gmon-static-pie passes; the 53 remaining FAILs also fail in
our 2.44 x86_64 build in the same environment
df83fa8813 was also backported to release/2.40, 2.41 and 2.42
(cb21f7144e, 30164ba504, 5492954033), and none of them include
dl-symbol-redir-ifunc.h in csu/libc-start.c. This patch applies to all
three. I have built and tested it only on 2.43.
csu/libc-start.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/csu/libc-start.c b/csu/libc-start.c
index 1c58561bce..6e7f6b7054 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -59,6 +59,7 @@ uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
#ifndef SHARED
# include <link.h>
# include <dl-irel.h>
+# include <dl-symbol-redir-ifunc.h>
# ifdef ELF_MACHINE_IRELA
# define IREL_T ElfW(Rela)
--
2.54.0 (Apple Git-157)
More information about the Libc-stable
mailing list