This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[PATCH] Fix GCC driver ICE on invalid abuse of specs (PR driver/30460)


Hi!

asm_debug variable isn't initialized to ASM_DEBUG_SPEC unlike all the other
static specs to work around some Irix cc bug and so is assigned only at
runtime.  But it is done only in init_spec and in the case where some -B xxx/
subdir contains an invalid hand-crafted specs (the default spec should be
always created from -dumpspecs and editing it, or better yet just using an
overriding -specs=xxx.spec) asm_debug is therefore uninitialized.
The PR submitter argues that init_spec should be called always, but that
would be a behavior change and for correctly created default specs even
unnecessary wasting of driver cycles.
This patch fixes this segfault instead by just initializing it always as
soon as possible (i.e. in main rather than init_spec).  If we wouldn't work
around Irix cc bugs, it would be already initialized by the time we reach
main through static initializer.

Tested on x86_64-linux, ok for trunk?

2007-11-12  Jakub Jelinek  <jakub@redhat.com>

	PR driver/30460
	* gcc.c (init_spec): Don't initialize asm_debug here...
	(main): ... but here.

--- gcc/gcc.c.jj	2007-11-01 20:48:57.000000000 +0100
+++ gcc/gcc.c	2007-11-12 12:21:49.000000000 +0100
@@ -1719,10 +1719,6 @@ init_spec (void)
     }
 #endif
 
-  /* Initialize here, not in definition.  The IRIX 6 O32 cc sometimes chokes
-     on ?: in file-scope variable initializations.  */
-  asm_debug = ASM_DEBUG_SPEC;
-
   for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
     {
       sl = &static_specs[i];
@@ -6134,6 +6130,10 @@ main (int argc, char **argv)
   struct user_specs *uptr;
   char **old_argv = argv;
 
+  /* Initialize here, not in definition.  The IRIX 6 O32 cc sometimes chokes
+     on ?: in file-scope variable initializations.  */
+  asm_debug = ASM_DEBUG_SPEC;
+
   p = argv[0] + strlen (argv[0]);
   while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
     --p;

	Jakub


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