[PATCH 55/59] Handle abort call for -fexceptions call

Adhemerval Zanella adhemerval.zanella@linaro.org
Mon Oct 20 12:27:52 GMT 2025


clang might generate an abort call when cleanup functions (set by
__attribute__ ((cleanup)) calls functions not marked as nothrow.
We can mitigate by marking some internal functions as __THROW,
but it is not possible for functions that issue used-provided
callbacks (for instance pthread_once).
---
 elf/Makefile                   | 5 +++++
 sysdeps/generic/symbol-hacks.h | 7 +++++++
 sysdeps/nptl/lowlevellock.h    | 4 ++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/elf/Makefile b/elf/Makefile
index dd21fe62411..73ceba84e05 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1495,6 +1495,11 @@ rtld-stubbed-symbols += \
   __GI___vsyslog_chk \
   # rtld-stubbed-symbols
 
+# clang might generate an abort call for cleanup functions.
+rtld-stubbed-symbols += \
+  __GI_abort \
+  # rtld-stubbed-symbols
+
 ifeq ($(have-ssp),yes)
 # rtld is not built with the stack protector, so these references will
 # go away in the rebuilds.
diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
index 09359f33e6a..e4b6816240c 100644
--- a/sysdeps/generic/symbol-hacks.h
+++ b/sysdeps/generic/symbol-hacks.h
@@ -30,6 +30,13 @@ asm ("strcpy = __GI_strcpy");
 asm ("strncpy = __GI_strncpy");
 asm ("strcat = __GI_strcat");
 
+/* clang might generate an abort call when cleanup functions (set by
+   __attribute__ ((cleanup)) calls functions not marked as nothrow.
+   We can mitigate by marking some internal functions as __THROW,
+   but it is not possible for functions that issue used-provided
+   callbacks (for instance pthread_once).  */
+asm ("abort = __GI_abort");
+
 /* Some targets do not use __stack_chk_fail_local.  In libc.so,
    redirect __stack_chk_fail to a hidden reference
    __stack_chk_fail_local, to avoid the PLT reference.
diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h
index 393763f1933..d2af04b11f5 100644
--- a/sysdeps/nptl/lowlevellock.h
+++ b/sysdeps/nptl/lowlevellock.h
@@ -125,9 +125,9 @@ libc_hidden_proto (__lll_lock_wait)
 #define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
 
 
-extern void __lll_lock_wake_private (int *futex);
+extern void __lll_lock_wake_private (int *futex) __THROW;
 libc_hidden_proto (__lll_lock_wake_private)
-extern void __lll_lock_wake (int *futex, int private);
+extern void __lll_lock_wake (int *futex, int private) __THROW;
 libc_hidden_proto (__lll_lock_wake)
 
 /* This is an expression rather than a statement even though its value is
-- 
2.43.0



More information about the Libc-alpha mailing list