I'm using CodeBlocks ( 12.11 rev 8629, SDK 1.13.14 ) to build a 32-bit Windows executable, ArchQORDemo.exe
The command line is as follows:-
mingw32-g++.exe -std=c++11 -w -nostdlib -nostartfiles -nostdinc -nodefaultlibs -fno-exceptions -std=c++11 -g -D_QSYS_OS=_QSYS_MSW -DWIN32=1 -D_DEBUG=1 -D_CONSOLE=1 -I..\..\..\..\..\include -c D:\Develop\workspace\CP\QOR1\Demo\ArchQOR\ArchQORDemo.cpp -o obj\Debug\Demo\ArchQOR\ArchQORDemo.o
mingw32-g++.exe -L..\QORStrat1\bin\Debug -L..\WinUsrExeBoot -L..\WinCmpSupQORMinGW -o bin\Debug\ArchQORDemo.exe obj\Debug\Demo\ArchQOR\ArchQORDemo.o -nostdlib -Wl,--disable-runtime-pseudo-reloc -Wl,--disable-auto-import -Wl,--verbose -lWinCmpSupQORMinGW -lgcc -lWinUsrExeBoot -lQORStrata1 -lkernel32
Which ammounts to - the app being a trivial one cpp file application built using C++11 syntax assumptions, with no exceptions and linked to a custom C++ support library, libgcc and a custom runtime. ( Yes I did have to hack the specs file to make it do this but that's not the problem ).
The app builds fine, the custom runtime QORStrata1.dll gets loaded, called, does it's init successfully including making Win32 API calls and returns but the application entry point, _tMainCRTStartup, is never reached.
It dies with a SIGSEGV in ntdll!RtlInitializeContext.
My custom C++ support library contains everything that's in libsupc++ from the gcc 4.7.1 sources which matches with the 4.7.1 libgcc I'm linking with so the only thing I can see that can be missing is some magic MinGW support for PE executables.
Does anyone out there know what sections or resources Windows may be looking for in my .exe under RtlInitializeContext?
For example I have a IMAGE_LOAD_CONFIG_DIRECTORY32 instance. Do I need something else?
Does anyone out there know anything about MinGW PE magic and what I might be missing in terms of tricking the compiler into using it/ not using it?
I'm not linking to mingw or mingwex but the link works which implies everything is covered by QORStrata1.dll as it should be.
Sorry if this is a bit vague but I'm a little clueless as to what exactly is wrong other than I can build a valid DLL but an EXE with the same support code isn't even getting to first base.
Update:-
It could be an ENTRY POINT issue, according to WinDbg it is reaching the .exe code but executing something other than _tMainCRTStartup and then immediately exiting and crashing trying to lock the heap on exit.