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 soft-icache no stubs but need manager


It's possible to generate soft-icache code that needs no stubs,
when all control transfers between lines happen via inlined
indirect calls.  We still need the icache manager and its data..

	* elf32-spu.c (spu_elf_size_stubs): Do set up soft-icache manager
	data even when no stubs.
	(spu_elf_place_overlay_data, spu_elf_build_stubs): Adjust.

Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.85
diff -u -p -w -r1.85 elf32-spu.c
--- bfd/elf32-spu.c	9 Jul 2009 10:58:06 -0000	1.85
+++ bfd/elf32-spu.c	10 Jul 2009 04:57:49 -0000
@@ -1627,7 +1627,7 @@ process_stubs (struct bfd_link_info *inf
 }
 
 /* Allocate space for overlay call and return stubs.
-   Return 0 on error, 1 if no stubs, 2 otherwise.  */
+   Return 0 on error, 1 if no overlays, 2 otherwise.  */
 
 int
 spu_elf_size_stubs (struct bfd_link_info *info)
@@ -1647,10 +1647,9 @@ spu_elf_size_stubs (struct bfd_link_info
   if (htab->stub_err)
     return 0;
 
-  if (htab->stub_count == NULL)
-    return 1;
-
   ibfd = info->input_bfds;
+  if (htab->stub_count != NULL)
+    {
   amt = (htab->num_overlays + 1) * sizeof (*htab->stub_sec);
   htab->stub_sec = bfd_zmalloc (amt);
   if (htab->stub_sec == NULL)
@@ -1681,6 +1680,7 @@ spu_elf_size_stubs (struct bfd_link_info
 	return 0;
       stub->size = htab->stub_count[ovl] * ovl_stub_size (htab->params);
     }
+    }
 
   if (htab->params->ovly_flavour == ovly_soft_icache)
     {
@@ -1707,6 +1707,8 @@ spu_elf_size_stubs (struct bfd_link_info
 
       htab->init->size = 16;
     }
+  else if (htab->stub_count == NULL)
+    return 1;
   else
     {
       /* htab->ovtab consists of two arrays.
@@ -1750,11 +1752,9 @@ spu_elf_place_overlay_data (struct bfd_l
 {
   struct spu_link_hash_table *htab = spu_hash_table (info);
   unsigned int i;
-  const char *ovout;
-
-  if (htab->stub_count == NULL)
-    return;
 
+  if (htab->stub_sec != NULL)
+    {
   (*htab->params->place_spu_section) (htab->stub_sec[0], NULL, ".text");
 
   for (i = 0; i < htab->num_overlays; ++i)
@@ -1763,15 +1763,20 @@ spu_elf_place_overlay_data (struct bfd_l
       unsigned int ovl = spu_elf_section_data (osec)->u.o.ovl_index;
       (*htab->params->place_spu_section) (htab->stub_sec[ovl], osec, NULL);
     }
+    }
 
   if (htab->params->ovly_flavour == ovly_soft_icache)
     (*htab->params->place_spu_section) (htab->init, NULL, ".ovl.init");
 
-  ovout = ".data";
+  if (htab->ovtab != NULL)
+    {
+      const char *ovout = ".data";
   if (htab->params->ovly_flavour == ovly_soft_icache)
     ovout = ".bss";
   (*htab->params->place_spu_section) (htab->ovtab, NULL, ovout);
+    }
 
+  if (htab->toe != NULL)
   (*htab->params->place_spu_section) (htab->toe, NULL, ".toe");
 }
 
@@ -1883,26 +1888,13 @@ spu_elf_build_stubs (struct bfd_link_inf
   bfd *obfd;
   unsigned int i;
 
-  if (htab->stub_count == NULL)
-    return TRUE;
-
-  for (i = 0; i <= htab->num_overlays; i++)
-    if (htab->stub_sec[i]->size != 0)
+  if (htab->num_overlays != 0)
       {
-	htab->stub_sec[i]->contents = bfd_zalloc (htab->stub_sec[i]->owner,
-						  htab->stub_sec[i]->size);
-	if (htab->stub_sec[i]->contents == NULL)
-	  return FALSE;
-	htab->stub_sec[i]->rawsize = htab->stub_sec[i]->size;
-	htab->stub_sec[i]->size = 0;
-      }
-
   for (i = 0; i < 2; i++)
     {
       h = htab->ovly_entry[i];
-      BFD_ASSERT (h != NULL);
-
-      if ((h->root.type == bfd_link_hash_defined
+	  if (h != NULL
+	      && (h->root.type == bfd_link_hash_defined
 	   || h->root.type == bfd_link_hash_defweak)
 	  && h->def_regular)
 	{
@@ -1915,8 +1907,20 @@ spu_elf_build_stubs (struct bfd_link_inf
 	      return FALSE;
 	    }
 	}
-      else
-	BFD_ASSERT (0);
+	}
+    }
+
+  if (htab->stub_sec != NULL)
+    {
+      for (i = 0; i <= htab->num_overlays; i++)
+	if (htab->stub_sec[i]->size != 0)
+	  {
+	    htab->stub_sec[i]->contents = bfd_zalloc (htab->stub_sec[i]->owner,
+						      htab->stub_sec[i]->size);
+	    if (htab->stub_sec[i]->contents == NULL)
+	      return FALSE;
+	    htab->stub_sec[i]->rawsize = htab->stub_sec[i]->size;
+	    htab->stub_sec[i]->size = 0;
     }
 
   /* Fill in all the stubs.  */
@@ -1941,6 +1945,7 @@ spu_elf_build_stubs (struct bfd_link_inf
 	}
       htab->stub_sec[i]->rawsize = 0;
     }
+    }
 
   if (htab->ovtab == NULL || htab->ovtab->size == 0)
     return TRUE;

-- 
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]