This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: Mixed linking of ARM/THUMB object files
- To: "crossgcc mailinglist" <crossgcc at sourceware dot cygnus dot com>, "binutils mailinglist" <binutils at sourceware dot cygnus dot com>
- Subject: Re: Mixed linking of ARM/THUMB object files
- From: "Lim, Sung-taek" <totohero at poppy dot snu dot ac dot kr>
- Date: Thu, 13 Jan 2000 19:52:25 +0900
- References: <015a01bf5cb6$51846e60$8f742e93@snu.ac.kr>
I think I found a bug of arm-elf (or thumb-elf) targetted ld. When thumb-mode code
calls arm-mode function foo(), ld should generate codes as follows.
.... # thumb mode
b __foo_from_thumb
....
__foo_from_thumb:
....
__foo_change_to_arm:
b foo
but actually ld generated
.... # thumb mode
b __foo_change_to_arm
....
__foo_from_thumb:
.... ( 2 words long)
__foo_change_to_arm:
b foo
and code below the label __foo_from_thumb (2 words long) wasn't executed.
So I modified binutils-991229 (which supports thumb-elf) and my example
program worked successfully with gdb instruction set simulator. I just changed
the digit 4 at line 897 of binutils-991229/bfd/elf32-arm.h to 8.
Any comment is welcome.
----- Original Message -----
From: Lim, Sung-taek <totohero@poppy.snu.ac.kr>
To: crossgcc mailinglist <crossgcc@sourceware.cygnus.com>
Sent: Wednesday, January 12, 2000 1:34 PM
Subject: 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/
>
>