This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

Mixed linking of ARM/THUMB object files


   I tried to link an object file with another one which were generated by arm-elf and 
thumb-elf corssgcc respectively. Of course, both were compiled with the -mthumb-
interwork option. And I found that I should use one of the two which was used to 
compile the file containing main() function to link those object files. Yes, I had no 
problem to link them but when I executed them with the simulator in gdb, program 
exited abnormally probably when thumb-mode code calls arm-mode function like 
this.

C code:
/* foo.c : compiled with arm-elf-gcc */
int my_func()
{
  ...
}

/* main.c : compiled with thumb-elf-gcc and finally linked by the same target linker */
int main()
{
 ...
 my_func();
}

ASM code:
000080c0 <main>:      ### THUMB mode
...
    80ee:       60b8            60b8    str     r0, [r7, #8]
    80f0:       fab2f001        f001    bl      9658 <__my_func_change_to_arm>
...
00008100 <my_func>:     ### ARM mode
    8100:       e1a0c00d        mov     r12, sp
    8104:       e92dd800        stmdb   sp!, {r11, r12, lr, pc}
    8108:       e24cb004        sub     r11, r12, #4    ; 0x4
    810c:       e24dd00c        sub     sp, sp, #12     ; 0xc
...
00009658 <__my_func_change_to_arm>:
    9658:       eafffaa8        b       8100 <my_func>

IMHO, __my_func_change_to_arm should provide more code to change from thumb 
mode to arm mode. Is the crossgcc responsible of this? And how can I cope with 
this?

-----------------
Lim, Sung-taek
totohero@poppy.snu.ac.kr
http://poppy.snu.ac.kr/~totohero/


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