[OpenBIOS] libgcc problem

Blue Swirl blauwirbel at gmail.com
Sun Oct 3 17:59:58 CEST 2010


Hi,

I finally found out the cause of the problem that prevented us to
remove our copy of libgcc. The problem was that when switching to the
libgcc provided by GCC, there would be strange crashes. The cause of
these crashes is that the libgcc shipped with GCC is compiled with
default options, in Sparc64 case the machine model is 'embmedany'.
This makes memory accesses use %g4 as base register and since we don't
initialize it (because other code uses machine model 'medany'), there
will be crashes due to random base with some memory accesses in
libgcc. It's clear that the default machine model for Sparc64 is not
compatible with OpenBIOS, as is any libgcc compiled with this model.

I also found out how to make GCC compile and use separate libgccs
('multilib') for each machine model. This is enabled for sparc64-elf
target case with the following patch (applies to gcc-4.6-20100925).
--- gcc/config/sparc/t-crtfm.orig       2002-06-20 18:00:02.000000000 +0000
+++ gcc/config/sparc/t-crtfm    2010-10-03 14:45:31.000000000 +0000
@@ -1,4 +1,11 @@
 EXTRA_PARTS += crtfastmath.o

+MULTILIB_OPTIONS = mcmodel=medany/mcmodel=medmid/mcmodel=medlow
+MULTILIB_DIRNAMES = medany medmid medlow
+MULTILIB_MATCHES =
+
+LIBGCC = stmp-multilib
+INSTALL_LIBGCC = install-multilib
+
 $(T)crtfastmath.o: $(srcdir)/config/sparc/crtfastmath.c $(GCC_PASSES)
        $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) $(LIBGCC2_CFLAGS) -c -o
$(T)crtfastmath.o $(srcdir)/config/sparc/crtfastmath.c

The correct configuration can be seen with this command:
$ sparc64-elf-gcc --print-multi-lib
.;
medany;@mcmodel=medany
medmid;@mcmodel=medmid
medlow;@mcmodel=medlow
$ sparc64-elf-gcc -v
Using built-in specs.
COLLECT_GCC=sparc64-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sparc64-elf/4.6.0/lto-wrapper
Target: sparc64-elf
Configured with: ../configure --target=sparc64-elf
--enable-targets=sparc64-elf --disable-nls --disable-threads
--enable-languages=c --disable-shared --disable-libssp
--enable-multilib
Thread model: single
gcc version 4.6.0 20100925 (experimental) (GCC)

With this version, openbios-sparc64 without our local libgcc works as
well as the old version.

It may also be possible to change the default machine model, but I
didn't try that. This way may be easier if the GCC is not new enough
to support multilib.

Now the big question is, should we still aim for removal? I'm not sure
if libgccs shipped with native GCCs are compatible. Requiring a
specifically patched GCC does not seem so attractive, though most
people probably make a cross compiler anyway.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Remove-our-local-copy-of-libgcc.patch
Type: application/mbox
Size: 40027 bytes
Desc: not available
URL: <http://lists.openbios.org/pipermail/openbios/attachments/20101003/9ffeec53/attachment-0001.bin>


More information about the OpenBIOS mailing list