Fix spu-ld segfault

Alan Modra amodra@bigpond.net.au
Wed Jul 11 23:11:00 GMT 2007


	* emultempl/spuelf.em (embedded_spu_file): Test for NULL path
	before calling base_name, not after.

Index: ld/emultempl/spuelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/spuelf.em,v
retrieving revision 1.10
diff -u -p -r1.10 spuelf.em
--- ld/emultempl/spuelf.em	6 Jul 2007 14:09:42 -0000	1.10
+++ ld/emultempl/spuelf.em	11 Jul 2007 22:55:29 -0000
@@ -345,19 +345,19 @@ embedded_spu_file (lang_input_statement_
   for (search = (lang_input_statement_type *) input_file_chain.head;
        search != NULL;
        search = (lang_input_statement_type *) search->next_real_file)
-    {
-      const char *infile = base_name (search->filename);
+    if (search->filename != NULL)
+      {
+	const char *infile = base_name (search->filename);
 
-      if (infile != NULL
-	  && strncmp (infile, "crtbegin", 8) == 0)
-	{
-	  if (infile[8] == 'S')
-	    flags = concat (flags, " -fPIC", NULL);
-	  else if (infile[8] == 'T')
-	    flags = concat (flags, " -fpie", NULL);
-	  break;
-	}
-    }
+	if (strncmp (infile, "crtbegin", 8) == 0)
+	  {
+	    if (infile[8] == 'S')
+	      flags = concat (flags, " -fPIC", NULL);
+	    else if (infile[8] == 'T')
+	      flags = concat (flags, " -fpie", NULL);
+	    break;
+	  }
+      }
 
   /* Use fork() and exec() rather than system() so that we don't
      need to worry about quoting args.  */

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list