[LLVMdev] large modules, PPC on OS X, "ld: 32-bit pic-base out of range in"

Robb Kistler rkistler at arxan.com
Thu Mar 11 20:29:20 PST 2010


If it matters, I'm using OS X 10.5 and gcc/ld 4.0.  I've tried gcc/ld 4.2 and had the same results.  The object file being passed to ld is around 30 MBytes.

Is the darwin linker capable of synthesizing the branch islands?  I'm an including excerpt from an old post about this, circa 2003.  With gcc-4.0, I can see the branch islands in the PPC assembly.  It also warns about -mlongcall being deprecated.  With gcc-4.2, it seems like -mlongcall is just ignored, and I see no branch islands.  It seems like the darwin linker must be able to synthesize the branch islands now, but it didn't :)  

http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00328.html
From: Stuart Hastings <stuart at apple dot com>
To: gcc-patches at gcc dot gnu dot org
Date: Wed, 3 Dec 2003 10:01:36 -0800
Subject: [tree-ssa] -longcall branch islands for Darwin/PPC

] Most linkers that support branch islands (e.g. AIX) will create them
] when required.  Since the Darwin linker has a strict policy of "never
] create code," the Darwin version obliges the compiler to create branch
] islands wherever they may be needed, and the linker will delete
] unnecessary ones.

Thanks much!
--Robb

On Mar 11, 2010, at 6:33 PM, Nick Kledzik wrote:

> On Mar 11, 2010, at 6:07 PM, Chris Lattner wrote:
>> On Mar 11, 2010, at 5:47 PM, Robb Kistler wrote:
>> 
>>> I'm trying to build a very large shared library (bundle) for PPC on Mac OS X 10.5.  The build looks something like this, where mybundlebitcode.o is the large object
>>> 
>>> llc -relocation-model=pic -o=mybundle.s mybundlebitcode.o
>>> gcc -arch ppc -c -x assembler -o mybundle.o mybundle.s
>>> g++ -o mybundle.bundle -bundle mybundle.o -lotherlibrary
>>> 
>>> I get the following error:
>>> 	ld: 32-bit pic-base out of range in somefunction(Array<unsigned char, 40ul> const&)from mybundle.o
>>> 
>>> Normally I'd try to build with the -mlongcall option, but it doesn't appear that llc has support for this.  Is there some way to get llc to generate "long calls"?
>> 
>> I thought that -mlongcall was a linker option?  Have you tried passing it to GCC/G++ when you link the .s file?
> 
> -mlongcall is deprecated.  The linker ignores the "stubs" generated by the compiler.  The linker is capable of synthesizing branch islands for calls that are > 16 MB away but within the same linkage unit.
> 
> That error message happens not with a call site, but when there is a ppc code sequence that is using two instructions to add a 32-bit signed displacement to a "pic-base" register.  The linker thinks the target of the relocations is > 2GB away from the pic-base.
> 
> Just how large is this bundle?  Are you bumping up to a 2GB mach-o file limit?
> 
> Or are you using absolute addressing to symbols in another linkage unit?  That is not a supported code model.
> 
> -Nick
> 





More information about the llvm-dev mailing list