Extracting only my function names from ELF binary
What about using readelf
on your object file(s) instead of the linked executable? Then there's no spam from the library functions.Use the -c
flag to compile to an object file and not link immediately.
PS: The proper tool to extract names from an executable or object file is nm
, not readelf
. Using nm -P file
has everything you want.
$ nm -P tst.o | awk '$2 == "T" {print "b " $1}'b foob main
EDIT: To ignore main
and symbols starting with an underscore, use
$ nm -P a.out | awk '$2 == "T" && $1 !~ /^_/ && $1 != "main" {print "b " $1}'