#463379 objdump -d generates invalid assembler for ARM instruction stmia

Package:
binutils
Source:
binutils
Description:
GNU assembler, linker and binary utilities
Submitter:
Uwe Kleine-König
Date:
2014-12-18 20:21:06 UTC
Severity:
minor
#463379#5
Date:
2008-01-31 09:03:40 UTC
From:
To:
Hello,

	user@debian:/tmp$ cat test.S
	stmia   sp, {r0-r12}
	mov     pc, lr

	user@debian:/tmp$ as test.S

	user@debian:/tmp$ objdump -d a.out

	a.out:     file format elf32-littlearm

	Disassembly of section .text:

	00000000 <.text>:
	   0:   e88d1fff        stm     sp, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip}
	   4:   e1a0f00e        mov     pc, lr

According to the ARM Architecture Reference Manual (Issue I)
stm is not a valid ARM instruction.  The addressing mode is not
optional.  as is able to compile 'stm sp, ...', but using binutils from stable
(i.e. version 2.17-3) I get:

	user@debian:/tmp$ arm-linux-objdump -d a.out

	a.out:     file format elf32-littlearm

	Disassembly of section .text:

	00000000 <.text>:
	   0:   e88d1fff        stmia   sp, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip}
	   4:   e1a0f00e        mov     pc, lr

	user@debian:/tmp$ sed -i s/stmia/stm/ test.S

	user@debian:/tmp$ as test.S
	test.S: Assembler messages:
	test.S:1: Error: bad instruction `stm sp,{r0-r12}'

I have no concerns that as assumes that stm means stmia, but I think the
disassembler should give stmia.

Best regards
Uwe

#463379#10
Date:
2011-06-18 22:02:35 UTC
From:
To:
Hello,

$ cat test.S
stmia	sp, {r0-r12}
stmcsia	sp!, {r0-r12}

$ arm-linux-gnueabi-as test.S

$ objdump -d a.out
...
   0:	e88d1fff 	stm	sp, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip}
   4:	28ad1fff 	stmiacs	sp!, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip}

in the first line "ia" is missing (as reported originally here) and in
the second line "stmiacs" is wrong. When I try to compile test.S after
s/stmcsia/stmiacs/ I get:

	test.S: Assembler messages:
	test.S:2: Error: bad instruction `stmiacs sp!,{r0-r12}'

(using arm-linux-gnueabi-as from emdebian's
binutils-arm-linux-gnueabi 2.20.1-16)

According to ARMARM the syntax of the STM instruction is:

	STM{<cond>}<addressing_mode> ...

that is, cond is first and addressing_mode isn't optional. So that's
what objdump should dump out.

Best regards
Uwe

#463379#17
Date:
2014-12-18 18:29:04 UTC
From:
To:
Closing binutils bug reports reported for ancient versions
of binutils, or for outdated packages built with outdated
versions of binutils.  This doesn't mean that this issue
is fixed, but your help is needed to confirm the issue with
a recent binutils version (currently 2.24.90.20141209-1,
available in unstable).

Please reopen the issue if you think this still needs fixing,
adding all relevant files (including system libraries) in
a tarball attached to the bug report.

#463379#22
Date:
2014-12-18 19:50:56 UTC
From:
To:
Hello,

(I don't understand why you added "wontfix" and hope removing it again
is OK.)

I can reproduce the issue with objdump from binutils-multiarch
2.24.90.20141209-1:

	$ objdump --version | head -n 1
	GNU objdump (GNU Binutils for Debian) 2.24.90

(earlier versions report a longer version number here, e.g.
2.24.90.20141023-1 (current jessie's version) reports

	GNU objdump (GNU Binutils for Debian) 2.24.90.20141023

. Is this intended?)

	$ xxd -r > stm.bin << EOF
	0: 0f00 8de8 0f00 ad28
	EOF

	$ objdump -D -m arm -b binary stm.bin
	...
	   0:	e88d000f 	stm	sp, {r0, r1, r2, r3}
	   4:	28ad000f 	stmiacs	sp!, {r0, r1, r2, r3}

Newer versions of ARMARM than I used back then report "stm" as a valid
instruction with the same meaning as stmia, so I think that's OK today.
"stmiacs" is wrong as before. The pre-UAL syntax is stmcsia, and given
that for stmia the UAL version is given it would be consequent to use
"stmcs" here now.

Note that for the relatives of stm (here: stmda) the following is
documented: STMDA<c> is the UAL instruction name, and "The pre-UAL
syntaxes STM<c>DA and STM<c>ED are equivalent to STMDA<c>." So for them
it's ok to have the condition at the end.

So maybe I'm pedantic, but still getting this consistent (i.e. report
stmcs for the 2nd instruction in the dump above) would be good.
Degrading to severity minor as a compromise.

Unrelated to binutils, rasm2 reports the same instructions:

	$ rasm2 -a arm -b 32 -d -e "0xe88d000f28ad000f"
	disassemble error at offset 8
	stm sp, {r0, r1, r2, r3}
	stmiacs sp!, {r0, r1, r2, r3}
	invalid

Best regards
Uwe