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] | |
On Fri, Aug 06, 2004 at 11:25:04AM +0100, Nick Clifton wrote:
> 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().
My example was missing __attribute__ ((section(".foo"))) from foo(). But
putting that there nothing changes (except output section of foo()).
I think gcc should use the long call (with -mlong-calls / #pragma) if called
and caller functions are in different sections even if the functions are in
the same file.
> 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.
Ah, I'll try that.
PS. # arm-elf-gcc -mthumb -mlong-calls -Wall -nostdlib -o test test.c test2.c
-sk
Attachment:
test.c
Description: Text document
Attachment:
test2.c
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |