Get an exhaustive list of all the functions (other than the functions used in the .c file) in a statically GCC compiled C program

Viewed 32

I am working on a binary analysis. For that, I need to rule out all the functions which are added to our statically compiled C program. I want only the functions which are present in the static C file. But the analysis tool reports apart from the functions present in the .c file, all other functions that are added by the compiler. Few examples are:

__open64
__pthread_enable_asynccancel
__pthread_disable_asynccancel
__stack_chk_fail
__fortify_fail
__libc_message
abort
sigprocmask
pthread_sigmask
...

These are a few functions from the huge list of function-trace from main() in the binary analysis (using the control flow graph).

I am unaware of which headers these functions belong to. Are they part of libc? I tried to open up an executable in gdb and tried to find some function names in the address range where libc is loaded. (For that I used dynamic linking and not static to explicitly check in the libc package) I could not find many of them. Is there any man-page containing an exhaustive list of all these kinds of functions? Something like the linux man page containing the list of syscalls.

Thanks in advance.

1 Answers

You asked about an exhaustive list. Maybe you can use glibc and gcc source code itself to discover what you need?

github is another good resource, search all of github for __pthread_enable_asynccancel and __fortify_fail, github is a very exhaustive list of identifiers.

wget http://ftp.gnu.org/gnu/glibc/glibc-2.36.tar.gz
tar xzf glibc-2.36.tar.gz

grep -r libc_hidden
. . . a very long list . . .
./glibc-2.36/nptl/cancellation.c:libc_hidden_def (__pthread_enable_asynccancel)

wget https://ftp.gnu.org/gnu/gcc/gcc-12.2.0/gcc-12.2.0.tar.xz
tar xJf gcc-12.2.0.tar.xz 

grep -r __fortify_fail
. . . a lot of results . . .

Related