[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gas/12848] New: ARM: Thumb-2: Range check on b.w is off by a factor
From: |
dave.martin at linaro dot org |
Subject: |
[Bug gas/12848] New: ARM: Thumb-2: Range check on b.w is off by a factor of 2 |
Date: |
Mon, 6 Jun 2011 11:18:31 +0000 |
http://sourceware.org/bugzilla/show_bug.cgi?id=12848
Summary: ARM: Thumb-2: Range check on b.w is off by a factor of
2
Product: binutils
Version: 2.22 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: gas
AssignedTo: address@hidden
ReportedBy: address@hidden
The 32-bit Thumb long branch encoding has a range of +/-16MiB, but gas checks
+/-32MiB instead (which is, perhaps coincidentally, the range of the B
instruction in ARM state).
This can result in bogus branch offsets in the assembly output.
Having checked the ARM ARM, this looks like a big in gas, not objdump.
Since this behaviour only affects long distance branches within a single
section (i.e., branches fixed up directly by the assembler) it is unlikely to
be seen often in the wild.
(*) indicates the incorrect branch instructions.
$ binutils/gas/as-new -mthumb -o tst.o tst.s && arm-linux-gnueabi-objdump -d
tst.o
tst.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <e>:
0: f3ff 97ff b.w 1000002 <f+0xffffee> (*)
4: f400 9000 b.w ff000008 <g+0xfd000000>
8: f3ff 97ff b.w 100000a <f+0xfffff6>
c: f400 9000 b.w ff000010 <g+0xfd000008> (*)
10: f7ff bfff b.w 12 <e+0x12> (*)
00000014 <f>:
14: f7ff bff8 b.w 8 <e+0x8> (*)
...
02000008 <g>:
2000008: f000 b804 b.w 2000014 <g+0xc> (*)
$ cat tst.s
.syntax unified
.type f, %function
e:
b . - 0xfffffe @ gas mis-assembles as a forward branch
b . - 0xfffffc
b . + 0x1000002
b . + 0x1000004 @ gas mis-assembles as a backward branch
b . + 0x2000002 @ gas mis-assembles as a backward branch
@ b . + 0x2000004 @ gas correctly detects this as out of range
f: b g @ gas mis-assembles as a backward branch
.space 0x1fffff0
g: b f @ gas mis-assembles as a forward branch
@ If "b.w" is used instead of "b", the results are exactly the same.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
- [Bug gas/12848] New: ARM: Thumb-2: Range check on b.w is off by a factor of 2,
dave.martin at linaro dot org <=
- [Bug gas/12848] ARM: Thumb-2: Range check on b.w is off by a factor of 2, dave.martin at linaro dot org, 2011/06/06
- [Bug gas/12848] ARM: Thumb-2: Range check on b.w is off by a factor of 2, dave.martin at linaro dot org, 2011/06/08
- [Bug gas/12848] ARM: Thumb-2: Range check on b.w is off by a factor of 2, cvs-commit at gcc dot gnu.org, 2011/06/30
- [Bug gas/12848] ARM: Thumb-2: Range check on b.w is off by a factor of 2, cvs-commit at gcc dot gnu.org, 2011/06/30
- [Bug gas/12848] ARM: Thumb-2: Range check on b.w is off by a factor of 2, nickc at redhat dot com, 2011/06/30