[Linux-Xtensa] Re: gas problem with large function

linux-xtensa at linux-xtensa.org linux-xtensa at linux-xtensa.org
Thu Sep 4 10:04:34 PDT 2008

Oskar wrote:
> Hello,
> for test purpose, we fed into the xtensa GNU
> cross toolchain a source file which generates
> a very large function. The error message we see
> is:
> bash-3.00# xtensa-linux-gcc  -Os -o runtime runtime.c
> /tmp/ccwNQD70.s: Assembler messages:
> /tmp/ccwNQD70.s:12987: Error: operand 1 of 'j' has out of range value '156859'
> Checking the assembler output, we see there is
> an instruction "bltu" with its label far off.
> We currently use binutils .
> Down in xtensa-relax.c, there widening instructions
> to replace "bltu L" with "bgeu X ; j L ; X:", but
> the "j" jump is still limited to 128K offset to the PC.
> I guess, to fix the problem, we would need to add an
> relaxation like:
>   "j L" --> "literal X:L ; l32r a?,X ; jx a?"
> - is that correct?
> - how should the widening instruction look like exactly?
> - at which position to insert this into the existing table?

This is a harder problem than you might think.  It cannot be handled entirely in 
the assembler because there may not be any registers available for a JX 
instruction.  The compiler can do it, but it is hard for the compiler to know 
exactly how big the code will be.  We have been thinking about a solution that 
involves both the compiler and the assembler.  Your message has sparked some new 
discussion on this topic here at Tensilica, but I can't promise a quick fix for 
you.  Most of the work needs to be done in the compiler.  If you have expertise 
in GCC and want to contribute to the effort, volunteers are welcome!

More information about the linux-xtensa mailing list