[PATCH v3 16/19] Filter out internal abort during ld.so build

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Oct 31 20:00:49 GMT 2025


clang might generate an abort call when cleanup functions (set by
__attribute__ ((cleanup)) calls functions not marked as nothrow.

The hurd already provides abort for the loader at
sysdeps/mach/hurd/dl-sysdep.c, and adding it rtld-stubbed-symbols
triggers duplicate symbols.
---
 configure                      | 4 ++++
 configure.ac                   | 3 +++
 elf/Makefile                   | 7 +++++++
 sysdeps/mach/hurd/configure    | 2 ++
 sysdeps/mach/hurd/configure.ac | 2 ++
 5 files changed, 18 insertions(+)

diff --git a/configure b/configure
index c2e33a5c9f1..086791356a8 100755
--- a/configure
+++ b/configure
@@ -8915,6 +8915,7 @@ libc_cv_localstatedir=$localstatedir
 libc_cv_gcc_unwind_find_fde=no
 libc_cv_idn=no
 pthread_in_libc=yes
+abort_in_ld=no
 
 # Iterate over all the sysdep directories we will use, running their
 # configure fragments.
@@ -9497,6 +9498,9 @@ if test "$libc_cv_attr_after_func_decl" = yes; then
 
 fi
 
+config_vars="$config_vars
+abort-in-ld = $abort_in_ld";
+
 ac_config_files="$ac_config_files config.make Makefile"
 
 ac_config_commands="$ac_config_commands default"
diff --git a/configure.ac b/configure.ac
index 1150ce9aac7..663eca3caa3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1916,6 +1916,7 @@ libc_cv_localstatedir=$localstatedir
 libc_cv_gcc_unwind_find_fde=no
 libc_cv_idn=no
 pthread_in_libc=yes
+abort_in_ld=no
 
 # Iterate over all the sysdep directories we will use, running their
 # configure fragments.
@@ -2201,6 +2202,8 @@ if test "$libc_cv_attr_after_func_decl" = yes; then
    AC_DEFINE(ATTR_AFTER_FUNC_DECL)
 fi
 
+LIBC_CONFIG_VAR([abort-in-ld],[$abort_in_ld]);
+
 AC_CONFIG_FILES([config.make Makefile])
 AC_CONFIG_COMMANDS([default],[[
 case $CONFIG_FILES in *config.make*)
diff --git a/elf/Makefile b/elf/Makefile
index dd21fe62411..e95747c7950 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1495,6 +1495,13 @@ rtld-stubbed-symbols += \
   __GI___vsyslog_chk \
   # rtld-stubbed-symbols
 
+ifeq (no,$(abort-in-ld))
+# clang might generate an abort call for cleanup functions.
+rtld-stubbed-symbols += \
+  __GI_abort \
+  # rtld-stubbed-symbols
+endif
+
 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/mach/hurd/configure b/sysdeps/mach/hurd/configure
index 6ca3bab5112..743bad5fcba 100644
--- a/sysdeps/mach/hurd/configure
+++ b/sysdeps/mach/hurd/configure
@@ -220,4 +220,6 @@ fi
 
 # Hurd has libpthread as a separate library.
 pthread_in_libc=no
+# Hurd already provides abort implementation for the loader
+abort_in_ld=yes
 
diff --git a/sysdeps/mach/hurd/configure.ac b/sysdeps/mach/hurd/configure.ac
index 1695e94eccb..6d33feed0e7 100644
--- a/sysdeps/mach/hurd/configure.ac
+++ b/sysdeps/mach/hurd/configure.ac
@@ -48,3 +48,5 @@ fi
 
 # Hurd has libpthread as a separate library.
 pthread_in_libc=no
+# Hurd already provides abort implementation for the loader
+abort_in_ld=yes
-- 
2.43.0



More information about the Libc-alpha mailing list