name-mangling

MSVC C++ Name Mangling From String On Runtime

六月ゝ 毕业季﹏ 提交于 2021-01-28 05:41:02
问题 First i will start with the reason i need name mangling on runtime. I need to create a bridge between dll and its wrapper namespace Wrapper { class __declspec(dllexport) Token { public: virtual void release() {} }; } class __declspec(dllexport) Token { public: virtual void release(){} }; The idea is to use dumpin to generate all the mangled names of the dll holding class token and than demangled them. ?release@Token@@UAEXXZ --> void Token::release(void) after that i want to convert is to

Why name-mangling has no effect on main function in C++?

随声附和 提交于 2021-01-27 05:35:14
问题 C++ compiler often mangle function names to support many features. Programer can suppress default name-mangling using extern "C" way. However, why int main(int, char **) not affected ever? // test.cpp int max(int a, int b) { return a > b ? a : b; } extern "C" { int min(int a, int b) { return a < b ? a : b; } } int main (int argc, char *argv[]) { return 0; } And $ xcrun --sdk macosx clang -x c++ -c test.cpp -o test $ xcrun nm -nm test 0000000000000000 (__TEXT,__text) external __Z3maxii

Why name-mangling has no effect on main function in C++?

巧了我就是萌 提交于 2021-01-27 05:35:10
问题 C++ compiler often mangle function names to support many features. Programer can suppress default name-mangling using extern "C" way. However, why int main(int, char **) not affected ever? // test.cpp int max(int a, int b) { return a > b ? a : b; } extern "C" { int min(int a, int b) { return a < b ? a : b; } } int main (int argc, char *argv[]) { return 0; } And $ xcrun --sdk macosx clang -x c++ -c test.cpp -o test $ xcrun nm -nm test 0000000000000000 (__TEXT,__text) external __Z3maxii

x64 DLL export function names

[亡魂溺海] 提交于 2021-01-20 15:15:26
问题 I am trying to port a 32-bit dll (and application) to 64-bit and I have managed to build it without errors. When trying to load it with my 64-bit application I noticed that the exported function names differ. This is how I export the functions: #ifdef __cplusplus extern "C" { #endif __declspec(dllexport) long __stdcall Connect(char * name, long size); #ifdef __cplusplus } #endif In Dependency Walker the exported functions have the following format: 32-bit: _Connect@8 64-bit: Connect In the

What does '_GLOBAL__sub_I_' mean in nm output?

雨燕双飞 提交于 2020-05-12 11:16:29
问题 While I was trying to resolve a problem in static linking, I encounter a couple of _GLOBAL__sub_I_ prefixes in front of symbol names. It appears in that form although I used nm --demangle(-C) . I stumbled upon this answer (How to find global static initializations). Looking at my source code, it indeed looks like initialization of a global static variable. What I'm wondering is, where can I more information on __sub_ and other mangled names, like __cxxabiv1 ? 回答1: To prevent link rot i will

writing c++ code in extern c

限于喜欢 提交于 2020-04-07 03:51:27
问题 I'm trying to implement an external c++ header interface that will be produced as a shared library. Their example interface has c style functionality wrapped in extern "C" as they don't want name mangling to be performed. My current implementation is qt dependent. Can I now place this qt code in the extern "C" and expect it to work out of the box? If this works why? pseudo code: // don't expect this to work and might contain errors. extern "C"{ void doStuff(){ QString filename="Data.txt";

Finding arguments that go with methods in C++ dll's

眉间皱痕 提交于 2020-01-29 07:13:32
问题 Ok, so I can use dumpbin.exe /exports library.dll to find all methods in the dll. ...but how do I find out which arguments to pass into them? Without a header file of course. 回答1: For the usual C-style exports (e.g., Windows API DLLs): You can't. This information is not stored in the DLL and is inevitably lost after compilation (unless you have the headers or debuging symbols). C++ exports, on the other hand, store their signature as part of the mangled function name and you can view them

Finding arguments that go with methods in C++ dll's

大兔子大兔子 提交于 2020-01-29 07:13:09
问题 Ok, so I can use dumpbin.exe /exports library.dll to find all methods in the dll. ...but how do I find out which arguments to pass into them? Without a header file of course. 回答1: For the usual C-style exports (e.g., Windows API DLLs): You can't. This information is not stored in the DLL and is inevitably lost after compilation (unless you have the headers or debuging symbols). C++ exports, on the other hand, store their signature as part of the mangled function name and you can view them

C++ : Finding out decorated names

冷暖自知 提交于 2020-01-02 05:42:06
问题 How can I find out the decorated name that will be asigned to each method name ? I'm trying to find out what the decorated name is , so that I may export it , in a DLL . 回答1: .DEF file are still being used? Forget .DEF files. They are a thing of the past. Export your functions, be them C functions or C++ symbols, through __declspec(dllimport/dllexport). If you really need undecorated names, use as suggested by Greg Hewgill, the __declspec(dllimport/dllexport) keywords, combined with extern "C

How can I see symbols of (C and C++) binary on linux?

ぐ巨炮叔叔 提交于 2019-12-31 08:05:34
问题 Which tools do you guys use? How do demangle c++ symbols do be able to pass it to profiler tools, such as opannotate? Thanks 回答1: Use nm to see all symbols and c++filt to demangle. Example: nm -an foo | c++filt 回答2: The profiling tool I use already knows the symbols and source code, since it is just the debugger. I can build the app with symbols included, even with full optimization. 来源: https://stackoverflow.com/questions/1379533/how-can-i-see-symbols-of-c-and-c-binary-on-linux