Bug 28904 - operand out of range on Linux/PowerPC
Summary: operand out of range on Linux/PowerPC
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: assemble-failure
Depends on:
Reported: 2006-08-30 15:21 UTC by Guillaume Libersat
Modified: 2009-05-14 04:03 UTC (History)
5 users (show)

See Also:
Host: powerpc-linux-gnu
Target: powerpc-linux-gnu
Build: powerpc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-09-05 22:50:51


Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Libersat 2006-08-30 15:21:29 UTC
When trying to build CrystalSpace3d, which is a very big application, on GNU/Linux, I get errors like this :

{standard input}:1236795: Error: operand out of range (0x0000000000008220 is not between 0xffffffffffff8000 and 0x0000000000007fff)
(repeated about 300 times)

The file, cs_pyth.cpp generates a huge .S (45Mb).

Every error refers to a "lwz" instruction :
        lwz 4,.LC42716-.LCTOC1(30)
        lwz 4,.LC42718-.LCTOC1(30)
        lwz 4,.LC42720-.LCTOC1(30)
        lwz 4,.LC42722-.LCTOC1(30)
        lwz 4,.LC42724-.LCTOC1(30)
        lwz 4,.LC42726-.LCTOC1(30)


Here's what I'm using :
[sakura>glibersat::crystal]$ g++ -v
Using built-in specs.
Target: powerpc-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --disable-softfloat --enable-targets=powerpc-linux,powerpc64-linux --with-cpu=default32 --enable-checking=release powerpc-linux-gnu
Thread model: posix
gcc version 4.1.2 20060814 (prerelease) (Debian 4.1.1-11)


The complete command line is :
g++ -c -o ./out/linuxppc/debug/plugins/cscript/cspython/cs_pyth.o -I. -I./include -I./include -pipe -Wall -Wno-unknown-pragmas -I/usr/local/include -fno-exceptions -g3 -DCS_DEBUG -fPIC -I/usr/include/python2.3 -DSWIG_GLOBAL -Wno-unused -Wno-uninitialized -fno-strict-aliasing  ./out/linuxppc/debug/plugins/cscript/cspython/cs_pyth.cpp


I can't attach the .i file since it's really big. You can get it there :

Thanks !
Comment 1 Andrew Pinski 2006-08-31 04:30:49 UTC
Hmm, I am going to go out on a limb and say we should 
produce about the following (hopefully I get the right macros):
la temp, ha16(.LC42716-.LCTOC1)(30)
lwz rn, lo16(.LC42716-.LCTOC1)(temp)

This is like what Darwin does for PIC.
Comment 2 Andrew Pinski 2006-08-31 04:34:41 UTC
well, the syntax would be more like:
        addis 9,(.LC42716-.LCTOC1)@ha(30)
        lwz 0,.LC42716-.LCTOC1)@l(9)

But I don't know if this syntax will work.
Comment 3 Alan Modra 2006-09-05 22:50:51 UTC
This is a limitation of the -fPIC implementation used on powerpc-linux.  You get a maximum of 64K bytes of GOT entries per function (ie. 16K entries).  -fpic is even more limited, with only 64K bytes of GOT for the entire executable.  (-fpic used to be 32k for the entire executable until the linker was enhanced.)
Comment 4 S.R.Mueller 2007-06-26 16:12:16 UTC
the same here on gentoo-ppc-2.6.21, using gcc-4.1.2
Powerbook G4(5,6)
trying to compile Crystalspace v1.2 --with-python
When ommiting -fPIC OR using --without-python, the build works.
I will see if a revert to 4.1.1 brings any advancement for 4.1.2 is marked as testing on gentoo-ppc.
Comment 5 Andrew Pinski 2007-06-26 20:30:42 UTC
They have been improvements in 4.2.0 with respect of having a smaller GOT.  Can you try 4.2.0?
Comment 6 S.R.Mueller 2007-06-26 20:35:32 UTC
(In reply to comment #5)
> They have been improvements in 4.2.0 with respect of having a smaller GOT.  Can
> you try 4.2.0?

uh, i'd like to...give me a few days to figure out how i can do a proper upgrade or setup a sandbox for testing.
I will check back with the results.
Comment 7 S.R.Mueller 2007-06-27 08:06:04 UTC
I have checked with 4.2.0 and it produces the same error.
Maybe i'd like to rebuild python too with 4.2?
Comment 8 S.R.Mueller 2007-07-07 13:37:18 UTC
crystalspace also has a bug report for this (http://www.crystalspace3d.org/trac/CS/ticket/210)

as mentioned there, one could try this http://www.crystalspace3d.org/trac/CS/ticket/258 which is using a special branch for the python modules. using this branch, i had no problem building the python modules. maybe it's worth a look for you :)
i dont really get the point...but, eager to... 
Comment 9 Ben Elliston 2009-05-14 04:03:27 UTC
The original reporter seems to have resolved this to their satisfaction in their CrystalSpace3d bug report.  This report was due to running up against a limitation of the -fPIC implementation.