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.
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:
精彩评论