diff options
author | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-06-17 14:39:02 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-06-29 12:39:50 +0000 |
commit | c937bbb4fe708f7f873ca630c6ff225f9a3f9ace (patch) | |
tree | 99b4e9191a887458b92de08f2ff72903ec89cd70 /src/plugins/platforms/ios | |
parent | 7b0cb2ffa3e4a1fec6ac716f7c82c42e2bacbb2a (diff) |
iOS: Use LC_MAIN to wrap user main() instead of mangling object files
With iOS 6.0 and above the LC_MAIN load command is available, which allows
dyld to call the application entrypoint directly instead of going through
_start in crt.o. By passing -e to the linker we can change this entrypoint
to our wrapper that sets up the separate stack before entering the native
iOS runloop through UIApplicationMain. As before, we call the user's main()
from applicationDidFinishLaunching.
By using LC_MAIN instead of messing with the object files we open up the
possibility of generating Bitcode instead of object code, which can be
useful for link-time optimizations, either locally or by Apple.
Change-Id: If2153bc919581cd93dfa10fb6ff1c305b3e39a52
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/qioseventdispatcher.mm | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index 8e4b4c5875..bd4b8778ed 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -198,7 +198,7 @@ namespace bool debugStackUsage = false; } -extern "C" int __attribute__((weak)) main(int argc, char *argv[]) +extern "C" int qt_main_wrapper(int argc, char *argv[]) { @autoreleasepool { size_t defaultStackSize = 512 * kBytesPerKiloByte; // Same as secondary threads @@ -233,18 +233,7 @@ enum SetJumpResult kJumpedFromUserMainTrampoline, }; -// We define qtmn so that user_main_trampoline() will not cause -// missing symbols in the case of hybrid applications that don't -// use our main wrapper. Since the symbol is weak, it will not -// get used or cause a clash in the normal Qt application usecase, -// where we rename main to qtmn before linking. -extern "C" int __attribute__((weak)) qtmn(int argc, char *argv[]) -{ - Q_UNUSED(argc); - Q_UNUSED(argv); - - Q_UNREACHABLE(); -} +extern "C" int main(int argc, char *argv[]); static void __attribute__((noinline, noreturn)) user_main_trampoline() { @@ -263,7 +252,7 @@ static void __attribute__((noinline, noreturn)) user_main_trampoline() qFatal("Could not convert argv[%d] to C string", i); } - int exitCode = qtmn(argc, argv); + int exitCode = main(argc, argv); delete[] argv; qEventDispatcherDebug() << "Returned from main with exit code " << exitCode; |