Skip to content
/ elfdbg Public

Utility to determine if ELF binary is built with debug sections

Notifications You must be signed in to change notification settings

sbz/elfdbg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elfdbg

FreeBSD Build Status Linux Build Status

About

This project elfdbg is a utility program to quickly identify if an ELF binary is built with debug sections

Debug sections in ELF binary usually are generated using the -g flag with the compiler. The compiler adds the new .debug_* sections in the binary.

The program is looking for the existence of sections with name starting with .debug_ to determine if the binary has been built with debug information.

The ELF format is a well-known standard. ELF TIS reference specification is available here and as a FreeBSD elf(5) man page.

Usage

This is intented to be used in shell script in order to avoid using file(1) and parsing the output like below:

`file /path/to/binary | awk '/debug_info/{print $2}'` != 'ELF'

To determine if binary has been built with debug, use the following:

if elfdbg -q /path/to/binary; then
        echo "No symbols"
    else
        echo "Binary with debug symbols"
fi

On FreeBSD, you can easily identify the binary packages with missing debug using similar one-liner:

pkg info -a -l|grep local/bin/|while read a; do echo $a: `elfdbg $a`; done

Build and install

The Makefile use the standard BSD Makefile to build the program.

make && sudo make install

If your on Linux, use make also build using the GNU Makefile.

Test

The tests cases are implemented using the FreeBSD test suite framework with kyua and Kyuafile.

make test

History

  • 2015 I wrote this using libelf elf(3) and gelf(3) API f4b470b
  • 2020 I rewrote this without relying on libelf API 1960d10

About

Utility to determine if ELF binary is built with debug sections

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published