arm-elf-as truncates branch offsets w/o warning

Grant Edwards grante@visi.com
Thu Mar 16 17:19:00 GMT 2000


> : ------------------------------testit2.s------------------------------
> :      .text
> :      .org 0x05000000
> :      b    label1
> :      nop
> :      nop
> :      nop
> : label1:
> :      nop
> : --------------------------------------------------------------------
> 
> Great - thanks.  I have now been able to track the cause of the
> assembler's failure to handle this code correctly.  It turns out that
> the assembler was performing an absolute relocation rather than a PC
> relative relocation.  If you try to assemble the following code you
> will also get a bad binary:
> 
>      .text
>      .org 0x100
>      b label1
>      nop
> label1:
>      nop

It looks OK to me -- when I assemble the above and link it with
.text @ 0, I get:

----------------------------------------------------------------------
testit:     file format elf32-littlearm

Disassembly of section .text:

00000000 <label1-0x108>:
	...
 100:	ea000000 	b	108 <label1>
 104:	e1a00000 	nop			(mov r0,r0)

00000108 <label1>:
 108:	e1a00000 	nop			(mov r0,r0)
Disassembly of section .glue:
----------------------------------------------------------------------

Linked with .text @ 1000, I get:

----------------------------------------------------------------------
testit:     file format elf32-littlearm

Disassembly of section .text:

00001000 <label1-0x108>:
	...
    1100:	ea000000 	b	1108 <label1>
    1104:	e1a00000 	nop			(mov r0,r0)

00001108 <label1>:
    1108:	e1a00000 	nop			(mov r0,r0)
Disassembly of section .glue:
----------------------------------------------------------------------


-- 
Grant Edwards
grante@visi.com


More information about the Binutils mailing list