[committed] arm: correctly decode Tag_THUMB_ISA_use=3 for thumb2 features

Richard Earnshaw rearnsha@arm.com
Tue May 11 15:23:04 GMT 2021


This was detected when a user accidentally tried to build a shared
library using armv8-m.main objects.  The resulting error was "warning:
thumb-1 mode PLT generation not currently supported".  Something was
clearly wrong because v8-m.main is a thumb-2 variant.

It turns out that the code to detect thumb-2 in object files hadn't
been updated for the extended definition of Tag_THUMB_ISA_use to
support the value 3, meaning 'work it out for yourself from the
architecture tag'; something that is now necessary given that the line
between thumb-1 and thumb-2 has become blurred over time.

Another problem with the function doing this calculation was that the
absence of this tag (implying a default value 0) should mean use of
thumb code was NOT permitted.  However, the code went on to look at
the architecture flags and decide that it could ignore this if the
architecture flags said that thumb2 features were available, thus
completely ignoring the intended meaning.

bfd/

	* elf32-arm.c (using_thumb2): Correctly handle Tag_THUMB_ISA_use
	values 0 and 3.
---
 bfd/elf32-arm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 79b94e836fc..cb567fe82ad 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -3888,9 +3888,11 @@ using_thumb2 (struct elf32_arm_link_hash_table *globals)
   int thumb_isa = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
 					    Tag_THUMB_ISA_use);
 
-  if (thumb_isa)
+  /* No use of thumb permitted, or a legacy thumb-1/2 definition.  */
+  if (thumb_isa < 3)
     return thumb_isa == 2;
 
+  /* Variant of thumb is described by the architecture tag.  */
   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.  */
-- 
2.25.1



More information about the Binutils mailing list