Skip to content

Instantly share code, notes, and snippets.

@nbulischeck
Last active January 16, 2024 12:06
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save nbulischeck/bda4397a59b77822703f98f6aeb2cb20 to your computer and use it in GitHub Desktop.
Save nbulischeck/bda4397a59b77822703f98f6aeb2cb20 to your computer and use it in GitHub Desktop.
Install glibc debug symbols on Arch Linux for pwndbg heap analysis
#!/bin/bash
# Install Dependencies
sudo pacman -S git svn gd lib32-gcc-libs patch make bison fakeroot
# Checkout glibc source
svn checkout --depth=empty svn://svn.archlinux.org/packages
cd packages
svn update glibc
cd glibc/repos/core-x86_64
# Add current locale to locale.gen.txt
grep -v "#" /etc/locale.gen >> locale.gen.txt
# Enable debug build in PKGBUILD
sed -i 's#!strip#debug#' PKGBUILD
# Build glibc and glibc-debug packages
makepkg --skipchecksums
# Install glibc-debug
sudo pacman -U *.pkg.tar.xz
sed '/^OPTIONS/ s/!debug/debug/g; /^OPTIONS/ s/strip/!strip/g' /etc/makepkg.conf
sudo pacman -S gdb pwndbg
echo "Don't forget to add `source /usr/share/pwndbg/gdbinit.py` to your ~/.gdbinit"
@kriive
Copy link

kriive commented Sep 21, 2022

Arch Linux's libc symbols are available through debuginfod now.
To enable it in gdb add set debuginfod enabled on to your .gdbinit file. Now the heap and vis commands should work out of the box, without needing to recompile the debug symbols for each update of the GLIBC.

@MUWASEC
Copy link

MUWASEC commented Sep 22, 2022

Arch Linux's libc symbols are available through debuginfod now. To enable it in gdb add set debuginfod enabled on to your .gdbinit file. Now the heap and vis commands should work out of the box, without needing to recompile the debug symbols for each update of the GLIBC.

are you sure ? just test it out heap and vis command from pwndbg it's not working, i even update the pwndbg repo but still need libc debug symbols, here is the proof image https://ibb.co/PzVd54L

@kriive
Copy link

kriive commented Sep 22, 2022

Have you installed debuginfod? A reboot or re-login cycle may be required in order to make it work.

@komugi64
Copy link

Yes you have to log out and in again for the environment variables to get updated. Thanks for the tip, I didn't even know debuginfod existed

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