I've got a C library that is being used in an iOS app. This library uses dlopen()
to access extension functionality. The code works fine on the iOS simulator (in both 32 bit and 64 bit modes); however, when I run the same code on an actual iPhone5s (ARM64), I get the following error:
dlopen(/private/var/mobile/Containers/Bundle/Application/EDEAE282-AE96-45CA-9A4F-D70EE532FB93/foobar.app/lib/time.so, 2): no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/EDEAE282-AE96-45CA-9A4F-D70EE532FB93/foobar.app/lib/time.so: mmap() error 1 at address=0x101CE4000, size=0x00004000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/EDEAE282-AE96-45CA-9A4F-D70EE532FB93/foobar.app/lib/time.so
As far as I can make out, the file exists and is being found successfully. It's also not just a problem of being compiled for the wrong architecture; lipo -info
reports that time.so
is:
Non-fat file: time.so is architecture: arm64
and file
reports time.so
as a Mach-O 64-bit bundle
.
The two questions I have:
What does the "no suitable image found" and "mmap() error 1" error messages mean?
How do I correct (or even diagnose) what is going on here? I've stepped through the C code, and the
dlopen()
call is failing with a return value ofNULL
, and setting the error message, so stepping through the code isn't going to give me any more information.
(As background, - I'm trying to port Python to iOS; the call to dlopen()
is used to load native code modules. time.so
is one of those modules).