This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Long call support broke Thumb veneers


On Mon, Jun 09, 2008 at 10:29:20AM -0400, Daniel Jacobowitz wrote:
> I've still got concerns about the implementation, but this is clearly
> an improvement.  It's OK; I'll check it in for you, but you may want
> to request a sourceware account.

It does not seem to be against HEAD; it didn't apply.  Here's what
I'll commit if it tests OK.

-- 
Daniel Jacobowitz
CodeSourcery

2008-06-03  Christophe Lyon  <christophe.lyon@st.com>

	bfd/
	* elf32-arm.c (arm_stub_is_thumb): Define.
	(elf32_arm_final_link_relocate): Handle near mode switching stubs.

	ld/testsuite/
	* ld-arm/farcall-thumb-thumb-m.d: Fix branch type.
	* ld-arm/farcall-thumb-arm.d: Likewise.

Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.146
diff -u -p -r1.146 elf32-arm.c
--- bfd/elf32-arm.c	6 Jun 2008 23:20:48 -0000	1.146
+++ bfd/elf32-arm.c	9 Jun 2008 14:37:57 -0000
@@ -2713,6 +2713,23 @@ using_thumb2 (struct elf32_arm_link_hash
   return arch == TAG_CPU_ARCH_V6T2 || arch >= TAG_CPU_ARCH_V7;
 }
 
+static bfd_boolean
+arm_stub_is_thumb (enum elf32_arm_stub_type stub_type)
+{
+  switch (stub_type)
+    {
+    case arm_thumb_thumb_stub_long_branch:
+    case arm_thumb_arm_v4t_stub_long_branch:
+      return TRUE;
+    case arm_stub_none:
+      BFD_FAIL ();
+      return FALSE;
+      break;
+    default:
+      return FALSE;
+    }
+}
+
 /* Determine the type of stub needed, if any, for a call.  */
 
 static enum elf32_arm_stub_type
@@ -6426,7 +6443,8 @@ elf32_arm_final_link_relocate (reloc_how
 		||
 		(thumb2
 		 && (branch_offset > THM2_MAX_FWD_BRANCH_OFFSET
-		     || (branch_offset < THM2_MAX_BWD_BRANCH_OFFSET))))
+		     || (branch_offset < THM2_MAX_BWD_BRANCH_OFFSET)))
+		|| ((sym_flags != STT_ARM_TFUNC) && !globals->use_blx))
 	      {
 		/* The target is out of reach or we are changing modes, so
 		   redirect the branch to the local stub for this
@@ -6439,8 +6457,14 @@ elf32_arm_final_link_relocate (reloc_how
 			   + stub_entry->stub_sec->output_offset
 			   + stub_entry->stub_sec->output_section->vma);
 
-		/* This call becomes a call to Arm for sure. Force BLX.  */
-		lower_insn = (lower_insn & ~0x1000) | 0x0800;
+		/* If this call becomes a call to Arm, force BLX.  */
+		if (globals->use_blx)
+		  {
+		    if ((stub_entry
+			 && !arm_stub_is_thumb (stub_entry->stub_type))
+			|| (sym_flags != STT_ARM_TFUNC))
+		      lower_insn = (lower_insn & ~0x1000) | 0x0800;
+		  }
 	      }
 	  }
 
Index: ld/testsuite/ld-arm/farcall-thumb-arm.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/farcall-thumb-arm.d,v
retrieving revision 1.2
diff -u -p -r1.2 farcall-thumb-arm.d
--- ld/testsuite/ld-arm/farcall-thumb-arm.d	23 May 2008 13:53:27 -0000	1.2
+++ ld/testsuite/ld-arm/farcall-thumb-arm.d	9 Jun 2008 14:37:57 -0000
@@ -12,7 +12,7 @@ Disassembly of section .text:
 	...
 
 00001018 <_start>:
-    1018:	f7ff eff2 	blx	1000 <_start-0x18>
+    1018:	f7ff fff2 	bl	1000 <_start-0x18>
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-thumb-m.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/farcall-thumb-thumb-m.d,v
retrieving revision 1.1
diff -u -p -r1.1 farcall-thumb-thumb-m.d
--- ld/testsuite/ld-arm/farcall-thumb-thumb-m.d	15 May 2008 17:00:15 -0000	1.1
+++ ld/testsuite/ld-arm/farcall-thumb-thumb-m.d	9 Jun 2008 14:37:57 -0000
@@ -12,7 +12,7 @@ Disassembly of section .text:
     100c:	02001015 	.word	0x02001015
 
 00001010 <_start>:
-    1010:	f7ff eff6 	blx	1000 <_start-0x10>
+    1010:	f7ff fff6 	bl	1000 <_start-0x10>
 Disassembly of section .foo:
 
 02001014 <bar>:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]