ios - CFBundleGetFunctionPointerForName and dlsym return NULL for exported function -
i have fork of javascriptcore framework, have added function of own, exported. framework compiles find. running nm on framework reveals function (jscontextcreatebacktrace_unsafe) indeed exported:
leo-natans-wix-mpb:javascriptcore.framework lnatan$ nm -gu javascriptcore.framework/javascriptcore | grep jscontextcreatebacktrace 00000000004cb860 t _jscontextcreatebacktrace 00000000004cba10 t _jscontextcreatebacktrace_unsafe however, unable obtain pointer of function using cfbundlegetfunctionpointerforname or dlsym; both return null. @ first, used dlopen open framework, tried using cfbundlecreate , cfbundlegetfunctionpointerforname returns null.
what cause this?
update
something fishy going on. renamed 1 of jsc functions, , nm reflects this. however, dlsym still able find function original name, rather renamed.
it's hard track down since it's highly dependent on specific environment , circumstances, you're running issue because system image has been loaded , haven't changed name of framework.
if @ source code dlopen in dyld/dyldapis.cpp:1458, you'll notice context passed dyld configured matchbyinstallname = true. context passed load executes various stages necessary image loading. there few phases worth noting:
loadphase2in dyld/dyld.cpp:2896 extracts ending of framework path , searches in search pathloadphase5checkin dyld/dyld:2712 iterates on loaded images , determines if of them have matching install name, , if 1 does, returns instead of loading new one.loadphase5loadin dyld/dyld:2601 loads image if wasn't loaded/found earlier steps. (it's worth notingloadphase5checkexecuted first, since image loading 2 pass process.)
given of above, i'd try renaming framework besides javascriptcore.framework. depending on install name of both system framework , framework, i'd recommend changing install name. (there plenty of blog articles , stackoverflow posts document how using install_name_tool -id.)
Comments
Post a Comment