[libcxx-commits] [libcxx] [libcxx] Use local names for the operator new impl symbols (PR #122983)

Petr Hosek via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 14 15:55:06 PST 2025


https://github.com/petrhosek updated https://github.com/llvm/llvm-project/pull/122983

>From 6c665275b6b94b9ea29cc75df53ce84ed28d019d Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 14 Jan 2025 14:47:47 -0800
Subject: [PATCH 1/2] [libcxx] Use local names for the operator new impl
 symbols

This way the impl symbols don't even make it into the symbol table which
is important for symbolization since we want the symbolizer to always
pick up the public symbol (which has the same address as the impl one).
---
 libcxx/src/include/overridable_function.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/src/include/overridable_function.h b/libcxx/src/include/overridable_function.h
index 7372e347831bb4..71feebf0c15b20 100644
--- a/libcxx/src/include/overridable_function.h
+++ b/libcxx/src/include/overridable_function.h
@@ -90,8 +90,8 @@ _LIBCPP_END_NAMESPACE_STD
 
 #  define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1
 #  define _LIBCPP_OVERRIDABLE_FUNCTION(symbol, type, name, arglist)                                                    \
-    static type symbol##_impl__ arglist __asm__(_LIBCPP_TOSTRING(symbol##_impl__));                                    \
-    [[gnu::weak, gnu::alias(_LIBCPP_TOSTRING(symbol##_impl__))]] type name arglist;                                    \
+    static type symbol##_impl__ arglist __asm__(".L" _LIBCPP_TOSTRING(symbol));                                        \
+    [[gnu::weak, gnu::alias(".L" _LIBCPP_TOSTRING(symbol))]] type name arglist;                                        \
     _LIBCPP_BEGIN_NAMESPACE_STD                                                                                        \
     template <>                                                                                                        \
     inline bool __is_function_overridden<static_cast<type(*) arglist>(name)>() {                                       \

>From 00ec430c5e0c153a952a783e614f321fe12ef449 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 14 Jan 2025 15:54:28 -0800
Subject: [PATCH 2/2] Make the impl symbols non-static

This avoids the issue with -funique-internal-linkage-names.
---
 libcxx/src/include/overridable_function.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/src/include/overridable_function.h b/libcxx/src/include/overridable_function.h
index 71feebf0c15b20..0258432a9ac69f 100644
--- a/libcxx/src/include/overridable_function.h
+++ b/libcxx/src/include/overridable_function.h
@@ -90,7 +90,7 @@ _LIBCPP_END_NAMESPACE_STD
 
 #  define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1
 #  define _LIBCPP_OVERRIDABLE_FUNCTION(symbol, type, name, arglist)                                                    \
-    static type symbol##_impl__ arglist __asm__(".L" _LIBCPP_TOSTRING(symbol));                                        \
+    type symbol##_impl__ arglist __asm__(".L" _LIBCPP_TOSTRING(symbol));                                               \
     [[gnu::weak, gnu::alias(".L" _LIBCPP_TOSTRING(symbol))]] type name arglist;                                        \
     _LIBCPP_BEGIN_NAMESPACE_STD                                                                                        \
     template <>                                                                                                        \
@@ -98,7 +98,7 @@ _LIBCPP_END_NAMESPACE_STD
       return static_cast<type(*) arglist>(name) != symbol##_impl__;                                                    \
     }                                                                                                                  \
     _LIBCPP_END_NAMESPACE_STD                                                                                          \
-    static type symbol##_impl__ arglist
+    type symbol##_impl__ arglist
 
 #else
 



More information about the libcxx-commits mailing list