- Example.cc:测试程序
- Example.s:使用
g++ -S
编译后的汇编文件
- 观察函数名,发现似乎函数名经过了某种编码
void Test::func_1()
:_ZN4Test6func_1Ev
static std::string func_2(int in_a)
:消失
Test* Test::func_3(double in_b)
:_ZN4Test6func_3Ed
int test_2(std::string in_c, uint16_t in_d)
:_Z6test_2NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEt
- 原因:mangle
- 因为C++可以函数重载和重写引入的功能
- 本质就是对函数的命名空间(比如哪个类或者哪个namespace)、函数名、函数参数进行编码
- 可以被解码
- 不同编译器编码规则不同,一般以g++为例
- 解码:demangle
- 使用工具 c++filt
- 包含在binutils软件包中