I've just built an assembler/linker with the options you mention.
Compiling the following testcase:
.text .arm .cpu arm7tdmi .global _start .type _start, %function _start: bl bar bx lr .thumb .global bar .type bar, %function bar: bx lr
Results in:
.../as /tmp/asm.s -o /tmp/asm.o .../ld -o /tmp/asm /tmp/asm.o
.../objdump -d /tmp/asm
/tmp/asm: file format elf32-littlearm
Disassembly of section .text:
00008000 <_start>: 8000: eb000002 bl 8010 <__bar_from_arm> 8004: e12fff1e bx lr
00008008 <bar>: 8008: 4770 bx lr 800a: 46c0 nop ; (mov r8, r8) 800c: 0000 movs r0, r0 ...
00008010 <__bar_from_arm>: 8010: e59fc000 ldr ip, [pc] ; 8018 <__bar_from_arm+0x8> 8014: e12fff1c bx ip 8018: 00008009 .word 0x00008009 801c: 00000000 .word 0x00000000
Change the .cpu directive to .cpu cortex-a9 and you get
objdump -d /tmp/asm
/tmp/asm: file format elf32-littlearm
Disassembly of section .text:
00008000 <_start>: 8000: fa000000 blx 8008 <bar> 8004: e12fff1e bx lr
00008008 <bar>: 8008: 4770 bx lr 800a: bf00 nop
So exactly how are you calling the linker?
The original example I was trying to debug was u-boot, which is a complicated example because it uses a custom linker script and it's own libgcc, but using your "readelf -A" hint I was able to track down that some of my objects were compiled armv5.
I also created a simple 2 function test in C
$ cat main.c void main(void); int arm_incr(int x); void main(void) { int x = arm_incr(2); }
$ cat arm.c int arm_incr(int x) { return x + 1; }
$ arm-cortex_a9-linux-gnueabi-gcc -mcpu=arm7tdmi -march=armv4t -mthumb-interwork -mthumb -c -o main.o main.c $ arm-cortex_a9-linux-gnueabi-gcc -mcpu=arm7tdmi -march=armv4t -mthumb-interwork -marm -o arm.o -c arm.c $ arm-cortex_a9-linux-gnueabi-gcc -mcpu=arm7tdmi -march=armv4t -mthumb-interwork -o thumbtest main.o arm.o
But because I wasn't supplying arm armv4t sysroot it pulled in armv7 crt*.o files so it showed the same problem as my u-boot.
I think this is resolved now, I modified my simple test to use an armv4t sysroot and libgcc and verified it does the correct thing, so I'm confident I can make my u-boot work too. Thanks for your assistance.
-Allen
nvpublic