Aneesh V <ane...@ti.com> wrote on 03/16/2011 10:32:50 AM:

> Can you try this sequence:
>
> arm-linux-gnueabi-gcc -march=armv7-a -mthumb -mthumb-interwork -o foo1.o
> foo1.c -c
> arm-linux-gnueabi-gcc -march=armv7-a -mthumb -mthumb-interwork -o foo2.o
> foo2.S -c
> arm-linux-gnueabi-ld -r foo1.o foo2.o
> arm-linux-gnueabi-objdump -S a.out
>
> With this sequence I get the following output:

> 0000000c <main>:
>     c:   b580         push   {r7, lr}
>     e:   af00         add   r7, sp, #0
>    10:   f7ff fffe    bl   18 <foo>
>    14:   4618         mov   r0, r3
>    16:   bd80         pop   {r7, pc}
>
> 00000018 <foo>:
>    18:   e92d0080    push   {r7}
>    1c:   e28d7000    add   r7, sp, #0
>    20:   e1a0d007    mov   sp, r7
>    24:   e8bd0080    pop   {r7}
>    28:   e12fff1e    bx   lr

Well, sure, but the result of "ld -r" is not a final executable, but just
another relocatable object file.  In particular, it will still carry
relocation records.  In fact, if you add --reloc to the objdump line,
you should see:

0000000c <main>:
   c:   b580            push    {r7, lr}
   e:   af00            add     r7, sp, #0
  10:   f7ff fffe       bl      18 <foo>
                        10: R_ARM_THM_CALL      foo
  14:   4618            mov     r0, r3
  16:   bd80            pop     {r7, pc}

The R_ARM_THM_CALL marks the branch instruction as still to be processed
by the final link step.  And once you actually *perform* the final link,
e.g. via "gcc -o final a.out", the branch gets indeed converted to a blx
by the linker for me:

0000836c <main>:
    836c:       b580            push    {r7, lr}
    836e:       af00            add     r7, sp, #0
    8370:       f000 e802       blx     8378 <foo>
    8374:       4618            mov     r0, r3
    8376:       bd80            pop     {r7, pc}

00008378 <foo>:
    8378:       e92d0080        push    {r7}
    837c:       e28d7000        add     r7, sp, #0
    8380:       e1a0d007        mov     sp, r7
    8384:       e8bd0080        pop     {r7}
    8388:       e12fff1e        bx      lr


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU compiler and toolchain for Linux on System z and Cell/B.E.
  IBM Deutschland Research & Development GmbH
  Vorsitzender des Aufsichtsrats: Martin Jetter | Geschäftsführung: Dirk
Wittkopp
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294


_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to