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]

SPU overlay stub branch check


This is mainly about fixing an incorrect branch offset check.  spu
branches reach +/- 0x2000 but of course that covers the entire local
store, so really there isn't much point in checking that we can reach
a destination.

bfd/
	* elf32-spu.c (build_stub): Allow wraparound on stub branches.
	(allocate_spuear_stubs, build_spuear_stubs): Return value from
	count_stub/build_stub.
	(spu_elf_build_stubs): Correct location of stub reloc error message.
ld/
	* emultempl/spuelf.em (gld${EMULATION_NAME}_finish): Make "can not
	build overlay stubs" a fatal error.
ld/testsuite/
	* ld-spu/ovl.d: Update.
	* ld-spu/ovl2.d: Update.

diff -urp src.old/bfd/elf32-spu.c src/bfd/elf32-spu.c
--- src.old/bfd/elf32-spu.c	2008-06-17 03:01:28.000000000 +0930
+++ src/bfd/elf32-spu.c	2008-06-19 05:43:56.000000000 +0930
@@ -977,7 +977,7 @@ build_stub (struct spu_link_hash_table *
   if (OVL_STUB_SIZE == 16)
     val -= 12;
   if (((dest | to | from) & 3) != 0
-      || val + 0x20000 >= 0x40000)
+      || val + 0x40000 >= 0x80000)
     {
       htab->stub_err = 1;
       return FALSE;
@@ -1083,7 +1083,7 @@ allocate_spuear_stubs (struct elf_link_h
       && (spu_elf_section_data (sym_sec->output_section)->u.o.ovl_index != 0
 	  || htab->non_overlay_stubs))
     {
-      count_stub (htab, NULL, NULL, nonovl_stub, h, NULL);
+      return count_stub (htab, NULL, NULL, nonovl_stub, h, NULL);
     }
   
   return TRUE;
@@ -1109,8 +1109,8 @@ build_spuear_stubs (struct elf_link_hash
       && (spu_elf_section_data (sym_sec->output_section)->u.o.ovl_index != 0
 	  || htab->non_overlay_stubs))
     {
-      build_stub (htab, NULL, NULL, nonovl_stub, h, NULL,
-		  h->root.u.def.value, sym_sec);
+      return build_stub (htab, NULL, NULL, nonovl_stub, h, NULL,
+			 h->root.u.def.value, sym_sec);
     }
   
   return TRUE;
@@ -1461,10 +1461,15 @@ spu_elf_build_stubs (struct bfd_link_inf
 
   /* Fill in all the stubs.  */
   process_stubs (info, TRUE);
+  if (!htab->stub_err)
+    elf_link_hash_traverse (&htab->elf, build_spuear_stubs, info);
 
-  elf_link_hash_traverse (&htab->elf, build_spuear_stubs, info);
   if (htab->stub_err)
-    return FALSE;
+    {
+      (*_bfd_error_handler) (_("overlay stub relocation overflow"));
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
 
   for (i = 0; i <= htab->num_overlays; i++)
     {
@@ -1477,13 +1482,6 @@ spu_elf_build_stubs (struct bfd_link_inf
       htab->stub_sec[i]->rawsize = 0;
     }
 
-  if (htab->stub_err)
-    {
-      (*_bfd_error_handler) (_("overlay stub relocation overflow"));
-      bfd_set_error (bfd_error_bad_value);
-      return FALSE;
-    }
-
   htab->ovtab->contents = bfd_zalloc (htab->ovtab->owner, htab->ovtab->size);
   if (htab->ovtab->contents == NULL)
     return FALSE;
diff -urp src.old/ld/emultempl/spuelf.em src/ld/emultempl/spuelf.em
--- src.old/ld/emultempl/spuelf.em	2008-06-17 03:01:31.000000000 +0930
+++ src/ld/emultempl/spuelf.em	2008-06-19 05:27:47.000000000 +0930
@@ -343,7 +343,7 @@ gld${EMULATION_NAME}_finish (void)
 
       if (!spu_elf_build_stubs (&link_info,
 				emit_stub_syms || link_info.emitrelocations))
-	einfo ("%X%P: can not build overlay stubs: %E\n");
+	einfo ("%F%P: can not build overlay stubs: %E\n");
     }
 
   finish_default ();
diff -urp src.old/ld/testsuite/ld-spu/ovl2.d src/ld/testsuite/ld-spu/ovl2.d
--- src.old/ld/testsuite/ld-spu/ovl2.d	2008-03-14 21:52:08.000000000 +1030
+++ src/ld/testsuite/ld-spu/ovl2.d	2008-06-19 06:14:31.000000000 +0930
@@ -104,12 +104,12 @@ Disassembly of section \.data:
 .*00 00 04 00 .*
 .*00 00 00 20 .*
 #.*00 00 03 10 .*
-.*00 00 03 40 .*
+.*00 00 03 60 .*
 .*00 00 00 01 .*
 .*00 00 04 00 .*
 .*00 00 00 20 .*
 #.*00 00 03 20 .*
-.*00 00 03 60 .*
+.*00 00 03 80 .*
 .*00 00 00 01 .*
 
 00000450 <_ovly_buf_table>:
diff -urp src.old/ld/testsuite/ld-spu/ovl.d src/ld/testsuite/ld-spu/ovl.d
--- src.old/ld/testsuite/ld-spu/ovl.d	2008-02-06 22:47:31.000000000 +1030
+++ src/ld/testsuite/ld-spu/ovl.d	2008-06-19 06:14:31.000000000 +0930
@@ -154,12 +154,12 @@ Disassembly of section .data:
  450:	00 00 04 00 .*
  454:	00 00 00 20 .*
 # 458:	00 00 03 40 .*
- 458:	00 00 03 70 .*
+ 458:	00 00 03 90 .*
  45c:	00 00 00 01 .*
  460:	00 00 04 00 .*
  464:	00 00 00 40 .*
 # 468:	00 00 03 60 .*
- 468:	00 00 03 90 .*
+ 468:	00 00 03 b0 .*
  46c:	00 00 00 01 .*
 
 00000470 <_ovly_buf_table>:

-- 
Alan Modra
Australia Development Lab, IBM


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