Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要一种方法来枚举从 Mac OS X 上的 dylib 导出的符号及其地址。
从我通常会使用的外壳nm中 - 是否有一个库可以让我从我的代码中使用它来获得相同的东西nm?类似于 Windows 上的 dbghelp API。
nm
作为最后的手段,我想我可以生成nm并解析输出,但如果有更清洁的方法,我很想避免这种情况。
nm(和 otool)拥有内置的知识,而不是使用 API。您将获得的最好的结果是定义文件格式的头文件(参见“man Mach-O”)。我会调用 nm 并解析输出;仅仅因为接口是程序执行而不是函数调用,重用现有组件并没有错。