[Patch ARM Gas] ldr/str - Add error for unpredictable cases

James Greenhalgh james.greenhalgh@arm.com
Thu Sep 15 13:26:00 GMT 2011


Hi,

This patch adds an error when performing `ldr r15, .imm' where
imm % 4 != 0, such that the program counter would no longer be
4-byte aligned under arm and thumb.

For example in:

	ldr r15, .-0xab7

I also caught the unpredictable cases of ldr-register under thumb:
ldr rt, [rn, rm] where (rm == r13) || (rm == r15)

For example in:

	ldr r1, [r2, r13]
	ldr r2, [r2, r15]

Likewise, I caught the unpredictable cases of ldr-immedidiate and
str-immediate under thumb:
ldr rt, [rn, #imm]! where (rt == rn) and writeback is enabled.
str rt, [rn, #imm]! where (rt == rn) and writeback is enabled.

For example in:

	ldr r1, [r1, #5]!
	str r1, [r1, #5]!

The patch also adds testcases covering all unpredictable cases
in thumb and arm state for the ldr/str instructions.

Finally the patch corrects the sp-pc-usage-t.s testcase to not
include `ldr sp, [r0, +pc]' which invokes the unpredictable
behaviour described above.

The patch has been tested with no regressions.

Thanks,
James Greenhalgh

gas/

2011-08-26  James Greenhalgh  <james.greenhalgh@arm.com>

	* config/tc-arm.c (check_ldr_r15_aligned): New.
	(do_ldst): Warn in upredictable cases.
	(do_t_ldst): Likewise.
	(insns): Update accordingly.

gas/testsuite

2011-08-26  James Greenhalgh  <james.greenhalgh@arm.com>

	* gas/arm/ldr-bad.s: New testcase.
	* gas/arm/ldr-bad.l: Likewise.
	* gas/arm/ldr-bad.d: Likewise.
	* gas/arm/ldr.s: Likewise.
	* gas/arm/ldr.d: Likewise.
	* gas/arm/ldr-t-bad.s: Likewise.
	* gas/arm/ldr-t-bad.l: Likewise.
	* gas/arm/ldr-t-bad.d: Likewise.
	* gas/arm/ldr-t.s: Likewise.
	* gas/arm/ldr-t.d: Likewise.
	* gas/arm/sp-pc-usage-t.s: Correct.
	* gas/arm/sp-pc-usage-t.d: Update accordingly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Patch-ARM-Gas-Add-error-for-unpredictable-cases-ldr-.patch
Type: text/x-patch
Size: 18320 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20110915/900c0623/attachment.bin>


More information about the Binutils mailing list