Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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"
@MUWASEC
Copy link

MUWASEC commented Apr 14, 2020

is it include 32 bit glibc symbols too ?

@nbulischeck
Copy link
Author

nbulischeck commented Apr 19, 2020

@MUWASEC - this compiles for 64-bit systems, but works on 32-bit binaries as well

@MUWASEC
Copy link

MUWASEC commented Jul 31, 2021

hi, when i try to rebuild the glibc with the method above with the new version of glibc (2.33) from arch linux i got some error like below :

In file included from <command-line>:
../misc/syslog.c: In function ‘__vsyslog_internal’:
../misc/syslog.c:127:30: error: inlining failed in call to ‘always_inline’ ‘syslog’: function not inlinable
  127 | ldbl_strong_alias (__syslog, syslog)
      |                              ^~~~~~
./../include/libc-symbols.h:140:26: note: in definition of macro ‘_strong_alias’
  140 |   extern __typeof (name) aliasname __attribute__ ((alias (#name))) \
      |                          ^~~~~~~~~
../sysdeps/generic/math_ldbl_opt.h:14:44: note: in expansion of macro ‘strong_alias’
   14 | #define ldbl_strong_alias(name, aliasname) strong_alias (name, aliasname)
      |                                            ^~~~~~~~~~~~
../misc/syslog.c:127:1: note: in expansion of macro ‘ldbl_strong_alias’
  127 | ldbl_strong_alias (__syslog, syslog)
      | ^~~~~~~~~~~~~~~~~
In file included from ../sysdeps/unix/sysv/linux/syslog.c:4:
../misc/syslog.c:173:17: note: called from here
  173 |                 syslog(INTERNALLOG,
      |                 ^~~~~~~~~~~~~~~~~~~
  174 |                     "syslog: unknown facility/priority: %x", pri);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [/home/muwa00/packages/glibc/repos/core-x86_64/src/glibc-build/sysd-rules:213: /home/muwa00/packages/glibc/repos/core-x86_64/src/glibc-build/misc/syslog.o] Error 1
make[2]: Leaving directory '/home/muwa00/packages/glibc/repos/core-x86_64/src/glibc-2.33/misc'
make[1]: *** [Makefile:479: misc/subdir_lib] Error 2
make[1]: Leaving directory '/home/muwa00/packages/glibc/repos/core-x86_64/src/glibc-2.33'
make: *** [Makefile:9: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
zsh: no matches found: *.pkg.tar.xz

do you have any new workaround method for rebuild glibc on arch linux ?

@pata00
Copy link

pata00 commented Aug 17, 2021

hi, when i try to rebuild the glibc with the method above with the new version of glibc (2.33) from arch linux i got some error like below :

In file included from <command-line>:
../misc/syslog.c: In function ‘__vsyslog_internal’:
../misc/syslog.c:127:30: error: inlining failed in call to ‘always_inline’ ‘syslog’: function not inlinable
  127 | ldbl_strong_alias (__syslog, syslog)
      |                              ^~~~~~
./../include/libc-symbols.h:140:26: note: in definition of macro ‘_strong_alias’
  140 |   extern __typeof (name) aliasname __attribute__ ((alias (#name))) \
      |                          ^~~~~~~~~
../sysdeps/generic/math_ldbl_opt.h:14:44: note: in expansion of macro ‘strong_alias’
   14 | #define ldbl_strong_alias(name, aliasname) strong_alias (name, aliasname)
      |                                            ^~~~~~~~~~~~
../misc/syslog.c:127:1: note: in expansion of macro ‘ldbl_strong_alias’
  127 | ldbl_strong_alias (__syslog, syslog)
      | ^~~~~~~~~~~~~~~~~
In file included from ../sysdeps/unix/sysv/linux/syslog.c:4:
../misc/syslog.c:173:17: note: called from here
  173 |                 syslog(INTERNALLOG,
      |                 ^~~~~~~~~~~~~~~~~~~
  174 |                     "syslog: unknown facility/priority: %x", pri);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [/home/muwa00/packages/glibc/repos/core-x86_64/src/glibc-build/sysd-rules:213: /home/muwa00/packages/glibc/repos/core-x86_64/src/glibc-build/misc/syslog.o] Error 1
make[2]: Leaving directory '/home/muwa00/packages/glibc/repos/core-x86_64/src/glibc-2.33/misc'
make[1]: *** [Makefile:479: misc/subdir_lib] Error 2
make[1]: Leaving directory '/home/muwa00/packages/glibc/repos/core-x86_64/src/glibc-2.33'
make: *** [Makefile:9: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
zsh: no matches found: *.pkg.tar.xz

do you have any new workaround method for rebuild glibc on arch linux ?

aha, i met the same problem, did you slove this ?

@c0mp3r
Copy link

c0mp3r commented Oct 12, 2021

The problem is new CFLAGS in the default makepkg.conf, see this forum post.
To fix it you need to install the devtools package and use the makepkg.conf in /usr/share/devtools/makepkg-x86_64.conf.

@KSroido
Copy link

KSroido commented Jan 17, 2022

thx @JoanKX

@KSroido
Copy link

KSroido commented Feb 23, 2022

In manjaro, line 22 maybe need change into

sudo pacman -U *.pkg.tar.zst

@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.

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