检查共享库是否与二进制文件兼容?

Check if shared libraries are compatible with a binary?

背景:我有一个大型项目,它链接了数十个共享库,这些共享库来自外部资源和我们自己的项目。在交付新软件版本之前,我通常会 make clean all 并推出项目附带的所有可执行文件和共享库。

现在有时客户更喜欢只发送一个可执行文件,例如对于热修复,因为他们的规定要求在更改库时测试所有受影响的功能,这意味着一切。

问题: 确定可执行文件是否与一组共享库兼容的最简单方法是什么?


编辑:我目前的方法是 "If the headers of the libs have not changed it will be compatible",但这是一种容易出错的方法,我宁愿检查可执行文件和库本身。

libabigail project contains tools for checking binary compatibility, and Binary compatibility issues with C++ 是一套很好的规则。

尝试abi-compliance-checker。它是检查库版本的二进制兼容性的工具。自 2009 年开始开发。

如果你在某个地方有你的库的调试信息,那么你也可以尝试 abi-dumper:

# Create ABI dumps from debug info
abi-dumper libSample-1.0.so.debug -o ABI-1.0.dump
abi-dumper libSample-2.0.so.debug -o ABI-2.0.dump

# Compare ABI dumps
abi-compliance-checker -l libSample -old ABI-1.0.dump -new ABI-2.0.dump