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 call graph analysis fixes for soft-icache code


Error tweaks, and a couple of fixes.  My 2008-12-10 change to consider
sections symbols broke recognition of pasted functions, so I'm reverting
that change.  Extending the range of the first function to the start of
its section fixes the case where we have a function partitioned into
multiple sections, and don't branch into a section at the beginning (as
is likely when entering a loop).

	* elf32-spu.c (spu_elf_find_overlays): Call bfd_set_error on errors.
	(find_function): Likewise.
	(pasted_function): Don't error if no prior function found.
	(discover_functions): Revert 2008-12-10 change.  Extend first
	function range to start of section.

Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.63
diff -u -p -r1.63 elf32-spu.c
--- bfd/elf32-spu.c	4 Feb 2009 02:42:57 -0000	1.63
+++ bfd/elf32-spu.c	9 Feb 2009 14:22:17 -0000
@@ -686,6 +686,7 @@ spu_elf_find_overlays (struct bfd_link_i
 		  info->callbacks->einfo (_("%X%P: overlay section %A "
 					    "does not start on a cache line.\n"),
 					  s);
+		  bfd_set_error (bfd_error_bad_value);
 		  return FALSE;
 		}
 	      else if (s->size > htab->params->line_size)
@@ -693,6 +694,7 @@ spu_elf_find_overlays (struct bfd_link_i
 		  info->callbacks->einfo (_("%X%P: overlay section %A "
 					    "is larger than a cache line.\n"),
 					  s);
+		  bfd_set_error (bfd_error_bad_value);
 		  return FALSE;
 		}
 
@@ -712,6 +714,7 @@ spu_elf_find_overlays (struct bfd_link_i
 	      info->callbacks->einfo (_("%X%P: overlay section %A "
 					"is not in cache area.\n"),
 				      alloc_sec[i-1]);
+	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
 	  else
@@ -752,6 +755,7 @@ spu_elf_find_overlays (struct bfd_link_i
 						"and %A do not start at the "
 						"same address.\n"),
 					      s0, s);
+		      bfd_set_error (bfd_error_bad_value);
 		      return FALSE;
 		    }
 		  if (ovl_end < s->vma + s->size)
@@ -2473,6 +2477,7 @@ find_function (asection *sec, bfd_vma of
     }
   info->callbacks->einfo (_("%A:0x%v not found in function table\n"),
 			  sec, offset);
+  bfd_set_error (bfd_error_bad_value);
   return NULL;
 }
 
@@ -2744,7 +2749,7 @@ mark_functions_via_relocs (asection *sec
    These sections are pasted together to form a single function.  */
 
 static bfd_boolean
-pasted_function (asection *sec, struct bfd_link_info *info)
+pasted_function (asection *sec)
 {
   struct bfd_link_order *l;
   struct _spu_elf_section_data *sec_data;
@@ -2793,8 +2798,9 @@ pasted_function (asection *sec, struct b
 	fun_start = &sinfo->fun[sinfo->num_fun - 1];
     }
 
-  info->callbacks->einfo (_("%A link_order not found\n"), sec);
-  return FALSE;
+  /* Don't return an error if we did not find a function preceding this
+     section.  The section may have incorrect flags.  */
+  return TRUE;
 }
 
 /* Map address ranges in code sections to functions.  */
@@ -2818,7 +2824,6 @@ discover_functions (struct bfd_link_info
   sec_arr = bfd_zmalloc (bfd_idx * sizeof (*sec_arr));
   if (sec_arr == NULL)
     return FALSE;
-
   
   for (ibfd = info->input_bfds, bfd_idx = 0;
        ibfd != NULL;
@@ -2873,8 +2878,7 @@ discover_functions (struct bfd_link_info
       sec_arr[bfd_idx] = psecs;
       for (psy = psyms, p = psecs, sy = syms; sy < syms + symcount; ++p, ++sy)
 	if (ELF_ST_TYPE (sy->st_info) == STT_NOTYPE
-	    || ELF_ST_TYPE (sy->st_info) == STT_FUNC
-	    || ELF_ST_TYPE (sy->st_info) == STT_SECTION)
+	    || ELF_ST_TYPE (sy->st_info) == STT_FUNC)
 	  {
 	    asection *s;
 
@@ -3004,7 +3008,7 @@ discover_functions (struct bfd_link_info
 
 		sec_data = spu_elf_section_data (sec);
 		sinfo = sec_data->u.i.stack_info;
-		if (sinfo != NULL)
+		if (sinfo != NULL && sinfo->num_fun != 0)
 		  {
 		    int fun_idx;
 		    bfd_vma hi = sec->size;
@@ -3014,10 +3018,12 @@ discover_functions (struct bfd_link_info
 			sinfo->fun[fun_idx].hi = hi;
 			hi = sinfo->fun[fun_idx].lo;
 		      }
+
+		    sinfo->fun[0].lo = 0;
 		  }
 		/* No symbols in this section.  Must be .init or .fini
 		   or something similar.  */
-		else if (!pasted_function (sec, info))
+		else if (!pasted_function (sec))
 		  return FALSE;
 	      }
 	}

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