[PATCH][Binutils][Arm] gas: fix out of range conditional branch (PR/24991)

Tamar Christina Tamar.Christina@arm.com
Thu Sep 19 13:00:00 GMT 2019


Hi All,

The fix for PR12848 introduced an off by one error in the mask, this corrected
the negative overflows but not the positive overflows.  As a result the
conditional branch instructions accepted a too wide positive immediate which
resulted in it corrupting the instruction during encoding.

The relocation I believe has been incorrectly named, to be consistent with the
other relocations it should have been named BRANCH21 which is why the masks for
it are confusing.

I've replaced the masks with a function out_of_range_p which should make it
harder to make such mistakes.

The mask for BL/BLX on Armv6t+ is also wrong, the extended range is 25-bits
and so the mask should be checking for 24-bits for positive overflow.

build on native hardware and regtested on
  arm-none-elf, arm-none-elf (32 bit host),
  arm-none-linux-gnueabihf, arm-none-linux-gnueabihf (32 bit host)

Cross-compiled and regtested on
  arm-none-linux-gnueabihf, armeb-none-elf, arm-wince-pe

and no issues.

Ok for master?

Thanks,
Tamar

gas/ChangeLog:

2019-09-19  Tamar Christina  <tamar.christina@arm.com>

	PR gas/24991
	* config/tc-arm.c (out_of_range_p): New.
	(md_apply_fix): Use it in BFD_RELOC_THUMB_PCREL_BRANCH9,
	BFD_RELOC_THUMB_PCREL_BRANCH12, BFD_RELOC_THUMB_PCREL_BRANCH20,
	BFD_RELOC_THUMB_PCREL_BRANCH23, BFD_RELOC_THUMB_PCREL_BRANCH25
	* testsuite/gas/arm/pr24991.d: New test.
	* testsuite/gas/arm/pr24991.l: New test.
	* testsuite/gas/arm/pr24991.s: New test.

-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rb11848.patch
Type: text/x-diff
Size: 3975 bytes
Desc: rb11848.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20190919/c95a2bf9/attachment.bin>


More information about the Binutils mailing list