powerpc-eabi subroutine calls

Gunter Magin magin@skil.camelot.de
Tue Dec 11 13:32:00 GMT 2001


Hi,

I have observed a gcc problem for an embedded mpc8xx target (powerpc-eabi):

I have 2 memory banks, in which .text has to be linked into. These memory
banks are more than 16MB apart (0x40000000 and 0x00000000). A custom linker
script tells which source module goes into which bank.

GCC generates a "bl" (Opcode 0x48000000) for procedure
calls. Unfortunately this PPC instruction allows only 24bit (signed)
relative offset, i.e. the branch destination must be within +-8MByte
distance from the caller.

For cross bank subroutine calls different banks the linker gives a
relocation error:

      relocation truncated to fit: R_PPC_REL24 foo

The source of trouble seems, that gcc does generate an offset limited
relative jump instruction, where an absolute jump would be more adequate.

I know, PPC does not have absolute jumps, but that may be mimiced by
a bctrl or a blrl, after LR or CTR has been loaded with the absolute
destination address.

Is there a way to tell gcc how to generate those absolute call methods?
Handcrafted inline assembler seems messy to me because of parameter
handling.

gcc-2.95.2
GNU ld 2.10.1
gcc command line parameters:
/opt/gnu/powerpc-eabi/bin/gcc  -c -g -Wall  -fno-inline  -O3  -mcpu=860 \
-msoft-float  -o foo.o ../src/foo.c

P.S.

Of course, there is the (obvious) solution for my immediate problem to
remap one memory bank into the 24bit scope of the other.

However, the problem still remains if the .text segment would grow beyond
8 MB.

gm
-- 
Gunter Magin                                         magin[AT]skil.camelot.de

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com



More information about the crossgcc mailing list