On Mon, 27 Aug 2018, Liu Hao wrote:
This patch breaks libgcc.
At the moment the `__main()` function which performs global
initialization for static objects cannot handle `__CTOR_LIST__` with two
pointers of `-1` in the front of it [1]. The code is presumed to call
every function via pointers between the first `-1` and final null
terminator in reverse order, which, if the second element is a
duplicated `-1`, will result in a segfault at the last iteration of the
loop.
To clarify; mingw-w64-crt has got its own __main function, while libgcc
provides another one. The one in mingw-w64 should handle this just fine,
while the libgcc ones obviously doesn't.
Probably this patch should be reverted.
Yes, unless we come up with something better, soon. Feel free to revert,
but please amend the commit message to clarify that there are two
different implementations of the __main function; the one we have worked
fine but the libgcc one didn't handle our special situation.
I had an idea to try to move the defintion of these symbols from
crtexe.c/crtdll.c into gccmain.c, but that makes them turn up too late in
the link, after constructors from some object files, so that doesn't
really work.
If we revert this, my next alternative towards unifying this handling
across binutils and lld, would be to first make mingw-w64 check for these
symbols during the build so we can make the previous ifdefs a bit more
flexible (not having to check for #ifdef __clang__, which the compiler
doesn't say what linker one was going to use) - I have a pretty much ready
patch for this already. Then secondly, we could make lld provide the
symbols, to make things with gcc+binutils behave the same as with
clang+lld, making the CRT object files compatible across both linkers at
the same time.
// Martin
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public