This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH, binutils/ARM] Fix feature checks based on arch value and force review of logic for new arch
- From: Thomas Preudhomme <thomas dot preudhomme at foss dot arm dot com>
- To: binutils at sourceware dot org
- Date: Wed, 18 May 2016 17:01:38 +0100
- Subject: [PATCH, binutils/ARM] Fix feature checks based on arch value and force review of logic for new arch
- Authentication-results: sourceware.org; auth=none
Hi,
using_thumb2 in bfd/elf32-arm.c currently rely on values for Tag_CPU_arch
bigger than 10 (ARMv7) to be Thumb-2 capable. However this is not true of
ARMv6-M, ARMv6s-M and ARMv8-M Baseline. This patch look first for
Tag_THUMB_ISA_use value and if unavailable or different from 2 (as would be the
case for ARMv8-M Mainline where it would be 3) check Tag_CPU_arch against a
whitelist of values. It also fixes other arch check logics found in the same
file and force review of these logic for new architecture.
ChangeLog entry is as follows:
*** bfd/ChangeLog ***
2016-05-17 Thomas Preud'homme <thomas.preudhomme@arm.com>
* elf32-arm.c (using_thumb_only): Force review of arch check logic for
new architecture.
(using_thumb2): Try Tag_THUMB_ISA_use first and check
for exact arch value then. Force review of arch check logic for new
architecture.
(arch_has_arm_nop): Update and fix arch check logic. Force review of
that logic for new architecture.
(arch_has_thumb2_nop): Remove.
(elf32_arm_tls_relax): Use using_thumb2 instead of above function.
(elf32_arm_final_link_relocate): Likewise but using thumb2.
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index
c21d45a4fbc5e96dd392f0cdbce3e59d7a88aa8c..bf93e9f5b345159a60910f3390a1580f60bee06c
100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -3520,6 +3520,11 @@ using_thumb_only (struct elf32_arm_link_hash_table
*globals)
arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
Tag_CPU_arch);
+ /* Force return logic to be reviewed for each new architecture. */
+ BFD_ASSERT (arch <= TAG_CPU_ARCH_V8
+ || arch == TAG_CPU_ARCH_V8M_BASE
+ || arch == TAG_CPU_ARCH_V8M_MAIN);
+
if (arch == TAG_CPU_ARCH_V6_M
|| arch == TAG_CPU_ARCH_V6S_M
|| arch == TAG_CPU_ARCH_V7E_M
@@ -3535,9 +3540,25 @@ using_thumb_only (struct elf32_arm_link_hash_table
*globals)
static bfd_boolean
using_thumb2 (struct elf32_arm_link_hash_table *globals)
{
- int arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
- Tag_CPU_arch);
- return arch == TAG_CPU_ARCH_V6T2 || arch >= TAG_CPU_ARCH_V7;
+ int arch;
+ int thumb_isa = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
+ Tag_THUMB_ISA_use);
+
+ if (thumb_isa)
+ return thumb_isa == 2;
+
+ arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
Tag_CPU_arch);
+
+ /* Force return logic to be reviewed for each new architecture. */
+ BFD_ASSERT (arch <= TAG_CPU_ARCH_V8
+ || arch == TAG_CPU_ARCH_V8M_BASE
+ || arch == TAG_CPU_ARCH_V8M_MAIN);
+
+ return (arch == TAG_CPU_ARCH_V6T2
+ || arch == TAG_CPU_ARCH_V7
+ || arch == TAG_CPU_ARCH_V7E_M
+ || arch == TAG_CPU_ARCH_V8
+ || arch == TAG_CPU_ARCH_V8M_MAIN);
}
/* Create .plt, .rel(a).plt, .got, .got.plt, .rel(a).got, .dynbss, and
@@ -3742,19 +3763,16 @@ arch_has_arm_nop (struct elf32_arm_link_hash_table
*globals)
{
const int arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
Tag_CPU_arch);
- return arch == TAG_CPU_ARCH_V6T2
- || arch == TAG_CPU_ARCH_V6K
- || arch == TAG_CPU_ARCH_V7
- || arch == TAG_CPU_ARCH_V7E_M;
-}
-static bfd_boolean
-arch_has_thumb2_nop (struct elf32_arm_link_hash_table *globals)
-{
- const int arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
- Tag_CPU_arch);
- return (arch == TAG_CPU_ARCH_V6T2 || arch == TAG_CPU_ARCH_V7
- || arch == TAG_CPU_ARCH_V7E_M);
+ /* Force return logic to be reviewed for each new architecture. */
+ BFD_ASSERT (arch <= TAG_CPU_ARCH_V8
+ || arch == TAG_CPU_ARCH_V8M_BASE
+ || arch == TAG_CPU_ARCH_V8M_MAIN);
+
+ return (arch == TAG_CPU_ARCH_V6T2
+ || arch == TAG_CPU_ARCH_V6K
+ || arch == TAG_CPU_ARCH_V7
+ || arch == TAG_CPU_ARCH_V8);
}
static bfd_boolean
@@ -8827,7 +8845,7 @@ elf32_arm_tls_relax (struct elf32_arm_link_hash_table
*globals,
if (!is_local)
/* add r0,pc; ldr r0, [r0] */
insn = 0x44786800;
- else if (arch_has_thumb2_nop (globals))
+ else if (using_thumb2 (globals))
/* nop.w */
insn = 0xf3af8000;
else
@@ -9657,7 +9675,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *
howto,
if (h && h->root.type == bfd_link_hash_undefweak
&& plt_offset == (bfd_vma) -1)
{
- if (arch_has_thumb2_nop (globals))
+ if (thumb2)
{
bfd_put_16 (input_bfd, 0xf3af, hit_data);
bfd_put_16 (input_bfd, 0x8000, hit_data + 2);
Testsuite shows no regression when run for arm-none-eabi targets.
Is this ok for master branch?
Best regards,
Thomas