简体   繁体   English

在静态 GCC 编译的 C 程序中获取所有函数的详尽列表(除了 .c 文件中使用的函数)

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

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.为此,我需要排除添加到我们静态编译的 C 程序中的所有功能。 I want only the functions which are present in the static C file.我只想要 static C 文件中存在的函数。 But the analysis tool reports apart from the functions present in the.c file, all other functions that are added by the compiler.但是分析工具报告除了.c文件中存在的函数之外,编译器添加的所有其他函数。 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).这些是二进制分析中main()的大量函数跟踪列表中的一些函数(使用控制流图)。

I am unaware of which headers these functions belong to.我不知道这些函数属于哪个标头。 Are they part of libc?它们是 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.我试图在 gdb 中打开一个可执行文件,并试图在加载 libc 的地址范围内找到一些 function 名称。 (For that I used dynamic linking and not static to explicitly check in the libc package) I could not find many of them. (为此,我使用动态链接而不是 static 来显式检查 libc 包)我找不到很多。 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 .类似于包含系统调用列表的 linux 手册页。

Thanks in advance.提前致谢。

You asked about an exhaustive list.你问了一份详尽的清单。 Maybe you can use glibc and gcc source code itself to discover what you need?也许您可以使用 glibc 和 gcc 源代码本身来发现您需要什么?

github is another good resource, search all of github for __pthread_enable_asynccancel and __fortify_fail, github is a very exhaustive list of identifiers. github 是另一个很好的资源,在 github 中搜索 __pthread_enable_asynccancel 和 __fortify_fail,ZBF215181B5140522137B3D4F6B73544 的标识符列表非常详尽。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM