long calls generating in gcc

Guest #1321972
hi,

I'm confused with way how long calls are generated when compiling some 
example code

#pragma long_calls
void *reserve_ram ( void **buf, unsigned int size );
void *release_ram ( void **buf );
#pragma long_calls_off

extern unsigned int *ptr;

unsigned int main (unsigned int msg)
{
   reserve_ram (  &ptr, msg * 4 );
   release_ram ( &ptr );

   return 0;
}

with following options
arm-elf-gcc -mthumb -save-temps -Os -Wall -c main.c

compiler assembled it to

  .code  16
  .file  "main.c"
  .text
  .align  2
  .global  main
  .code  16
  .thumb_func
  .type  main, %function
_main_:
  push  {r4, lr}
  ldr  r4, .L3
  lsl  r1, r0, #2
  ldr  r3, .L3+4
  mov  r0, r4
  bl  .L5
  mov  r0, r4
  ldr  r3, .L3+8
  bl  .L5
  @ sp needed for prologue
  mov  r0, #0
  pop  {r4, pc}
.L4:
  .align  2
.L3:
  .word  ptr
  .word  reserve_ram
  .word  release_ram
  .size  main, .-_main_
  .ident  "GCC: (GNU) 4.3.3"
  .code 16
  .align  1
.L5:
  bx  r3


SO i have a question, is any way to generate calls directly by bx/blx 
instruction?. I mean something like this
/* ... */

_main_:
  push  {r4, lr}
  ldr  r4, .L3
  lsl  r1, r0, #2
  ldr  r3, .L3+4
  mov  r0, r4
  blx  r3
  mov  r0, r4
  ldr  r3, .L3+8
  blx  r3
  @ sp needed for prologue
  mov  r0, #0
  pop  {r4, pc}

/* ... */


regards,
Bartek

Reply

A question of your own? This thread is over 17 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.