[PATCH 48/59] elf: Fix localplt issue with clang
Adhemerval Zanella
adhemerval.zanella@linaro.org
Fri Oct 17 19:13:23 GMT 2025
Recent clang version optimizes some loops contructions to strlen [1],
so adds the symbol on symbol-hacks.h to call the internal __GI_strlen.
[1] https://github.com/llvm/llvm-project/pull/132572/commits/facd7dfc80d655fe49baf4bf27e144a4c890a149
---
sysdeps/generic/symbol-hacks.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
index 1115e4c0a7..e16627f046 100644
--- a/sysdeps/generic/symbol-hacks.h
+++ b/sysdeps/generic/symbol-hacks.h
@@ -6,6 +6,15 @@ asm ("memmove = __GI_memmove");
asm ("memset = __GI_memset");
asm ("memcpy = __GI_memcpy");
+#ifdef __clang__
+/* 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");
+#endif
+
/* 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.
--
2.43.0
More information about the Libc-alpha
mailing list