Skip to content

Instantly share code, notes, and snippets.

@stefan1wan
Last active July 26, 2019 10:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefan1wan/82a972f2ce0ab4f5898f2b236d59779f to your computer and use it in GitHub Desktop.
Save stefan1wan/82a972f2ce0ab4f5898f2b236d59779f to your computer and use it in GitHub Desktop.
调试libc

调试libc

寻找build-id相同,相应dgb版本的libc:

下载并解压

wget https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/ppa/+build/14520669/+files/libc6-dbg_2.27-0ubuntu3_amd64.deb
sudo dpkg -x libc6-dbg_2.26-0ubuntu2.1_amd64.deb .

查看信息

ld和libc等动态库可以在如下文件夹中找到: ./usr/lib/debug/lib/x86_64-linux-gnu

file ./usr/lib/debug/lib/x86_64-linux-gnu/libc-2.26.so
信息如下,注意
libc-2.26.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter *empty*, BuildID[sha1]=<b>dd</b>cc13122ddbfe5e5ef77d4ebe66d124ae5762c2, for GNU/Linux 3.2.0, with debug_info, not stripped

系统的build-id在/usr/lib/debug/.build-id中,gdb会优先从中寻找调试信息.

sudo mkdir dd
cd ..
cp (刚刚的路径)cc13122ddbfe5e5ef77d4ebe66d124ae5762c2 .

重启gdb,就可以看libc中中的符号了

@stefan1wan
Copy link
Author

感谢******的wzh学长

@msjyryxdzzj
Copy link

感谢******的elnx学长

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment