Bug#517875: gcc-4.3: [arm] bad assembly for blx from thumb mode
Package: gcc-4.3
Version: 4.3.2-1.1
Severity: normal
*** Please type your report below this line ***
When assembling a 'blx' from thumb to arm mode, the assembler can generate an
offset which is odd, such as when the address of the blx itself is (2 mod 4).
An odd offset is explicitly forbidden by the ARM Architecture Reference Manual,
ARM DDI 0100E (1996-2000), p.A7-28, Notes: Bit[0] for BLX, "If H==01, then
bit[0] of the instruction must be zero, or the intsruction is UNDEFINED."
When executed on armv5tel, then the CPU gives SIGILL for the odd offset.
Instead, the assembler should clear the low-order bit always.
Testcase:
----- blxbug.S; compile: gcc -o blxbug -nostartfiles -nostdlib blxbug.S
.globl _start
_start:
nop
nop
blx tmode
nop
.code 16
.thumb_func
tmode:
nop
blx amode
nop
.balign 4
.code 32
amode:
nop
-----
Example execution:
(gdb) run
Starting program: blxbug
Program received signal SIGILL, Illegal instruction.
0x00008068 in tmode () ## the middle of the blx instruction at tmode
(gdb) x/i _start
0x8054 <_start>: nop (mov r0,r0)
(gdb)
0x8058 <_start+4>: nop (mov r0,r0)
(gdb)
0x805c <_start+8>: blx 0x8064 <tmode>
(gdb)
0x8060 <_start+12>: nop (mov r0,r0)
(gdb)
0x8064 <tmode>: nop (mov r8, r8)
(gdb)
0x8066 <tmode+2>: blx 0x806c <amode>
(gdb)
0x806a <tmode+6>: nop (mov r8, r8)
(gdb)
0x806c <amode>: nop (mov r0,r0)
(gdb) x/x 0x8066
0x8066 <tmode+2>: 0xe801f000
Should be 0xe800f000
(difference is 0x00010000)
-- System Information:
Debian Release: 5.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: armel (armv5tel)
Kernel: Linux 2.6.26-1-ixp4xx
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages gcc-4.3 depends on:
ii binutils 2.18.1~cvs20080103-7 The GNU assembler, linker and bina
ii cpp-4.3 4.3.2-1.1 The GNU C preprocessor
ii gcc-4.3-base 4.3.2-1.1 The GNU Compiler Collection (base
ii libc6 2.7-18 GNU C Library: Shared libraries
ii libgcc1 1:4.3.2-1.1 GCC support library
ii libgomp1 4.3.2-1.1 GCC OpenMP (GOMP) support library
Versions of packages gcc-4.3 recommends:
ii libc6-dev 2.7-18 GNU C Library: Development Librari
Versions of packages gcc-4.3 suggests:
pn gcc-4.3-doc <none> (no description available)
pn gcc-4.3-locales <none> (no description available)
pn libgcc1-dbg <none> (no description available)
pn libgomp1-dbg <none> (no description available)
pn libmudflap0-4.3-dev <none> (no description available)
pn libmudflap0-dbg <none> (no description available)
-- no debconf information
--
John Reiser, jreiser@BitWagon.com
Reply to: