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]

ARM linker stub changes - placement, PIC


Hi Christophe, others,

I've just finished testing these patches.  The first one changes stubs
to go after input sections by default; my reasoning (as we discussed
last year) is that you can set the start address of sections in linker
scripts, but not the end address.  And fixed start addresses are
likely to be referenced by external entities, like a boot loader or a
hardware interrupt controller.  So this should stop dropping stubs on
top of the reset vector.  No change in testsuite results, but a lot
of churn in the expected output.

The second changes "add pc, pc, ip" to "add ip, pc, ip; bx ip" when
the target is Thumb.  It turns out that add pc does not mode switch on
ARM v6, but does on ARM v7 (sometimes, under some complicated set of
conditions).  Clearly better to avoid it.  This fixes three crashes
when I locally converted the linker dump tests to execution tests.

Comments welcome!  Credit to Joseph for the code in the first patch.

-- 
Daniel Jacobowitz
CodeSourcery
2009-02-23  Joseph Myers  <joseph@codesourcery.com>

	bfd/
	* elf32-arm.c (PREV_SEC): Update comment.
	(group_sections): Rename argument to stubs_always_after_branch.
	Reverse the list and place stubs at the end of input sections.
	Undefine NEXT_SEC.
	(elf32_arm_size_stubs): Update to use stubs_always_after_branch.

	ld/
	* ld.texinfo (ARM): Document changed meaning of --stub-group-size.
	* emultempl/armelf.em (hook_in_stub): Insert after the input section.
	(elf32_arm_add_stub_section): Update comment.
	(PARSE_AND_LIST_OPTIONS): Update help for --stub-group-size.

2009-02-23  Daniel Jacobowitz  <dan@codesourcery.com>

	ld/testsuite/
	* ld-arm/arm-elf.exp (armeabitests): Update duplicate test names.
	Use normal output files for big-endian.
	* ld-arm/farcall-arm-arm-be.d, ld-arm/farcall-thumb-arm-be.d: Delete.
	* ld-arm/farcall-arm-arm-be8.d, ld-arm/farcall-arm-arm-pic-veneer.d,
	ld-arm/farcall-arm-arm.d, ld-arm/farcall-arm-thumb-blx-pic-veneer.d,
	ld-arm/farcall-arm-thumb-blx.d, ld-arm/farcall-arm-thumb-pic-veneer.d,
	ld-arm/farcall-arm-thumb.d, ld-arm/farcall-group-size2.d,
	ld-arm/farcall-group.d, ld-arm/farcall-mix.d, ld-arm/farcall-mix2.d,
	ld-arm/farcall-thumb-arm-be8.d,
	ld-arm/farcall-thumb-arm-blx-pic-veneer.d,
	ld-arm/farcall-thumb-arm-blx.d, ld-arm/farcall-thumb-arm-short.d,
	ld-arm/farcall-thumb-arm.d,
	ld-arm/farcall-thumb-thumb-blx-pic-veneer.d,
	ld-arm/farcall-thumb-thumb-blx.d, ld-arm/farcall-thumb-thumb-m.d,
	ld-arm/farcall-thumb-thumb.d, ld-arm/thumb2-bl-as-thumb1-bad.d,
	ld-arm/thumb2-bl-bad.d: Update for moved stubs.

---
 bfd/elf32-arm.c                                          |   76 +++++++++------
 ld/emultempl/armelf.em                                   |   10 -
 ld/ld.texinfo                                            |    2 
 ld/testsuite/ld-arm/arm-elf.exp                          |    6 -
 ld/testsuite/ld-arm/farcall-arm-arm-be.d                 |   14 --
 ld/testsuite/ld-arm/farcall-arm-arm-be8.d                |   11 +-
 ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d         |   15 +-
 ld/testsuite/ld-arm/farcall-arm-arm.d                    |   11 +-
 ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d   |   15 +-
 ld/testsuite/ld-arm/farcall-arm-thumb-blx.d              |   11 +-
 ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d       |   15 +-
 ld/testsuite/ld-arm/farcall-arm-thumb.d                  |   15 +-
 ld/testsuite/ld-arm/farcall-group-size2.d                |   54 +++++-----
 ld/testsuite/ld-arm/farcall-group.d                      |   55 +++++-----
 ld/testsuite/ld-arm/farcall-mix.d                        |   51 +++++-----
 ld/testsuite/ld-arm/farcall-mix2.d                       |   46 ++++-----
 ld/testsuite/ld-arm/farcall-thumb-arm-be.d               |   17 ---
 ld/testsuite/ld-arm/farcall-thumb-arm-be8.d              |   18 +--
 ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d   |   16 +--
 ld/testsuite/ld-arm/farcall-thumb-arm-blx.d              |   12 +-
 ld/testsuite/ld-arm/farcall-thumb-arm-short.d            |   15 +-
 ld/testsuite/ld-arm/farcall-thumb-arm.d                  |   18 +--
 ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d |   16 +--
 ld/testsuite/ld-arm/farcall-thumb-thumb-blx.d            |   12 +-
 ld/testsuite/ld-arm/farcall-thumb-thumb-m.d              |   22 ++--
 ld/testsuite/ld-arm/farcall-thumb-thumb.d                |   22 ++--
 ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d            |   13 +-
 ld/testsuite/ld-arm/thumb2-bl-bad.d                      |   12 +-
 28 files changed, 312 insertions(+), 288 deletions(-)

Index: bfd/elf32-arm.c
===================================================================
--- bfd/elf32-arm.c.orig	2009-02-23 18:29:25.000000000 -0800
+++ bfd/elf32-arm.c	2009-02-23 18:30:36.000000000 -0800
@@ -3436,7 +3436,7 @@ elf32_arm_next_input_section (struct bfd
 	  /* Steal the link_sec pointer for our list.  */
 #define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
 	  /* This happens to make the list in reverse order,
-	     which is what we want.  */
+	     which we reverse later.  */
 	  PREV_SEC (isec) = *list;
 	  *list = isec;
 	}
@@ -3445,7 +3445,7 @@ elf32_arm_next_input_section (struct bfd
 
 /* See whether we can group stub sections together.  Grouping stub
    sections may result in fewer stubs.  More importantly, we need to
-   put all .init* and .fini* stubs at the beginning of the .init or
+   put all .init* and .fini* stubs at the end of the .init or
    .fini output sections respectively, because glibc splits the
    _init and _fini functions into multiple parts.  Putting a stub in
    the middle of a function is not a good idea.  */
@@ -3453,66 +3453,86 @@ elf32_arm_next_input_section (struct bfd
 static void
 group_sections (struct elf32_arm_link_hash_table *htab,
 		bfd_size_type stub_group_size,
-		bfd_boolean stubs_always_before_branch)
+		bfd_boolean stubs_always_after_branch)
 {
-  asection **list = htab->input_list + htab->top_index;
+  asection **list = htab->input_list;
 
   do
     {
       asection *tail = *list;
+      asection *head;
+      asection *tp;
 
       if (tail == bfd_abs_section_ptr)
 	continue;
 
-      while (tail != NULL)
+      /* Reverse the list: we must avoid placing stubs at the
+	 beginning of the section because the beginning of the text
+	 section may be required for an interrupt vector in bare metal
+	 code.  */
+#define NEXT_SEC PREV_SEC
+      head = tail;
+      tp = NULL;
+      for (;;)
+	{
+	  asection *h = PREV_SEC (head);
+	  NEXT_SEC (head) = tp;
+	  if (h == NULL)
+	    break;
+	  tp = head;
+	  head = h;
+	}
+
+      while (head != NULL)
 	{
 	  asection *curr;
-	  asection *prev;
+	  asection *next;
 	  bfd_size_type total;
 
-	  curr = tail;
-	  total = tail->size;
-	  while ((prev = PREV_SEC (curr)) != NULL
-		 && ((total += curr->output_offset - prev->output_offset)
+	  curr = head;
+	  total = head->size;
+	  while ((next = NEXT_SEC (curr)) != NULL
+		 && ((total += next->output_offset - curr->output_offset)
 		     < stub_group_size))
-	    curr = prev;
+	    curr = next;
 
-	  /* OK, the size from the start of CURR to the end is less
+	  /* OK, the size from the start to the start of CURR is less
 	     than stub_group_size and thus can be handled by one stub
-	     section.  (Or the tail section is itself larger than
+	     section.  (Or the head section is itself larger than
 	     stub_group_size, in which case we may be toast.)
 	     We should really be keeping track of the total size of
 	     stubs added here, as stubs contribute to the final output
 	     section size.  */
 	  do
 	    {
-	      prev = PREV_SEC (tail);
+	      next = NEXT_SEC (head);
 	      /* Set up this stub group.  */
-	      htab->stub_group[tail->id].link_sec = curr;
+	      htab->stub_group[head->id].link_sec = curr;
 	    }
-	  while (tail != curr && (tail = prev) != NULL);
+	  while (head != curr && (head = next) != NULL);
 
 	  /* But wait, there's more!  Input sections up to stub_group_size
-	     bytes before the stub section can be handled by it too.  */
-	  if (!stubs_always_before_branch)
+	     bytes after the stub section can be handled by it too.  */
+	  if (!stubs_always_after_branch)
 	    {
 	      total = 0;
-	      while (prev != NULL
-		     && ((total += tail->output_offset - prev->output_offset)
+	      while (next != NULL
+		     && ((total += next->output_offset - head->output_offset)
 			 < stub_group_size))
 		{
-		  tail = prev;
-		  prev = PREV_SEC (tail);
-		  htab->stub_group[tail->id].link_sec = curr;
+		  head = next;
+		  next = NEXT_SEC (head);
+		  htab->stub_group[head->id].link_sec = curr;
 		}
 	    }
-	  tail = prev;
+	  head = next;
 	}
     }
-  while (list-- != htab->input_list);
+  while (list++ != htab->input_list + htab->top_index);
 
   free (htab->input_list);
 #undef PREV_SEC
+#undef NEXT_SEC
 }
 
 /* Determine and set the size of the stub section for a final link.
@@ -3530,7 +3550,7 @@ elf32_arm_size_stubs (bfd *output_bfd,
 		      void (*layout_sections_again) (void))
 {
   bfd_size_type stub_group_size;
-  bfd_boolean stubs_always_before_branch;
+  bfd_boolean stubs_always_after_branch;
   bfd_boolean stub_changed = 0;
   struct elf32_arm_link_hash_table *htab = elf32_arm_hash_table (info);
 
@@ -3543,7 +3563,7 @@ elf32_arm_size_stubs (bfd *output_bfd,
   htab->stub_bfd = stub_bfd;
   htab->add_stub_section = add_stub_section;
   htab->layout_sections_again = layout_sections_again;
-  stubs_always_before_branch = group_size < 0;
+  stubs_always_after_branch = group_size < 0;
   if (group_size < 0)
     stub_group_size = -group_size;
   else
@@ -3563,7 +3583,7 @@ elf32_arm_size_stubs (bfd *output_bfd,
       stub_group_size = 4170000;
     }
 
-  group_sections (htab, stub_group_size, stubs_always_before_branch);
+  group_sections (htab, stub_group_size, stubs_always_after_branch);
 
   while (1)
     {
Index: ld/ld.texinfo
===================================================================
--- ld/ld.texinfo.orig	2009-02-23 18:20:22.000000000 -0800
+++ ld/ld.texinfo	2009-02-23 18:30:23.000000000 -0800
@@ -5809,7 +5809,7 @@ where they should be placed.
 
 The value of @samp{N}, the parameter to the
 @option{--stub-group-size=} option controls where the stub groups are
-placed.  If it is negative then all stubs are placed before the first
+placed.  If it is negative then all stubs are placed after the first
 branch that needs them.  If it is positive then the stubs can be
 placed either before or after the branches that need them.  If the
 value of @samp{N} is 1 (either +1 or -1) then the linker will choose
Index: ld/emultempl/armelf.em
===================================================================
--- ld/emultempl/armelf.em.orig	2009-02-23 18:19:47.000000000 -0800
+++ ld/emultempl/armelf.em	2009-02-23 18:30:23.000000000 -0800
@@ -220,9 +220,9 @@ hook_in_stub (struct hook_stub_info *inf
 	  if (l->input_section.section == info->input_section)
 	    {
 	      /* We've found our section.  Insert the stub immediately
-		 before its associated input section.  */
-	      *lp = info->add.head;
-	      *(info->add.tail) = l;
+		 after its associated input section.  */
+	      *(info->add.tail) = l->header.next;
+	      l->header.next = info->add.head;
 	      return TRUE;
 	    }
 	  break;
@@ -251,7 +251,7 @@ hook_in_stub (struct hook_stub_info *inf
 /* Call-back for elf32_arm_size_stubs.  */
 
 /* Create a new stub section, and arrange for it to be linked
-   immediately before INPUT_SECTION.  */
+   immediately after INPUT_SECTION.  */
 
 static asection *
 elf32_arm_add_stub_section (const char *stub_sec_name,
@@ -550,7 +550,7 @@ PARSE_AND_LIST_OPTIONS='
   fprintf (file, _("\
    --stub-group-size=N   Maximum size of a group of input sections that can be\n\
                            handled by one stub section.  A negative value\n\
-                           locates all stubs before their branches (with a\n\
+                           locates all stubs after their branches (with a\n\
                            group size of -N), while a positive value allows\n\
                            two groups of input sections, one before, and one\n\
                            after each stub section.  Values of +/-1 indicate\n\
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
--- ld/testsuite/ld-arm/arm-elf.exp.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/arm-elf.exp	2009-02-23 18:30:23.000000000 -0800
@@ -201,7 +201,7 @@ if { ![istarget "arm*-*-*eabi"] } {
 	{"Thumb-2-as-Thumb-1 BL" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {thumb2-bl-as-thumb1-bad.s}
 	    {{objdump -d thumb2-bl-as-thumb1-bad-noeabi.d}}
 	    "thumb2-bl-as-thumb1-bad"}
-	{"Thumb-2 BL" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {thumb2-bl-bad.s}
+	{"Thumb-2 BL bad" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {thumb2-bl-bad.s}
 	    {{objdump -d thumb2-bl-bad-noeabi.d}}
 	    "thumb2-bl-bad"}
     }
@@ -271,7 +271,7 @@ set armeabitests {
      {{objdump -d farcall-arm-arm-be8.d}}
      "farcall-arm-arm-be8"}
     {"ARM-ARM farcall (BE)" "-Ttext 0x1000 --section-start .foo=0x2001020 -EB" "-EB" {farcall-arm-arm.s}
-     {{objdump -d farcall-arm-arm-be.d}}
+     {{objdump -d farcall-arm-arm.d}}
      "farcall-arm-arm-be"}
 
     {"ARM-Thumb farcall" "-Ttext 0x1000 --section-start .foo=0x2001014" "" {farcall-arm-thumb.s}
@@ -307,7 +307,7 @@ set armeabitests {
      {{objdump -d farcall-thumb-arm-be8.d}}
      "farcall-thumb-arm-be8"}
     {"Thumb-ARM farcall (BE)" "-Ttext 0x1000 --section-start .foo=0x2001014 -EB" "-W -EB" {farcall-thumb-arm.s}
-     {{objdump -d farcall-thumb-arm-be.d}}
+     {{objdump -d farcall-thumb-arm.d}}
      "farcall-thumb-arm-be"}
     {"Thumb-ARM (short) call" "-Ttext 0x1000 --section-start .foo=0x0002014" "-W" {farcall-thumb-arm-short.s}
      {{objdump -d farcall-thumb-arm-short.d}}
Index: ld/testsuite/ld-arm/farcall-arm-arm-be.d
===================================================================
--- ld/testsuite/ld-arm/farcall-arm-arm-be.d	2009-02-23 18:29:28.000000000 -0800
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,14 +0,0 @@
-.*:     file format .*
-
-Disassembly of section .text:
-
-00001000 <__bar_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar_veneer\+0x4>
-    1004:	02001020 	.word	0x02001020
-
-00001008 <_start>:
-    1008:	ebfffffc 	bl	1000 <__bar_veneer>
-Disassembly of section .foo:
-
-02001020 <bar>:
- 2001020:	e12fff1e 	bx	lr
Index: ld/testsuite/ld-arm/farcall-arm-arm-be8.d
===================================================================
--- ld/testsuite/ld-arm/farcall-arm-arm-be8.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-arm-arm-be8.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,12 +2,13 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	04f01fe5 	ldr	pc, \[pc, #-4\]	; 1004 <__bar_veneer\+0x4>
-    1004:	02001020 	.word	0x02001020
+00001000 <_start>:
+    1000:	000000eb 	bl	1008 <__bar_veneer>
+    1004:	00000000 	andeq	r0, r0, r0
 
-00001008 <_start>:
-    1008:	fcffffeb 	bl	1000 <__bar_veneer>
+00001008 <__bar_veneer>:
+    1008:	04f01fe5 	ldr	pc, \[pc, #-4\]	; 100c <__bar_veneer\+0x4>
+    100c:	02001020 	.word	0x02001020
 Disassembly of section .foo:
 
 02001020 <bar>:
Index: ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d
===================================================================
--- ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,14 +2,15 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_veneer\+0x8>
-    1004:	e08ff00c 	add	pc, pc, ip
-    1008:	02000014 	.word	0x02000014
-    100c:	00000000 	.word	0x00000000
+00001000 <_start>:
+    1000:	eb000000 	bl	1008 <__bar_veneer>
+    1004:	00000000 	andeq	r0, r0, r0
 
-00001010 <_start>:
-    1010:	ebfffffa 	bl	1000 <__bar_veneer>
+00001008 <__bar_veneer>:
+    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_veneer\+0x8>
+    100c:	e08ff00c 	add	pc, pc, ip
+    1010:	0200000c 	.word	0x0200000c
+    1014:	00000000 	.word	0x00000000
 Disassembly of section .foo:
 
 02001020 <bar>:
Index: ld/testsuite/ld-arm/farcall-arm-arm.d
===================================================================
--- ld/testsuite/ld-arm/farcall-arm-arm.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-arm-arm.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,12 +2,13 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar_veneer\+0x4>
-    1004:	02001020 	.word	0x02001020
+00001000 <_start>:
+    1000:	eb000000 	bl	1008 <__bar_veneer>
+    1004:	00000000 	andeq	r0, r0, r0
 
-00001008 <_start>:
-    1008:	ebfffffc 	bl	1000 <__bar_veneer>
+00001008 <__bar_veneer>:
+    1008:	e51ff004 	ldr	pc, \[pc, #-4\]	; 100c <__bar_veneer\+0x4>
+    100c:	02001020 	.word	0x02001020
 Disassembly of section .foo:
 
 02001020 <bar>:
Index: ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d
===================================================================
--- ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d	2009-02-23 18:30:36.000000000 -0800
@@ -2,14 +2,15 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_arm>:
-    1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_from_arm\+0x8>
-    1004:	e08ff00c 	add	pc, pc, ip
-    1008:	02000009 	.word	0x02000009
-    100c:	00000000 	.word	0x00000000
+00001000 <_start>:
+    1000:	eb000000 	bl	1008 <__bar_from_arm>
+    1004:	00000000 	andeq	r0, r0, r0
 
-00001010 <_start>:
-    1010:	ebfffffa 	bl	1000 <__bar_from_arm>
+00001008 <__bar_from_arm>:
+    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
+    100c:	e08ff00c 	add	pc, pc, ip
+    1010:	02000001 	.word	0x02000001
+    1014:	00000000 	.word	0x00000000
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-arm-thumb-blx.d
===================================================================
--- ld/testsuite/ld-arm/farcall-arm-thumb-blx.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-arm-thumb-blx.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,12 +2,13 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_arm>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar_from_arm\+0x4>
-    1004:	02001015 	.word	0x02001015
+00001000 <_start>:
+    1000:	eb000000 	bl	1008 <__bar_from_arm>
+    1004:	00000000 	andeq	r0, r0, r0
 
-00001008 <_start>:
-    1008:	ebfffffc 	bl	1000 <__bar_from_arm>
+00001008 <__bar_from_arm>:
+    1008:	e51ff004 	ldr	pc, \[pc, #-4\]	; 100c <__bar_from_arm\+0x4>
+    100c:	02001015 	.word	0x02001015
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d
===================================================================
--- ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d	2009-02-23 18:30:36.000000000 -0800
@@ -2,14 +2,15 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_arm>:
-    1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_from_arm\+0x8>
-    1004:	e08ff00c 	add	pc, pc, ip
-    1008:	02000009 	.word	0x02000009
-    100c:	00000000 	.word	0x00000000
+00001000 <_start>:
+    1000:	eb000000 	bl	1008 <__bar_from_arm>
+    1004:	00000000 	andeq	r0, r0, r0
 
-00001010 <_start>:
-    1010:	ebfffffa 	bl	1000 <__bar_from_arm>
+00001008 <__bar_from_arm>:
+    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
+    100c:	e08ff00c 	add	pc, pc, ip
+    1010:	02000001 	.word	0x02000001
+    1014:	00000000 	.word	0x00000000
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-arm-thumb.d
===================================================================
--- ld/testsuite/ld-arm/farcall-arm-thumb.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-arm-thumb.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,14 +2,15 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_arm>:
-    1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_from_arm\+0x8>
-    1004:	e12fff1c 	bx	ip
-    1008:	02001015 	.word	0x02001015
-    100c:	00000000 	.word	0x00000000
+00001000 <_start>:
+    1000:	eb000000 	bl	1008 <__bar_from_arm>
+    1004:	00000000 	andeq	r0, r0, r0
 
-00001010 <_start>:
-    1010:	ebfffffa 	bl	1000 <__bar_from_arm>
+00001008 <__bar_from_arm>:
+    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
+    100c:	e12fff1c 	bx	ip
+    1010:	02001015 	.word	0x02001015
+    1014:	00000000 	.word	0x00000000
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-group-size2.d
===================================================================
--- ld/testsuite/ld-arm/farcall-group-size2.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-group-size2.d	2009-02-23 18:30:23.000000000 -0800
@@ -3,35 +3,35 @@
 
 Disassembly of section .text:
 
-00001000 <__bar2_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar2_veneer\+0x4>
-    1004:	02003024 	.word	0x02003024
-00001008 <__bar_from_arm>:
-    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
-    100c:	e12fff1c 	bx	ip
-    1010:	02003021 	.word	0x02003021
-    1014:	00000000 	.word	0x00000000
-
-00001018 <_start>:
-    1018:	ebfffffa 	bl	1008 <__bar_from_arm>
-    101c:	ebfffff7 	bl	1000 <__bar2_veneer>
-00001020 <__bar3_veneer>:
-    1020:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1024 <__bar3_veneer\+0x4>
-    1024:	02003028 	.word	0x02003028
-00001028 <__bar5_from_arm>:
-    1028:	e59fc000 	ldr	ip, \[pc, #0\]	; 1030 <__bar5_from_arm\+0x8>
-    102c:	e12fff1c 	bx	ip
-    1030:	0200302f 	.word	0x0200302f
-00001034 <__bar4_from_arm>:
-    1034:	e59fc000 	ldr	ip, \[pc, #0\]	; 103c <__bar4_from_arm\+0x8>
-    1038:	e12fff1c 	bx	ip
-    103c:	0200302d 	.word	0x0200302d
+00001000 <_start>:
+    1000:	eb000002 	bl	1010 <__bar_from_arm>
+    1004:	ebffffff 	bl	1008 <__bar2_veneer>
+00001008 <__bar2_veneer>:
+    1008:	e51ff004 	ldr	pc, \[pc, #-4\]	; 100c <__bar2_veneer\+0x4>
+    100c:	02003024 	.word	0x02003024
+00001010 <__bar_from_arm>:
+    1010:	e59fc000 	ldr	ip, \[pc, #0\]	; 1018 <__bar_from_arm\+0x8>
+    1014:	e12fff1c 	bx	ip
+    1018:	02003021 	.word	0x02003021
+    101c:	00000000 	.word	0x00000000
+00001020 <myfunc>:
+    1020:	eb000002 	bl	1030 <__bar3_veneer>
+    1024:	eb000006 	bl	1044 <__bar4_from_arm>
+    1028:	eb000002 	bl	1038 <__bar5_from_arm>
+    102c:	00000000 	andeq	r0, r0, r0
+00001030 <__bar3_veneer>:
+    1030:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1034 <__bar3_veneer\+0x4>
+    1034:	02003028 	.word	0x02003028
+00001038 <__bar5_from_arm>:
+    1038:	e59fc000 	ldr	ip, \[pc, #0\]	; 1040 <__bar5_from_arm\+0x8>
+    103c:	e12fff1c 	bx	ip
+    1040:	0200302f 	.word	0x0200302f
+00001044 <__bar4_from_arm>:
+    1044:	e59fc000 	ldr	ip, \[pc, #0\]	; 104c <__bar4_from_arm\+0x8>
+    1048:	e12fff1c 	bx	ip
+    104c:	0200302d 	.word	0x0200302d
 	...
 
-00001048 <myfunc>:
-    1048:	ebfffff4 	bl	1020 <__bar3_veneer>
-    104c:	ebfffff8 	bl	1034 <__bar4_from_arm>
-    1050:	ebfffff4 	bl	1028 <__bar5_from_arm>
 Disassembly of section .foo:
 
 02003020 <bar>:
Index: ld/testsuite/ld-arm/farcall-group.d
===================================================================
--- ld/testsuite/ld-arm/farcall-group.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-group.d	2009-02-23 18:30:23.000000000 -0800
@@ -3,34 +3,35 @@
 
 Disassembly of section .text:
 
-00001000 <__bar2_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar2_veneer\+0x4>
-    1004:	02003024 	.word	0x02003024
-00001008 <__bar_from_arm>:
-    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
-    100c:	e12fff1c 	bx	ip
-    1010:	02003021 	.word	0x02003021
-00001014 <__bar3_veneer>:
-    1014:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1018 <__bar3_veneer\+0x4>
-    1018:	02003028 	.word	0x02003028
-0000101c <__bar4_from_arm>:
-    101c:	e59fc000 	ldr	ip, \[pc, #0\]	; 1024 <__bar4_from_arm\+0x8>
-    1020:	e12fff1c 	bx	ip
-    1024:	0200302d 	.word	0x0200302d
-00001028 <__bar5_from_arm>:
-    1028:	e59fc000 	ldr	ip, \[pc, #0\]	; 1030 <__bar5_from_arm\+0x8>
-    102c:	e12fff1c 	bx	ip
-    1030:	0200302f 	.word	0x0200302f
+00001000 <_start>:
+    1000:	eb000007 	bl	1024 <__bar_from_arm>
+    1004:	eb00000c 	bl	103c <__bar2_veneer>
+
+00001008 <myfunc>:
+    1008:	eb00000d 	bl	1044 <__bar3_veneer>
+    100c:	eb000007 	bl	1030 <__bar4_from_arm>
+    1010:	eb000000 	bl	1018 <__bar5_from_arm>
+    1014:	00000000 	andeq	r0, r0, r0
+
+00001018 <__bar5_from_arm>:
+    1018:	e59fc000 	ldr	ip, \[pc, #0\]	; 1020 <__bar5_from_arm\+0x8>
+    101c:	e12fff1c 	bx	ip
+    1020:	0200302f 	.word	0x0200302f
+00001024 <__bar_from_arm>:
+    1024:	e59fc000 	ldr	ip, \[pc, #0\]	; 102c <__bar_from_arm\+0x8>
+    1028:	e12fff1c 	bx	ip
+    102c:	02003021 	.word	0x02003021
+00001030 <__bar4_from_arm>:
+    1030:	e59fc000 	ldr	ip, \[pc, #0\]	; 1038 <__bar4_from_arm\+0x8>
+    1034:	e12fff1c 	bx	ip
+    1038:	0200302d 	.word	0x0200302d
+0000103c <__bar2_veneer>:
+    103c:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1040 <__bar2_veneer\+0x4>
+    1040:	02003024 	.word	0x02003024
+00001044 <__bar3_veneer>:
+    1044:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1048 <__bar3_veneer\+0x4>
+    1048:	02003028 	.word	0x02003028
 	...
-
-00001040 <_start>:
-    1040:	ebfffff0 	bl	1008 <__bar_from_arm>
-    1044:	ebffffed 	bl	1000 <__bar2_veneer>
-
-00001048 <myfunc>:
-    1048:	ebfffff1 	bl	1014 <__bar3_veneer>
-    104c:	ebfffff2 	bl	101c <__bar4_from_arm>
-    1050:	ebfffff4 	bl	1028 <__bar5_from_arm>
 Disassembly of section .foo:
 
 02003020 <bar>:
Index: ld/testsuite/ld-arm/farcall-mix.d
===================================================================
--- ld/testsuite/ld-arm/farcall-mix.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-mix.d	2009-02-23 18:30:23.000000000 -0800
@@ -3,32 +3,33 @@
 
 Disassembly of section .text:
 
-00001000 <__bar2_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar2_veneer\+0x4>
-    1004:	02002024 	.word	0x02002024
-00001008 <__bar_from_arm>:
-    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
-    100c:	e12fff1c 	bx	ip
-    1010:	02002021 	.word	0x02002021
-00001014 <__bar3_veneer>:
-    1014:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1018 <__bar3_veneer\+0x4>
-    1018:	02002028 	.word	0x02002028
-0000101c <__bar4_from_arm>:
-    101c:	e59fc000 	ldr	ip, \[pc, #0\]	; 1024 <__bar4_from_arm\+0x8>
-    1020:	e12fff1c 	bx	ip
-    1024:	0200202d 	.word	0x0200202d
-00001028 <__bar5_from_arm>:
-    1028:	e59fc000 	ldr	ip, \[pc, #0\]	; 1030 <__bar5_from_arm\+0x8>
-    102c:	e12fff1c 	bx	ip
-    1030:	0200202f 	.word	0x0200202f
+00001000 <_start>:
+    1000:	eb000004 	bl	1018 <__bar_from_arm>
+    1004:	eb000006 	bl	1024 <__bar2_veneer>
+    1008:	eb00000a 	bl	1038 <__bar3_veneer>
+    100c:	eb00000b 	bl	1040 <__bar4_from_arm>
+    1010:	eb000005 	bl	102c <__bar5_from_arm>
+    1014:	00000000 	andeq	r0, r0, r0
+
+00001018 <__bar_from_arm>:
+    1018:	e59fc000 	ldr	ip, \[pc, #0\]	; 1020 <__bar_from_arm\+0x8>
+    101c:	e12fff1c 	bx	ip
+    1020:	02002021 	.word	0x02002021
+00001024 <__bar2_veneer>:
+    1024:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1028 <__bar2_veneer\+0x4>
+    1028:	02002024 	.word	0x02002024
+0000102c <__bar5_from_arm>:
+    102c:	e59fc000 	ldr	ip, \[pc, #0\]	; 1034 <__bar5_from_arm\+0x8>
+    1030:	e12fff1c 	bx	ip
+    1034:	0200202f 	.word	0x0200202f
+00001038 <__bar3_veneer>:
+    1038:	e51ff004 	ldr	pc, \[pc, #-4\]	; 103c <__bar3_veneer\+0x4>
+    103c:	02002028 	.word	0x02002028
+00001040 <__bar4_from_arm>:
+    1040:	e59fc000 	ldr	ip, \[pc, #0\]	; 1048 <__bar4_from_arm\+0x8>
+    1044:	e12fff1c 	bx	ip
+    1048:	0200202d 	.word	0x0200202d
 	...
-
-00001040 <_start>:
-    1040:	ebfffff0 	bl	1008 <__bar_from_arm>
-    1044:	ebffffed 	bl	1000 <__bar2_veneer>
-    1048:	ebfffff1 	bl	1014 <__bar3_veneer>
-    104c:	ebfffff2 	bl	101c <__bar4_from_arm>
-    1050:	ebfffff4 	bl	1028 <__bar5_from_arm>
 Disassembly of section .foo:
 
 02002020 <bar>:
Index: ld/testsuite/ld-arm/farcall-mix2.d
===================================================================
--- ld/testsuite/ld-arm/farcall-mix2.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-mix2.d	2009-02-23 18:30:23.000000000 -0800
@@ -3,35 +3,37 @@
 
 Disassembly of section .text:
 
-00001000 <__bar2_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar2_veneer\+0x4>
-    1004:	02003024 	.word	0x02003024
+00001000 <_start>:
+    1000:	eb000000 	bl	1008 <__bar_from_arm>
+    1004:	eb000002 	bl	1014 <__bar2_veneer>
+
 00001008 <__bar_from_arm>:
     1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
     100c:	e12fff1c 	bx	ip
     1010:	02003021 	.word	0x02003021
-    1014:	00000000 	.word	0x00000000
-
-00001018 <_start>:
-    1018:	ebfffffa 	bl	1008 <__bar_from_arm>
-    101c:	ebfffff7 	bl	1000 <__bar2_veneer>
+00001014 <__bar2_veneer>:
+    1014:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1018 <__bar2_veneer\+0x4>
+    1018:	02003024 	.word	0x02003024
+    101c:	00000000 	.word	0x00000000
 Disassembly of section .mytext:
 
-00002000 <__bar5_from_arm>:
-    2000:	e59fc000 	ldr	ip, \[pc, #0\]	; 2008 <__bar5_from_arm\+0x8>
-    2004:	e12fff1c 	bx	ip
-    2008:	0200302f 	.word	0x0200302f
-0000200c <__bar3_veneer>:
-    200c:	e51ff004 	ldr	pc, \[pc, #-4\]	; 2010 <__bar3_veneer\+0x4>
-    2010:	02003028 	.word	0x02003028
-00002014 <__bar4_from_arm>:
-    2014:	e59fc000 	ldr	ip, \[pc, #0\]	; 201c <__bar4_from_arm\+0x8>
-    2018:	e12fff1c 	bx	ip
-    201c:	0200302d 	.word	0x0200302d
+00002000 <__bar5_from_arm-0x10>:
+    2000:	eb000005 	bl	201c <__bar3_veneer>
+    2004:	eb000006 	bl	2024 <__bar4_from_arm>
+    2008:	eb000000 	bl	2010 <__bar5_from_arm>
+    200c:	00000000 	andeq	r0, r0, r0
+00002010 <__bar5_from_arm>:
+    2010:	e59fc000 	ldr	ip, \[pc, #0\]	; 2018 <__bar5_from_arm\+0x8>
+    2014:	e12fff1c 	bx	ip
+    2018:	0200302f 	.word	0x0200302f
+0000201c <__bar3_veneer>:
+    201c:	e51ff004 	ldr	pc, \[pc, #-4\]	; 2020 <__bar3_veneer\+0x4>
+    2020:	02003028 	.word	0x02003028
+00002024 <__bar4_from_arm>:
+    2024:	e59fc000 	ldr	ip, \[pc, #0\]	; 202c <__bar4_from_arm\+0x8>
+    2028:	e12fff1c 	bx	ip
+    202c:	0200302d 	.word	0x0200302d
 	...
-    2028:	ebfffff7 	bl	200c <__bar3_veneer>
-    202c:	ebfffff8 	bl	2014 <__bar4_from_arm>
-    2030:	ebfffff2 	bl	2000 <__bar5_from_arm>
 Disassembly of section .foo:
 
 02003020 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-arm-be.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-arm-be.d	2009-02-23 18:29:28.000000000 -0800
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,17 +0,0 @@
-.*:     file format .*
-
-Disassembly of section .text:
-
-00001000 <__bar_from_thumb>:
-    1000:	4778      	bx	pc
-    1002:	46c0      	nop.*
-    1004:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1008 <__bar_from_thumb\+0x8>
-    1008:	02001014 	.word	0x02001014
-    100c:	00000000 	.word	0x00000000
-
-00001010 <_start>:
-    1010:	f7ff fff6 	bl	1000 <__bar_from_thumb>
-Disassembly of section .foo:
-
-02001014 <bar>:
- 2001014:	e12fff1e 	bx	lr
Index: ld/testsuite/ld-arm/farcall-thumb-arm-be8.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-arm-be8.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-arm-be8.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,15 +2,17 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_thumb>:
-    1000:	7847      	bx	pc
-    1002:	c046      	nop.*
-    1004:	04f01fe5 	ldr	pc, \[pc, #-4\]	; 1008 <__bar_from_thumb\+0x8>
-    1008:	02001014 	.word	0x02001014
-    100c:	00000000 	.word	0x00000000
+00001000 <_start>:
+    1000:	00f0 02f8 	bl	1008 <__bar_from_thumb>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001010 <_start>:
-    1010:	fff7 f6ff 	bl	1000 <__bar_from_thumb>
+00001008 <__bar_from_thumb>:
+    1008:	7847      	bx	pc
+    100a:	c046      	nop.*
+    100c:	04f01fe5 	ldr	pc, \[pc, #-4\]	; 1010 <__bar_from_thumb\+0x8>
+    1010:	02001014 	.word	0x02001014
+    1014:	00000000 	.word	0x00000000
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,14 +2,16 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_thumb>:
-    1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_from_thumb\+0x8>
-    1004:	e08ff00c 	add	pc, pc, ip
-    1008:	02000008 	.word	0x02000008
-    100c:	00000000 	.word	0x00000000
+00001000 <_start>:
+    1000:	f000 e802 	blx	1008 <__bar_from_thumb>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001010 <_start>:
-    1010:	f7ff eff6 	blx	1000 <__bar_from_thumb>
+00001008 <__bar_from_thumb>:
+    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_thumb\+0x8>
+    100c:	e08ff00c 	add	pc, pc, ip
+    1010:	02000000 	.word	0x02000000
+    1014:	00000000 	.word	0x00000000
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-arm-blx.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-arm-blx.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-arm-blx.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,12 +2,14 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_thumb>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar_from_thumb\+0x4>
-    1004:	02001014 	.word	0x02001014
+00001000 <_start>:
+    1000:	f000 e802 	blx	1008 <__bar_from_thumb>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001008 <_start>:
-    1008:	f7ff effa 	blx	1000 <__bar_from_thumb>
+00001008 <__bar_from_thumb>:
+    1008:	e51ff004 	ldr	pc, \[pc, #-4\]	; 100c <__bar_from_thumb\+0x4>
+    100c:	02001014 	.word	0x02001014
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-arm-short.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-arm-short.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-arm-short.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,12 +2,15 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_thumb>:
-    1000:	4778      	bx	pc
-    1002:	46c0      	nop			\(mov r8, r8\)
-    1004:	ea000402 	b	2014 <bar>
-00001008 <_start>:
-    1008:	f7ff fffa 	bl	1000 <__bar_from_thumb>
+00001000 <_start>:
+    1000:	f000 f802 	bl	1008 <__bar_from_thumb>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
+
+00001008 <__bar_from_thumb>:
+    1008:	4778      	bx	pc
+    100a:	46c0      	nop			\(mov r8, r8\)
+    100c:	ea000400 	b	2014 <bar>
 Disassembly of section .foo:
 
 00002014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-arm.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-arm.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-arm.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,15 +2,17 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_from_thumb>:
-    1000:	4778      	bx	pc
-    1002:	46c0      	nop			\(mov r8, r8\)
-    1004:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1008 <__bar_from_thumb\+0x8>
-    1008:	02001014 	.word	0x02001014
-    100c:	00000000 	.word	0x00000000
+00001000 <_start>:
+    1000:	f000 f802 	bl	1008 <__bar_from_thumb>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001010 <_start>:
-    1010:	f7ff fff6 	bl	1000 <__bar_from_thumb>
+00001008 <__bar_from_thumb>:
+    1008:	4778      	bx	pc
+    100a:	46c0      	nop			\(mov r8, r8\)
+    100c:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1010 <__bar_from_thumb\+0x8>
+    1010:	02001014 	.word	0x02001014
+    1014:	00000000 	.word	0x00000000
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d	2009-02-23 18:30:36.000000000 -0800
@@ -2,14 +2,16 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	e59fc000 	ldr	ip, \[pc, #0\]	; 1008 <__bar_veneer\+0x8>
-    1004:	e08ff00c 	add	pc, pc, ip
-    1008:	02000009 	.word	0x02000009
-    100c:	00000000 	.word	0x00000000
+00001000 <_start>:
+    1000:	f000 e802 	blx	1008 <__bar_veneer>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001010 <_start>:
-    1010:	f7ff eff6 	blx	1000 <__bar_veneer>
+00001008 <__bar_veneer>:
+    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_veneer\+0x8>
+    100c:	e08ff00c 	add	pc, pc, ip
+    1010:	02000001 	.word	0x02000001
+    1014:	00000000 	.word	0x00000000
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-thumb-blx.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-thumb-blx.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-thumb-blx.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,12 +2,14 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar_veneer\+0x4>
-    1004:	02001015 	.word	0x02001015
+00001000 <_start>:
+    1000:	f000 e802 	blx	1008 <__bar_veneer>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001008 <_start>:
-    1008:	f7ff effa 	blx	1000 <__bar_veneer>
+00001008 <__bar_veneer>:
+    1008:	e51ff004 	ldr	pc, \[pc, #-4\]	; 100c <__bar_veneer\+0x4>
+    100c:	02001015 	.word	0x02001015
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-thumb-m.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-thumb-m.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-thumb-m.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,17 +2,19 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	b401      	push	{r0}
-    1002:	4802      	ldr	r0, \[pc, #8\]	\(100c <__bar_veneer\+0xc>\)
-    1004:	4684      	mov	ip, r0
-    1006:	bc01      	pop	{r0}
-    1008:	4760      	bx	ip
-    100a:	bf00      	nop
-    100c:	02001015 	.word	0x02001015
+00001000 <_start>:
+    1000:	f000 f802 	bl	1008 <__bar_veneer>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001010 <_start>:
-    1010:	f7ff fff6 	bl	1000 <__bar_veneer>
+00001008 <__bar_veneer>:
+    1008:	b401      	push	{r0}
+    100a:	4802      	ldr	r0, \[pc, #8\]	\(1014 <__bar_veneer\+0xc>\)
+    100c:	4684      	mov	ip, r0
+    100e:	bc01      	pop	{r0}
+    1010:	4760      	bx	ip
+    1012:	bf00      	nop
+    1014:	02001015 	.word	0x02001015
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/farcall-thumb-thumb.d
===================================================================
--- ld/testsuite/ld-arm/farcall-thumb-thumb.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/farcall-thumb-thumb.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,17 +2,19 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	b401      	push	{r0}
-    1002:	4802      	ldr	r0, \[pc, #8\]	\(100c <__bar_veneer\+0xc>\)
-    1004:	4684      	mov	ip, r0
-    1006:	bc01      	pop	{r0}
-    1008:	4760      	bx	ip
-    100a:	bf00      	nop
-    100c:	02001015 	.word	0x02001015
+00001000 <_start>:
+    1000:	f000 f802 	bl	1008 <__bar_veneer>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001010 <_start>:
-    1010:	f7ff fff6 	bl	1000 <__bar_veneer>
+00001008 <__bar_veneer>:
+    1008:	b401      	push	{r0}
+    100a:	4802      	ldr	r0, \[pc, #8\]	\(1014 <__bar_veneer\+0xc>\)
+    100c:	4684      	mov	ip, r0
+    100e:	bc01      	pop	{r0}
+    1010:	4760      	bx	ip
+    1012:	bf00      	nop
+    1014:	02001015 	.word	0x02001015
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d
===================================================================
--- ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d.orig	2009-02-23 18:29:28.000000000 -0800
+++ ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,12 +2,15 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar_veneer\+0x4>
-    1004:	0100100d 	.word	0x0100100d
+00001000 <_start>:
+    1000:	f000 e802 	blx	1008 <__bar_veneer>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
+
+00001008 <__bar_veneer>:
+    1008:	e51ff004 	ldr	pc, \[pc, #-4\]	; 100c <__bar_veneer\+0x4>
+    100c:	0100100d 	.word	0x0100100d
 
-00001008 <_start>:
-    1008:	f7ff effa 	blx	1000 <__bar_veneer>
 Disassembly of section .foo:
 
 0100100c <bar>:
Index: ld/testsuite/ld-arm/thumb2-bl-bad.d
===================================================================
--- ld/testsuite/ld-arm/thumb2-bl-bad.d.orig	2009-02-23 18:20:02.000000000 -0800
+++ ld/testsuite/ld-arm/thumb2-bl-bad.d	2009-02-23 18:30:23.000000000 -0800
@@ -2,12 +2,14 @@
 
 Disassembly of section .text:
 
-00001000 <__bar_veneer>:
-    1000:	e51ff004 	ldr	pc, \[pc, #-4\]	; 1004 <__bar_veneer\+0x4>
-    1004:	0100100d 	.word	0x0100100d
+00001000 <_start>:
+    1000:	f000 e802 	blx	1008 <__bar_veneer>
+    1004:	0000      	lsls	r0, r0, #0
+	\.\.\.
 
-00001008 <_start>:
-    1008:	f7ff effa 	blx	1000 <__bar_veneer>
+00001008 <__bar_veneer>:
+    1008:	e51ff004 	ldr	pc, \[pc, #-4\]	; 100c <__bar_veneer\+0x4>
+    100c:	0100100d 	.word	0x0100100d
 Disassembly of section .foo:
 
 0100100c <bar>:
2009-02-23  Daniel Jacobowitz  <dan@codesourcery.com>

	bfd/
	* elf32-arm.c (elf32_arm_stub_long_branch_any_any_pic): Rename
	to elf32_arm_stub_long_branch_any_arm_pic.
	(elf32_arm_stub_long_branch_any_thumb_pic): New.
	(enum elf32_arm_stub_type, arm_type_of_stub)
	(arm_size_one_stub): Handle any to ARM PIC and any to Thumb PIC
	separately.

	ld/testsuite/
	* ld-arm/farcall-arm-thumb-blx-pic-veneer.d,
	ld-arm/farcall-arm-thumb-pic-veneer.d,
	ld-arm/farcall-thumb-thumb-blx-pic-veneer.d: Update for fixed
	Thumb PIC stub.

---
 bfd/elf32-arm.c                                          |   37 ++++++++++-----
 ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d   |    8 +--
 ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d       |    8 +--
 ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d |    8 +--
 4 files changed, 39 insertions(+), 22 deletions(-)

Index: binutils-trunk/bfd/elf32-arm.c
===================================================================
--- binutils-trunk.orig/bfd/elf32-arm.c	2009-02-23 18:30:23.000000000 -0800
+++ binutils-trunk/bfd/elf32-arm.c	2009-02-23 18:30:31.000000000 -0800
@@ -2094,15 +2094,27 @@ static const insn_sequence elf32_arm_stu
     ARM_REL_INSN(0xea000000, -8),     /* b    (X-8) */
   };
 
-/* ARM/Thumb -> ARM/Thumb long branch stub, PIC. On V5T and above, use
+/* ARM/Thumb -> ARM long branch stub, PIC.  On V5T and above, use
    blx to reach the stub if necessary.  */
-static const insn_sequence elf32_arm_stub_long_branch_any_any_pic[] =
+static const insn_sequence elf32_arm_stub_long_branch_any_arm_pic[] =
   {
     ARM_INSN(0xe59fc000),             /* ldr   r12, [pc] */
     ARM_INSN(0xe08ff00c),             /* add   pc, pc, ip */
     DATA_WORD(0, R_ARM_REL32, -4),    /* dcd   R_ARM_REL32(X-4) */
   };
 
+/* ARM/Thumb -> Thumb long branch stub, PIC.  On V5T and above, use
+   blx to reach the stub if necessary.  We can not add into pc;
+   it is not guaranteed to mode switch (different in ARMv6 and
+   ARMv7).  */
+static const insn_sequence elf32_arm_stub_long_branch_any_thumb_pic[] =
+  {
+    ARM_INSN(0xe59fc004),             /* ldr   r12, [pc, #4] */
+    ARM_INSN(0xe08fc00c),             /* add   ip, pc, ip */
+    ARM_INSN(0xe12fff1c),             /* bx    ip */
+    DATA_WORD(0, R_ARM_REL32, 0),     /* dcd   R_ARM_REL32(X) */
+  };
+
 /* Section name for stubs is the associated section name plus this
    string.  */
 #define STUB_SUFFIX ".stub"
@@ -2115,7 +2127,8 @@ enum elf32_arm_stub_type
   arm_stub_long_branch_thumb_only,
   arm_stub_long_branch_v4t_thumb_arm,
   arm_stub_short_branch_v4t_thumb_arm,
-  arm_stub_long_branch_any_any_pic,
+  arm_stub_long_branch_any_arm_pic,
+  arm_stub_long_branch_any_thumb_pic,
 };
 
 struct elf32_arm_stub_hash_entry
@@ -2877,7 +2890,7 @@ arm_type_of_stub (struct bfd_link_info *
 		    /* PIC stubs.  */
 		    ? ((globals->use_blx)
 		       /* V5T and above.  */
-		       ? arm_stub_long_branch_any_any_pic
+		       ? arm_stub_long_branch_any_thumb_pic
 		       /* not yet supported on V4T.  */
 		       : arm_stub_none)
 
@@ -2914,7 +2927,7 @@ arm_type_of_stub (struct bfd_link_info *
 		/* PIC stubs.  */
 		? ((globals->use_blx)
 		   /* V5T and above.  */
-		   ? arm_stub_long_branch_any_any_pic
+		   ? arm_stub_long_branch_any_arm_pic
 		   /* not yet supported on V4T.  */
 		   : arm_stub_none)
 
@@ -2957,7 +2970,7 @@ arm_type_of_stub (struct bfd_link_info *
 	    {
 	      stub_type = (info->shared | globals->pic_veneer)
 		/* PIC stubs.  */
-		? arm_stub_long_branch_any_any_pic
+		? arm_stub_long_branch_any_thumb_pic
 		/* non-PIC stubs.  */
 		: ((globals->use_blx)
 		   /* V5T and above.  */
@@ -2974,7 +2987,7 @@ arm_type_of_stub (struct bfd_link_info *
 	    {
 	      stub_type = (info->shared | globals->pic_veneer)
 		/* PIC stubs.  */
-		? arm_stub_long_branch_any_any_pic
+		? arm_stub_long_branch_any_arm_pic
 		/* non-PIC stubs.  */
 		: arm_stub_long_branch_any_any;
 	    }
@@ -3296,9 +3309,13 @@ arm_size_one_stub (struct bfd_hash_entry
       template =  elf32_arm_stub_short_branch_v4t_thumb_arm;
       template_size = sizeof (elf32_arm_stub_short_branch_v4t_thumb_arm) / sizeof (insn_sequence);
       break;
-    case arm_stub_long_branch_any_any_pic:
-      template = elf32_arm_stub_long_branch_any_any_pic;
-      template_size = sizeof (elf32_arm_stub_long_branch_any_any_pic) / sizeof (insn_sequence);
+    case arm_stub_long_branch_any_arm_pic:
+      template = elf32_arm_stub_long_branch_any_arm_pic;
+      template_size = sizeof (elf32_arm_stub_long_branch_any_arm_pic) / sizeof (insn_sequence);
+      break;
+    case arm_stub_long_branch_any_thumb_pic:
+      template = elf32_arm_stub_long_branch_any_thumb_pic;
+      template_size = sizeof (elf32_arm_stub_long_branch_any_thumb_pic) / sizeof (insn_sequence);
       break;
     default:
       BFD_FAIL ();
Index: binutils-trunk/ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d
===================================================================
--- binutils-trunk.orig/ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d	2009-02-23 18:30:23.000000000 -0800
+++ binutils-trunk/ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d	2009-02-23 18:30:31.000000000 -0800
@@ -7,10 +7,10 @@ Disassembly of section .text:
     1004:	00000000 	andeq	r0, r0, r0
 
 00001008 <__bar_from_arm>:
-    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
-    100c:	e08ff00c 	add	pc, pc, ip
-    1010:	02000001 	.word	0x02000001
-    1014:	00000000 	.word	0x00000000
+    1008:	e59fc004 	ldr	ip, \[pc, #4\]	; 1014 <__bar_from_arm\+0xc>
+    100c:	e08fc00c 	add	ip, pc, ip
+    1010:	e12fff1c 	bx	ip
+    1014:	02000001 	.word	0x02000001
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: binutils-trunk/ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d
===================================================================
--- binutils-trunk.orig/ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d	2009-02-23 18:30:23.000000000 -0800
+++ binutils-trunk/ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d	2009-02-23 18:30:31.000000000 -0800
@@ -7,10 +7,10 @@ Disassembly of section .text:
     1004:	00000000 	andeq	r0, r0, r0
 
 00001008 <__bar_from_arm>:
-    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_from_arm\+0x8>
-    100c:	e08ff00c 	add	pc, pc, ip
-    1010:	02000001 	.word	0x02000001
-    1014:	00000000 	.word	0x00000000
+    1008:	e59fc004 	ldr	ip, \[pc, #4\]	; 1014 <__bar_from_arm\+0xc>
+    100c:	e08fc00c 	add	ip, pc, ip
+    1010:	e12fff1c 	bx	ip
+    1014:	02000001 	.word	0x02000001
 Disassembly of section .foo:
 
 02001014 <bar>:
Index: binutils-trunk/ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d
===================================================================
--- binutils-trunk.orig/ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d	2009-02-23 18:30:23.000000000 -0800
+++ binutils-trunk/ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d	2009-02-23 18:30:31.000000000 -0800
@@ -8,10 +8,10 @@ Disassembly of section .text:
 	\.\.\.
 
 00001008 <__bar_veneer>:
-    1008:	e59fc000 	ldr	ip, \[pc, #0\]	; 1010 <__bar_veneer\+0x8>
-    100c:	e08ff00c 	add	pc, pc, ip
-    1010:	02000001 	.word	0x02000001
-    1014:	00000000 	.word	0x00000000
+    1008:	e59fc004 	ldr	ip, \[pc, #4\]	; 1014 <__bar_veneer\+0xc>
+    100c:	e08fc00c 	add	ip, pc, ip
+    1010:	e12fff1c 	bx	ip
+    1014:	02000001 	.word	0x02000001
 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]