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
- To: Scott Bambrough <scottb at netwinder dot org>
- Subject: Re: arm-elf-as truncates branch offsets w/o warning
- From: Grant Edwards <grante at visi dot com>
- Date: Thu, 16 Mar 2000 19:06:43 -0600
- Cc: binutils at sourceware dot cygnus dot com
- References: <20000316102708.A18044@visi.com> <20000316171956.A5344@visi.com> <38D16B91.6B96150F@netwinder.org>
> > 1) Legal, non-relocatible branch destinations >= 0x0400,00000
> > are not handled correctly and bad code is generated with
> > no error or warning messages.
> Would you have a testcase for this as well?
Here's a slightly different (and easier to work with test case):
------------------------------------------------------------
.section .text0,"ax"
.global _start
_start:
b 0x100
.section .text5,"ax"
label1:
nop
b 0x05000000 @ should be legal if this section is at 0x05000000
nop
------------------------------------------------------------
When this is assembled, with the unpatched assembler, it
generates incorrect code:
testit3.o: file format elf32-littlearm
Disassembly of section .text:
Disassembly of section .text0:
00000000 <_start>:
0: ea00003e b 100 <*ABS*+0x100>
Disassembly of section .text5:
00000000 <label1>:
0: e1a00000 nop (mov r0,r0)
4: ea3ffffe b 1000004 <*ABS*+0x1000004>
8: e1a00000 nop (mov r0,r0)
The code at offset 4 in .text5 is incorrect.
If linked with .text5 at 0x0500,0000 (which conceivably should
might have generated legal code), you get a fixup-error:
$ arm-elf-ld -o testit3 -T testit3.ld testit3.o
testit3.o: In function label1':
testit3.o(.text5+0x4): relocation truncated to fit: R_ARM_PC24 *UND*
If linked with .text5 at 0x0100,0000 (which one would think
should generate a fixup error since you can't jump from
0x0100,0004 from 0x0500,0000) you get the following:
testit3: file format elf32-littlearm
Disassembly of section .text0:
00000000 <_start>:
0: ea00003e b 100 <*ABS*+0x100>
Disassembly of section .text:
Disassembly of section .glue:
Disassembly of section .text5:
01000000 <label1>:
1000000: e1a00000 nop (mov r0,r0)
1000004: eafffffd b 1000000 <label1>
1000008: e1a00000 nop (mov r0,r0)
The brach to 0x0500,0000 has turned into a branch to
0x0100,0000 without any warning.
--
Grant Edwards
grante@visi.com