https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101010
Bug ID: 101010 Summary: Feature request: add builtins to provide mangled symbols, optionally with a prefix Product: gcc Version: 11.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hedayat.fwd at gmail dot com Target Milestone: --- Currently, there is no method to generate mangled symbol as an string or as a symbol. A mangled symbol as string is useful in many cases for GCC itself, e.g. to use with alias or ifunc attributes. Currently, you should find the mangled name yourself and use it there, which is both inconvenient and also might change in future (or it might be even different for example when compiled with mingw). Having a mangled symbol with a prefix (not as a string), is useful when using the '--wrap' option to ld, to generate __real_SYMBOL and __wrap_SYMBOLs. Actually, I'm more interested in this one, but found that the former one (mangled name as string) is also useful. Sample intended usage: void __builtin_mangled_symbol(__wrap_, &MyClass::member)(MyClass *mc_this, int a) { if (call_real) __builtin_mangled_symbol(__real_, &MyClass::member)(mc_this, a); else {...} }