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]

Re: ARM thumb-interwork libgcc asm functions have no bx


> Hi Giuliano,
> 
> : Some of the gcc/libgcc/interwork/*.o use BX, some don't (rm-elf-objdump -d
> : $i | grep -q bx && echo $i). The ones that do not use BX seem to all come
> : from:
> : 
> : ../egcs-20000619/gcc/config/arm/lib1funcs.asm
> 
> It sounds like you have a broken build of libgcc.a.
> 

Nick,

I think Giuliano is right.  Consider the following code snippets.

file1.c:
int foo(a, b)
{
  return a / b;
}

file2.c:
int bar(a, b)
{
  return a / b;
}

file3.c:

int main()
{
  foo (55, 2);
  bar (55, 2);
  return 0;
}

gcc -O -c -minterwork file1.c
gcc -O -c -mthumb -minterwork file2.c

Now, lets link with the ARM interworking libraries:

gcc -minterwork file3.c file1.o file2.o -o arm-code

We then get the division routine from the ARM+interworking library (ARM 
code): but this doesn't use a bx instruction to return, so the call from 
within bar will fail to switch back to thumb mode on return.

So, lets link with the thumb interworking libraries:

gcc -minterwork -mthumb file3.c file1.o file2.o -o thumb-code

We then get the division routine from the Thumb+interworking library 
(Thumb code):  but this doesn't use a bx instruction either, so the call 
from within foo will fail.

I'm having a think about the problem.  It isn't entirely obvious what is 
the best solution is (I'm not convinced we should be switching in and out 
of thumb/ARM mode for such low-level routines).


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