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]

modify spu icache --auto-overlay


This patch modifies --auto-overlay for SPU soft-icache to only include
text sections named .text.ia.* in soft-icache lines.  I also add an
option to ignore text section names so that non-icache code can be
linked to icache lines, for those who like to live dangerously.  Such
code will not work correctly if it dereferences function pointers
with targets in icache lines.

bfd/
	* elf32-spu.h (struct spu_elf_params): Add non_ia_text.
	* elf32-spu.c (mark_overlay_section): Only include .text.ia.*
	sections in soft-icache lines unless non_ia_text.  Don't add
	rodata if doing so would exceed line size.
ld/
	* emultempl/spuelf.em (params): Init new field.
	(OPTION_SPU_NON_IA_TEXT): Define.
	(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add --non-ia-text.
	(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_SPU_NON_IA_TEXT.
ld/testsuite/
	* ld-spu/icache1.d: Add --non-ia-text to ld options.

Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.61
diff -u -p -r1.61 elf32-spu.c
--- bfd/elf32-spu.c	12 Jan 2009 14:13:03 -0000	1.61
+++ bfd/elf32-spu.c	21 Jan 2009 01:40:05 -0000
@@ -3279,12 +3279,16 @@ mark_overlay_section (struct function_in
   struct call_info *call;
   unsigned int count;
   struct _mos_param *mos_param = param;
+  struct spu_link_hash_table *htab = spu_hash_table (info);
 
   if (fun->visit4)
     return TRUE;
 
   fun->visit4 = TRUE;
-  if (!fun->sec->linker_mark)
+  if (!fun->sec->linker_mark
+      && (htab->params->ovly_flavour != ovly_soft_icache
+	  || htab->params->non_ia_text
+	  || strncmp (fun->sec->name, ".text.ia.", 9) == 0))
     {
       unsigned int size;
 
@@ -3296,7 +3300,8 @@ mark_overlay_section (struct function_in
 	 this flag to differentiate the two overlay section types.  */
       fun->sec->flags |= SEC_CODE;
 
-      if (spu_hash_table (info)->params->auto_overlay & OVERLAY_RODATA)
+      size = fun->sec->size;
+      if (htab->params->auto_overlay & OVERLAY_RODATA)
 	{
 	  char *name = NULL;
 
@@ -3347,16 +3352,23 @@ mark_overlay_section (struct function_in
 	      fun->rodata = rodata;
 	      if (fun->rodata)
 		{
-		  fun->rodata->linker_mark = 1;
-		  fun->rodata->gc_mark = 1;
-		  fun->rodata->flags &= ~SEC_CODE;
+		  size += fun->rodata->size;
+		  if (htab->params->line_size != 0
+		      && size > htab->params->line_size)
+		    {
+		      size -= fun->rodata->size;
+		      fun->rodata = NULL;
+		    }
+		  else
+		    {
+		      fun->rodata->linker_mark = 1;
+		      fun->rodata->gc_mark = 1;
+		      fun->rodata->flags &= ~SEC_CODE;
+		    }
 		}
 	      free (name);
 	    }
 	}
-      size = fun->sec->size;
-      if (fun->rodata)
-	size += fun->rodata->size;
       if (mos_param->max_overlay_size < size)
 	mos_param->max_overlay_size = size;
     }
Index: bfd/elf32-spu.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.h,v
retrieving revision 1.11
diff -u -p -r1.11 elf32-spu.h
--- bfd/elf32-spu.h	12 Jan 2009 00:23:56 -0000	1.11
+++ bfd/elf32-spu.h	21 Jan 2009 01:40:06 -0000
@@ -53,6 +53,9 @@ struct spu_elf_params
   /* Set if __stack_* syms will be emitted.  */
   unsigned int emit_stack_syms : 1;
 
+  /* Set if non-icache code should be allowed in icache lines.  */
+  unsigned int non_ia_text : 1;
+
   /* Range of valid addresses for loadable sections.  */
   bfd_vma local_store_lo;
   bfd_vma local_store_hi;
Index: ld/emultempl/spuelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/spuelf.em,v
retrieving revision 1.31
diff -u -p -r1.31 spuelf.em
--- ld/emultempl/spuelf.em	12 Jan 2009 00:23:57 -0000	1.31
+++ ld/emultempl/spuelf.em	21 Jan 2009 01:40:11 -0000
@@ -37,7 +37,7 @@ static struct spu_elf_params params =
   &spu_elf_load_ovl_mgr,
   &spu_elf_open_overlay_script,
   &spu_elf_relink,
-  0, ovly_normal, 0, 0, 0, 0, 0,
+  0, ovly_normal, 0, 0, 0, 0, 0, 0,
   0, 0x3ffff,
   1, 0, 16, 0, 0, 2000
 };
@@ -594,7 +594,8 @@ PARSE_AND_LIST_PROLOGUE='
 #define OPTION_SPU_LINE_SIZE		(OPTION_SPU_SOFT_ICACHE + 1)
 #define OPTION_SPU_NUM_LINES		(OPTION_SPU_LINE_SIZE + 1)
 #define OPTION_SPU_LRLIVE		(OPTION_SPU_NUM_LINES + 1)
-#define OPTION_SPU_FIXED_SPACE		(OPTION_SPU_LRLIVE + 1)
+#define OPTION_SPU_NON_IA_TEXT		(OPTION_SPU_LRLIVE + 1)
+#define OPTION_SPU_FIXED_SPACE		(OPTION_SPU_NON_IA_TEXT + 1)
 #define OPTION_SPU_RESERVED_SPACE	(OPTION_SPU_FIXED_SPACE + 1)
 #define OPTION_SPU_EXTRA_STACK		(OPTION_SPU_RESERVED_SPACE + 1)
 #define OPTION_SPU_NO_AUTO_OVERLAY	(OPTION_SPU_EXTRA_STACK + 1)
@@ -606,6 +607,7 @@ PARSE_AND_LIST_LONGOPTS='
   { "lrlive-analysis", no_argument, NULL, OPTION_SPU_LRLIVE },
   { "num-lines", required_argument, NULL, OPTION_SPU_NUM_LINES },
   { "line-size", required_argument, NULL, OPTION_SPU_LINE_SIZE },
+  { "non-ia-text", no_argument, NULL, OPTION_SPU_NON_IA_TEXT },
   { "no-overlays", no_argument, NULL, OPTION_SPU_NO_OVERLAYS },
   { "emit-stub-syms", no_argument, NULL, OPTION_SPU_STUB_SYMS },
   { "extra-overlay-stubs", no_argument, NULL, OPTION_SPU_NON_OVERLAY_STUBS },
@@ -647,6 +649,7 @@ PARSE_AND_LIST_OPTIONS='
   --soft-icache               Generate software icache overlays.\n\
   --num-lines                 Number of soft-icache lines (default 32).\n\
   --line-size                 Size of soft-icache lines (default 1k).\n\
+  --non-ia-text               Allow non-icache code in icache lines.\n\
   --lrlive-analysis           Scan function prologue for lr liveness.\n"
 		   ));
 '
@@ -725,6 +728,10 @@ PARSE_AND_LIST_ARGS_CASES='
       params.lrlive_analysis = 1;
       break;
 
+    case OPTION_SPU_NON_IA_TEXT:
+      params.non_ia_text = 1;
+      break;
+
     case OPTION_SPU_NUM_LINES:
       {
 	char *end;
Index: ld/testsuite/ld-spu/icache1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-spu/icache1.d,v
retrieving revision 1.1
diff -u -p -r1.1 icache1.d
--- ld/testsuite/ld-spu/icache1.d	13 Jan 2009 01:54:15 -0000	1.1
+++ ld/testsuite/ld-spu/icache1.d	21 Jan 2009 01:40:14 -0000
@@ -1,5 +1,5 @@
 #source: icache1.s
-#ld: --soft-icache --num-lines=4 --auto-overlay=tmpdir/icache1.lnk --auto-relink
+#ld: --soft-icache --num-lines=4 --non-ia-text --auto-overlay=tmpdir/icache1.lnk --auto-relink
 #objdump: -D
 
 .* elf32-spu

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