gpt4 book ai didi

你能从 C 可执行文件中提取关于它是从哪些源文件编译的信息吗?

转载 作者:太空宇宙 更新时间:2023-11-04 08:50:02 27 4
gpt4 key购买 nike

我有一个 C 可执行文件,我想知道可执行文件中是否存储了关于它是从哪个或哪些文件编译的任何信息,如果有,如何访问该信息?我正在使用 RedHat Linux 6。

最佳答案

如果您的程序编译时带有调试信息,那么是的,这是可能的。

比如我用gcc -ggdb3 test.c -o test编译test.c

然后,使用 gdb ./test:

(gdb) info functions
All defined functions:

File main.c:
int main(int, char **);

Non-debugging symbols:
0x0000000000400370 _init
0x00000000004003a0 __libc_start_main@plt
0x00000000004003b0 __gmon_start__@plt
0x00000000004003c0 _start
0x00000000004003f0 deregister_tm_clones
0x0000000000400420 register_tm_clones
0x0000000000400460 __do_global_dtors_aux
0x0000000000400480 frame_dummy
0x00000000004004d0 __libc_csu_init
0x0000000000400540 __libc_csu_fini
0x0000000000400544 _fini

(gdb) info sources
Source files for which symbols have been read in:

/home/john/Projects/test/main.c, /usr/include/bits/sys_errlist.h, ...

Source files for which symbols will be read in on demand:

关于你能从 C 可执行文件中提取关于它是从哪些源文件编译的信息吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20009858/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com