arm thumb interworking funkyness.

Duane Ellis duane@duaneellis.com
Mon Apr 23 13:32:00 GMT 2007


Hello,

I'm trying to write a small bit of ARM asm, that is callable from mixed 
code.

that is: I don't want the LD to create a "_from_thumb" symbol (wrapper) 
for it.
I want to include that in my hand written assembler code.

GCC version: gcc version 4.1.2
binutils version 2.17

C code is compiled with -mcpu=arm7tdmi -mthumb -mthumb-interwork
ASM code is (really .S, through GCC) is compiled with the same options.

In C, code, I'm doing this:

   void
   my_function( void )
  { 
       printf("Turn interrupts on\n");
       ARM_enable_IRQ();
       process_run();
   }

After linking, instead of calling my ARM/THUMB code, I get this in the 
disassembly output:

  200558:    f001 f962     bl    201820 <printf>
  20055c:    f007 f9c6     bl    2078ec <____floatsidf_from_thumb>
  200560:    f000 f8e8     bl    200734 <process_run>

yea, it is literally calling the *WRONG* function.

The Assembler code (a .S file) looks like this:

#define DUAL_HEAD( X )  \
    .global    __ ## X ## _from_thumb     ; \
    .code 16             ; \
    .thumb_func            ; \
    .type    __ ## X ## _from_thumb,function ;  \
__ ## X  ## _from_thumb:            ; \
    bx    pc             ; \
    nop                ; \
    .global    X             ; \
    .type    X ,function         ; \
    .code 32            ; \
X :                    ; \

    DUAL_HEAD( ARM_disable_IRQ    )
    mrs    r0,cpsr
    orr    r1,r0,#I_BIT
    msr    cpsr_c,r1
    bx    lr
    .size    ARM_disable_IRQ,(.-ARM_disable_IRQ)

==========================

 From what I can see, I believe I'm constructing the veneer correctly.
But -- Either I'm doing something wrong or - there's a bug in the linker.
I suspect it is me... But... well, I'm not getting anywhere.

==========================

Any suggestions?

Sadly, It is not very simple to reduce this to a _small_ set of code.


--Duane.



--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list