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:

  • loadphase2 in dyld/dyld.cpp:2896 extracts ending of framework path , searches in search path

  • loadphase5check in dyld/dyld:2712 iterates on loaded images , determines if of them have matching install name, , if 1 does, returns instead of loading new one.

  • loadphase5load in dyld/dyld:2601 loads image if wasn't loaded/found earlier steps. (it's worth noting loadphase5check executed 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

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -