[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] gcc 4.2.2 patch



MiKRO wrote :
This patch is an addition to Vincent's gcc 4.2.2 patch (20071212). I
didn't use the newest one since I (freemint) use old binutils 2.13.1
and according to Vincent's note in history log, I shouldn't use old
binutils and his newest gcc4 patch.

Don't be afraid of my latest GCC patch. The issue is about CONSTRUCTORS. It is a list of functions which have to be called before main(). It is used in C++ for calling the constructors of the global variables (if they have a specific constructor), or functions explicitly tagged with __attribute__((constructor)). Because the CONSTRUCTORS list contains function pointers, it has to be relocated. The original binutils patch didn't relocate the CONSTRUCTORS list at all. Thus, I'm pretty sure that if a program using CONSTRUCTORS is compiled with GCC 2.95.3 and linked with binutils 2.13.1, it will crash before main(). In my earlier patches, I put a workaround in GCC in order to relocate the CONSTRUCTORS at run time. Recently, I managed to persuade the linker to put the CONSTRUCTORS into the relocation table as expected. So I removed the workaround in GCC. My binutils and GCC patches are now 100% clean - as far as CONSTRUCTORS are concerned ;-) So my latest patch for GCC 4.2.2 and GCC 2.95.3 are more similar than before, because none of them use a CONSTRUCTORS workaroud ! Because CONSTRUCTORS is rarely used in the real MiNT world (C++ program + global variables having constructors), we are very unlikely going to see any problem between the different GCC and binutils versions.

This patch will probably work also with the newest Vincent's gcc4
patch but I didn't test it.

Sure it will work !
I will include it in my next update.
Thank you for your work and your patience !

Btw, I've tried to compile&run my port of quake with my gcc4 and guess
what... it crashed :(

Well, you'll have to investigate a bit.
Try to compile it without optimization.
Maybe there is a bug somewhere, and it appears only now.
It is very unlikely to be a stack problem this time.
I imagine that you didn't recompile all the libraries.
GCC 4 has some debugging facilities, however I didn't test it.
I must admit that I'm not completely sure that the code generated with GCC 4.2.2 is fully binary compatible with the libraries compiled with GCC 2.95.3...
Well, I'm sure you will find the reason of this crash very soon !

--
Vincent Rivière