Mach-O 共享库(`.dylib`s)支持符号版本控制吗?
我遇到了一些段错误,这些错误似乎可以通过
例如,我知道在 Linux 上我可以执行 readelf -s libsomething.so ,它会输出版本信息以及符号。但是 readelf
在 .dylib
文件上卡住了。
I'm running into some segfaults that seem to be resolved on linux platforms by symbol versioning inside the ELF dynamic libraries. But I'm still getting segfaults on macOS. Is there a comparable feature in Mach-O shared libraries? And if so, how can I see the version information in the file?
For example, I know that on linux I can do readelf -s libsomething.so
, and it will output the version info along with the symbols. But readelf
chokes on .dylib
files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是真的,但你可以自己动手。
举个例子,Apple 实际上已经对 stat() 系列函数进行了某种符号版本控制。根据宏定义,
stat
的声明将扩展为这样:或这样:
这就是库导出的样子:(
请注意,您必须使用x86_64 版本,因为 arm64 版本从来没有旧的实现,所以
_stat
已经有了新版本。)但是如果你只是一个库的用户,那么除非你头文件损坏,结构和功能不匹配定义,那么这不会解决您的段错误问题。
Not really, but you can kinda roll your own.
To serve as an example, Apple has actually done some kind of symbol versioning to the
stat()
family of functions. Depending on macro definitions, the declaration ofstat
will expand to either this:Or this:
And this is what the library exports look like:
(Note that you have to use the x86_64 version there, as the arm64 version never had the old implementation to begin with, and so
_stat
there is already the new version.)But if you're just a user of a library, then unless you have broken headers with mismatched struct and function definitions, then this is not going to solve your segfault issue.