This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ARM/THUMB long calls stubs


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]