【问题标题】:How to compare nm outputs如何比较 nm 输出
【发布时间】:2016-05-15 04:13:10
【问题描述】:

我有 2 个目标文件,它们应该是相似的,因为它们来自同一代码库的 2 个不同编译时间。我想比较他们的 nm 输出。但是我不能,因为有很多名字修饰。由于名称修改结果似乎不同,但实际上并非如此。我尝试了以下步骤来帮助我比较

1) took last word using command
sed '/ /s/.* //' nmfile1 >nmfile1_lastword

2) removed _Z.. starting word with nothing 
sed 's/^_Z...//' nmfile1_lastword > nmfile1_lastword_removed_z

3) sorted the same 
sort nmfile1_lastword_removed_z > nmfile1_lastword_removed_z_sorted

我也为第二个 nmFile2 做了上述操作。

但是,开始时仍然有很多名称修改,我无法删除,这让我认为没有简单的方法来比较 nm 输出。请注意,我只关心起始名称的修改,因为我可以在 gvim -d 中看到结果,并且我可以手动识别差异。如果有一些直接的工具那就最好了。

请注意,我尝试使用带有选项 -C 的 nm 来显示没有 name Mangling 但它仍然显示很多 name mangling 。

【问题讨论】:

    标签: c++ linux g++ nm


    【解决方案1】:

    使用 c++filt 将符号分解为

    nm xxx.so | c++filt > compare1.txt
    nm xxx.so | c++filt > compare2.txt
    

    【讨论】:

    • 什么平台?可以访问示例二进制文件吗?
    • 抱歉无法共享二进制文件。我正在使用带有 g++ 的 linux。操作系统规格是: 分销商 ID:RedHatEnterpriseClient 描述:Red Hat Enterprise Linux 客户端版本 5.10 版本:5.10
    • 好的,你能传递一个未被 c++ 文件处理的 mangle 字符串,例如 $c++filt ZNK3MapI10StringName3RefI8GDScriptE10ComparatorIS0_E16DefaultAllocatorE3hasERKS0
    • 看起来您使用的 nm 版本有错误。快速解决方案是在最新工具 (nm) 上对您的二进制文件进行解构。供参考sourcery.mentor.com/archives/cxx-abi-dev/msg02295.html
    猜你喜欢
    • 2016-08-13
    • 1970-01-01
    • 1970-01-01
    • 2013-12-23
    • 2012-09-18
    • 2017-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多