ARM/THUMB long calls stubs

Sami Kantoluoto sami.kantoluoto@embedtronics.fi
Fri Aug 6 08:17:00 GMT 2004


Hi Nick,

On Fri, Aug 06, 2004 at 08:43:02AM +0100, Nick Clifton wrote:

> >Tried both #pragma long_calls and __attribute__((long_call)) and didn't
> >help :-/.
> 
> OK - do you have a *small* test program/sources that demonstrates the 
> problem ?

Here. Compiled (gcc 3.4.1 patched with your patch) like:

# arm-elf-gcc -mthumb -mlong-calls -Wall -nostdlib -o test test.c test2.c

objdump shows (ripped a bit) following: 

# arm-elf-objdump -d test

test:     file format elf32-littlearm

Disassembly of section .text:

	...

0000802c <_start>:
    802c:	b580      	push	{r7, lr}
    802e:	466f      	mov	r7, sp

	foo() gets called here:

    8030:	ffe6f7ff 	bl	8000 <foo>

	bar() gets called here:

    8034:	4b03      	ldr	r3, [pc, #12]	(8044 <.text+0x44>)
    8036:	f801f000 	bl	803c <_start+0x10>
    803a:	e000      	b	803e <_start+0x12>
    803c:	4718      	bx	r3

    803e:	46bd      	mov	sp, r7
    8040:	bd80      	pop	{r7, pc}
    8042:	0000      	lsl	r0, r0, #0
    8044:	8049      	strh	r1, [r1, #2]
	...


So foo() gets called directly with 'bl' but bar() (in test2.c) gets called
as "wanted".


     -sk
-------------- next part --------------
#pragma	long_calls

int boo;

void foo() __attribute__ ((long_call));
void foo()
{
  int i;
  for (i=0; i < boo; i++) ;
}

extern void bar();

void _start() __attribute__ ((long_call));
void _start()
{
  foo();
  bar();
}

  
-------------- next part --------------
extern int boo;

void bar()
{
  int i;
  for (i=0; i < boo; i++);
}


More information about the Gcc-bugs mailing list