ELF 文件版本
我正在研究 elfdump 命令的克隆。
在所有可执行文件上运行 elfdump -ecps *file*
时,我的程序工作正常。 但是,当我在库文件(例如 libc.so)上运行程序时,它会为 .symtab 部分中的所有符号打印出错误的版本号(特别是它们全部为零)。 我已经查看了文档很多次,但我不明白为什么会发生这种情况。
有人可以提供一些提示吗? 或者可能如何检测它是否是一个库,以便我可以硬编码一个 0 ?
I'm working on a clone of the elfdump
command.
My program works fine when running elfdump -ecps *file*
on all executables. However, when I run my program on a library file, say libc.so, it prints out an incorrect version number for all symbols in the .symtab section (specifically they are all zero). I've looked over the documentation tons of times, but I can't figure out why this is happening.
Can someone please provide some tips? Or possibly how to detect whether its a library or not so I could just hard-code a 0 in?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信,您可以通过检查 e_type 字段是否为 ET_DYN 来确定您是否正在针对共享库运行。 (man elf(5))
有一篇文章,作者: Ulrich Drepper 介绍了 ELF 中的 glibc 每个符号版本控制技巧。 也许那里有您以前没有遇到过的其他信息。 Linux 上的手册页似乎没有涵盖 ELF 文档中每个符号的版本控制信息。
You can determine if you're running against a shared library by checking to see if the e_type field is ET_DYN, I believe. (man elf(5))
There is an article by Ulrich Drepper that covers the glibc per-symbol versioning tricks in ELF. Perhaps there is additional information there which you've not encountered before. The man pages on linux don't appear to cover the per-symbol versioning information in the ELF docs.