【问题标题】:NM linux command output meaningNM linux命令输出含义
【发布时间】:2017-06-09 14:39:14
【问题描述】:
我正在我的库中搜索特定符号:
nm --undefined-only -A libcpprest.a | grep "error_category"
我得到:
libcpprest.a:json.cpp.o: U _ZNSt14error_categoryC2Ev
libcpprest.a:json.cpp.o: U _ZNSt14error_categoryD2Ev
libcpprest.a:json.cpp.o: U _ZTISt14error_category
“_ZNSt14”和“C2Ev”是什么意思?
有没有办法清理 nm 输出?
【问题讨论】:
标签:
linux
static-libraries
symbols
static-linking
nm
【解决方案1】:
C++ 编译器执行name mangling 以支持函数重载等功能(多次使用具有不同签名的相同函数名,接受不同参数)。不同的编译器可能会使用不同的命名约定。
您可以使用c++filt 实用程序将名称分解为更易读的形式。在你的情况下:
> c++filt -n _ZNSt14error_categoryC2Ev
std::error_category::error_category()
> c++filt -n _ZNSt14error_categoryD2Ev
std::error_category::~error_category()
> c++filt -n _ZTISt14error_category
typeinfo for std::error_category
这是包含名称“error_category”的 3 个不同符号:构造函数、析构函数和类型信息。