This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: arm-elf-as truncates branch offsets w/o warning
> ------------------------------testit2.s------------------------------
> .text
> .org 0x05000000
> b label1
> nop
> nop
> nop
> label1:
> nop
> --------------------------------------------------------------------
It doesn't appear to be possible to link an object file
produced by assembling the above case (final link failed:
Memory exhausted), so it's probably a moot question whether the
file contains incorrect object code or not. ;)
However, the other case (non-reloc dest < 0x0400,0000 with
offset too large for the branch instruction) can be linked:
------------------------------testit.s------------------------------
.text
.org 0x0020
b label1
.org 0x02001000
label1:
nop
--------------------------------------------------------------------
The ARM branch instruction can only handle offsets of
-0x2000000 to +0x1ffffff, so the above jump isn't legal, but it
assembles and produces bad code:
$ arm-elf-as -o testit.o testit.s
**** this should have generated an error ****
$ arm-elf-objdump --source testit.o
testit.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <label1-0x2001000>:
...
20: ea8003fe b fe001020 <label1+0xfc000020>
...
02001000 <label1>:
2001000: e1a00000 nop (mov r0,r0)
$ arm-elf-ld -o testit testit.o
arm-elf-ld: warning: cannot find entry symbol _start; defaulting to 00008000
$ arm-elf-objdump --source testit
testit: file format elf32-littlearm
Disassembly of section .text:
00008000 <label1-0x2001000>:
...
8020: ea8003f6 b fe009000 <__bss_end__+0xfbfffefc>
...
02009000 <label1>:
2009000: e1a00000 nop (mov r0,r0)
--
Grant Edwards
grante@visi.com