ARM/THUMB long calls stubs
Nick Clifton
nickc@redhat.com
Fri Aug 6 10:24:00 GMT 2004
Hi Sami,
> So foo() gets called directly with 'bl' but bar() (in test2.c) gets called
> as "wanted".
Right - this is because foo() is defined in the same file as the
function that calls it: _start(). GCC makes the (reasonable) assumption
that since both foo() and _start() are going to be compiled together and
placed into the same output section that it knows how far apart they are
and that it can avoid the overhead of the long-call. In fact at high
optimisation levels it might even in-line the code from foo() into _start().
The way to avoid this "feature" (I hesitate to call it a bug) is to
compile your code with the "-ffunction-sections" switch added to the GCC
command line. This tells GCC to place each function into its own
separate section, and GCC is smart enough to know that different
sections may not end up close to each other, so it cannot optimise away
the use of the long call.
Cheers
Nick
More information about the Gcc-bugs
mailing list