[v8,5/6] elf: Remove __chk_fail from dl-minimal.c

Message ID 20260318193454.2466865-6-adhemerval.zanella@linaro.org (mailing list archive)
State New
Headers
Series elf: Allow RPATH/RUNPATH for static-pie |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Adhemerval Zanella Netto March 18, 2026, 7:34 p.m. UTC
  The elf/rtld-Rules adds $(no-fortify-source) on rtld object, so
__chk_fail is never used.
---
 elf/Makefile        | 1 +
 elf/dl-minimal.c    | 8 --------
 include/sys/cdefs.h | 1 -
 3 files changed, 1 insertion(+), 9 deletions(-)
  

Comments

Florian Weimer March 20, 2026, 11:09 a.m. UTC | #1
* Adhemerval Zanella:

> The elf/rtld-Rules adds $(no-fortify-source) on rtld object, so
> __chk_fail is never used.
> ---
>  elf/Makefile        | 1 +
>  elf/dl-minimal.c    | 8 --------
>  include/sys/cdefs.h | 1 -
>  3 files changed, 1 insertion(+), 9 deletions(-)

Okay.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian
  

Patch

diff --git a/elf/Makefile b/elf/Makefile
index 986ef6b388..36d2207732 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1508,6 +1508,7 @@  endif
 # These symbols might be emitted by the compiler when fortify is enabled
 # (through builtins).
 rtld-stubbed-symbols += \
+  __GI___chk_fail \
   __GI___vfprintf_chk \
   __GI___vsprintf_chk \
   __GI___vsyslog_chk \
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
index 591d49e3f5..4583c48db3 100644
--- a/elf/dl-minimal.c
+++ b/elf/dl-minimal.c
@@ -163,14 +163,6 @@  __libc_fatal (const char *message)
 }
 rtld_hidden_def (__libc_fatal)
 
-void
-__attribute__ ((noreturn))
-__chk_fail (void)
-{
-  _exit (127);
-}
-rtld_hidden_def (__chk_fail)
-
 #ifndef NDEBUG
 /* Define (weakly) our own assert failure function which doesn't use stdio.
    If we are linked into the user program (-ldl), the normal __assert_fail
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index a676f75f62..33d0a47f43 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -18,7 +18,6 @@ 
 
 extern void __chk_fail (void) __attribute__ ((__noreturn__));
 libc_hidden_proto (__chk_fail)
-rtld_hidden_proto (__chk_fail)
 
 /* If we are using redirects internally to support long double,
    we need to tweak some macros to ensure the PLT bypass tricks