我可以从ELF文件的符号表中的符号信息中获取对象名称吗?
我已经成功解析了一个由多个源文件编译而成的elf文件(可执行文件)。我能够获取绑定(本地、全局、弱)、类型(对象、文件、部分、函数)、符号大小、符号地址以及符号名称(来自字符串表)。
我也知道该符号所链接的部分。
我的问题是,我们能否从符号表信息中获取包含该符号的确切目标文件名(**.obj)?我在解析时是否遗漏了一些信息?
I have successfully parsed an elf file (executable file) compiled from multiple source files. I am able to get the binding(local,global,weak), type(object,file,section,function), size of the symbol and the address of the symbol along with the symbol name ( from string table).
The section to which the symbol is linked is also known to me.
My question is that can we get the exact object file name(**.obj) which contains the symbol from the symbol table information? Am I missing some information while parsing ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法直接获取目标文件名,该文件名在链接过程中会丢失。但是,根据用于创建可执行文件的构建过程,您可以从 STT_FILE 符号推断目标文件名(例如,可执行文件包含名称为 foo.c 的 STT_FILE 符号 -> 您可以推断目标文件是 foo .o)。
似乎特定源文件中的符号遵循带有 STB_LOCAL 绑定的 STT_FILE 符号。
来自 System V ABI 标准:
You cannot get the object file name directly, this is lost during linking. However, depending on the build process used to create the executable, you can infer the object file name from the STT_FILE symbols (e.g., an executable contains a STT_FILE symbol with name foo.c -> you could maybe infer the object file was foo.o).
It appears that symbols in a specific source file follow the STT_FILE symbol with a binding of STB_LOCAL.
From the System V ABI standard: