Load named unexported symbols with dlsym?

半城伤御伤魂 提交于 2020-01-04 04:34:28

问题


Is it possible to load a named unexported symbol from a framework using dlsym?

The symbol I'm trying to import has a name by which it is referred to within the framework. It is a function I need to call.

I'm trying to do it the usual dlopen + dlsym way, but when I try to load a symbol that isn't exported, dlsym returns a NULL pointer.


回答1:


dlsym can only load functions that are listed in the symbol table. You can list the symbol table by running nm on the framework in question.

You can verify this in the dyld source: ImageLoaderMachOClassic::findExportedSymbol is the internal implementation of dlsym, it simply binary searches the symbol table:

And ImageLoaderMachO::parseLoadCmds loads the symbol table from the load commands in the Mach header:



来源:https://stackoverflow.com/questions/6008904/load-named-unexported-symbols-with-dlsym

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!