如何调试链接特定版本共享库的程序?

How can I debug program linking specific version of shared library?

helloworld.c:

int main(){}

[1] 9845 非法硬件指令(核心已转储)LD_PRELOAD=./libc.so.6 ./helloworld

这个预加载的 libc 是旧版本的 glibc

我可以在我的系统上调试链接它的 helloworld 吗?

或者是否有快速部署具有特定版本共享库的虚拟机的方法?

  • 从你的 post 我可以看到 POC 转储核心。因此,最好使用 gdb 来分析核心转储并查看崩溃的调用堆栈。确保在分析 coredump 时在 gdb 中加载正确的 libc。
  • 否则在调用 POC 之前使用 LD_DEBUG=all 并通过在运行时查看详细信息来查看是否有任何指向崩溃的指针。

Can I debug helloworld linking it on my system?

是的,但你需要正确地做。 This answer 提供了详细信息,并解释了为什么您的 LD_PRELOAD 不起作用。