Fix ld-arm bug in encoding of blx calls jumping from thumb to arm instructions

PR 28924
	* elf32-arm.c (THM_MAX_FWD_BRANCH_OFFSET): Fix definition.
	(THM2_MAX_FWD_BRANCH_OFFSET): Likewise.
This commit is contained in:
Viorel Preoteasa
2022-03-18 15:32:28 +00:00
committed by Nick Clifton
parent c4d0963383
commit a747a286b9
2 changed files with 21 additions and 3 deletions
+6
View File
@@ -1,3 +1,9 @@
2022-03-18 Viorel Preoteasa <viorel.preoteasa@gmail.com>
PR 28924
* elf32-arm.c (THM_MAX_FWD_BRANCH_OFFSET): Fix definition.
(THM2_MAX_FWD_BRANCH_OFFSET): Likewise.
2022-03-16 Simon Marchi <simon.marchi@efficios.com>
* Makefile.am (ALL_MACHINES, ALL_MACHINES_CFILES):
+15 -3
View File
@@ -2536,11 +2536,23 @@ static const bfd_vma elf32_arm_nacl_plt_entry [] =
0xea000000, /* b .Lplt_tail */
};
/* PR 28924:
There was a bug due to too high values of THM_MAX_FWD_BRANCH_OFFSET and
THM2_MAX_FWD_BRANCH_OFFSET. The first macro concerns the case when Thumb-2
is not available, and second macro when Thumb-2 is available. Among other
things, they affect the range of branches represented as BLX instructions
in Encoding T2 defined in Section A8.8.25 of the ARM Architecture
Reference Manual ARMv7-A and ARMv7-R edition issue C.d. Such branches are
specified there to have a maximum forward offset that is a multiple of 4.
Previously, the respective values defined here were multiples of 2 but not
4 and they are included in comments for reference. */
#define ARM_MAX_FWD_BRANCH_OFFSET ((((1 << 23) - 1) << 2) + 8)
#define ARM_MAX_BWD_BRANCH_OFFSET ((-((1 << 23) << 2)) + 8)
#define THM_MAX_FWD_BRANCH_OFFSET ((1 << 22) -2 + 4)
#define ARM_MAX_BWD_BRANCH_OFFSET ((-((1 << 23) << 2)) + 8)
#define THM_MAX_FWD_BRANCH_OFFSET ((1 << 22) - 4 + 4)
/* #def THM_MAX_FWD_BRANCH_OFFSET ((1 << 22) - 2 + 4) */
#define THM_MAX_BWD_BRANCH_OFFSET (-(1 << 22) + 4)
#define THM2_MAX_FWD_BRANCH_OFFSET (((1 << 24) - 2) + 4)
#define THM2_MAX_FWD_BRANCH_OFFSET (((1 << 24) - 4) + 4)
/* #def THM2_MAX_FWD_BRANCH_OFFSET (((1 << 24) - 2) + 4) */
#define THM2_MAX_BWD_BRANCH_OFFSET (-(1 << 24) + 4)
#define THM2_MAX_FWD_COND_BRANCH_OFFSET (((1 << 20) -2) + 4)
#define THM2_MAX_BWD_COND_BRANCH_OFFSET (-(1 << 20) + 4)