c - 在 C 程序 (Lib ELF) 中检索被调用函数的名称
问题描述
我试图在 C 程序中获取被调用函数的名称。
例如,这是我的代码:
void toto(void)
{
printf("toto\n");
}
void tutu(void)
{
printf("tutu\n");
}
void mdr(void)
{
printf("tutu\n");
printf("tutu\n");
printf("tutu\n");
printf("tutu\n");
}
int main(int ac, char **av)
{
toto();
tutu();
mdr();
}
我只想要结果:Main()、toto()、tutu() 和 mdr()。但问题是,当我使用 Libelf 时,我在符号表上检索了一些信息,但它给了我调用的函数等等,比如这个例子:
...
57: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
58: 0000000000401148 47 FUNC GLOBAL DEFAULT 13 mdr
59: 0000000000401126 17 FUNC GLOBAL DEFAULT 13 toto
60: 0000000000404020 0 NOTYPE GLOBAL DEFAULT 23 __data_start
61: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
62: 0000000000402008 0 OBJECT GLOBAL HIDDEN 15 __dso_handle
63: 0000000000401137 17 FUNC GLOBAL DEFAULT 13 tutu
64: 0000000000402000 4 OBJECT GLOBAL DEFAULT 15 _IO_stdin_used
65: 00000000004011a0 101 FUNC GLOBAL DEFAULT 13 __libc_csu_init
66: 0000000000404028 0 NOTYPE GLOBAL DEFAULT 24 _end
67: 0000000000401070 5 FUNC GLOBAL HIDDEN 13 _dl_relocate_static_pie
68: 0000000000401040 47 FUNC GLOBAL DEFAULT 13 _start
69: 0000000000404024 0 NOTYPE GLOBAL DEFAULT 24 __bss_start
70: 0000000000401177 37 FUNC GLOBAL DEFAULT 13 main
71: 0000000000404028 0 OBJECT GLOBAL HIDDEN 23 __TMC_END__
72: 0000000000401000 0 FUNC GLOBAL HIDDEN 11 _init
那么我怎样才能只检索我调用的函数呢?再次感谢您的帮助
解决方案
推荐阅读
- c++ - 无法推断模板参数“T”
- java - 未保留多模块项目中的 Lombok @RequiredArgsConstructor
- java - 使用java检查字符串是否为回文
- node.js - 属性未提交到 MongoDB(MERN 堆栈)
- azure - Azure DevOps Powershell 脚本无法创建 SSL/TLS 安全通道
- java - 日历 / GregorianCalendar 等效 Javascript
- python - 类型变量错误。你们能帮我让我的代码工作吗?
- html - 悬停图像时更改背景颜色
- r - 如何将数据帧从 R 导出到 excel 并用空行分隔它们
- javascript - 使用 Axios Vue JS 访问 JSON 对象内的数组