* gcc.c (this_is_linker_script): New variable. Like
authornickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Sep 2009 14:48:02 +0000 (14:48 +0000)
committernickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Sep 2009 14:48:02 +0000 (14:48 +0000)
        this_is_library_file but for the %T constructor.
        (end_going_arg): If this_is_linker_script is set then locate the
        script and insert a --script switch before it
        (do_spec_2): Initialise this_is_linker_script.
        (do_spec_1): Likewise.  Handle %T construct.
        (eval_spec_function): Preserve this_is_linker_script.
        * doc/invoke.texi: Document %T construct in spec files.
        * config/m32c/m32c.h (LIB_SPEC): Use it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151477 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/m32c/m32c.h
gcc/doc/invoke.texi
gcc/gcc.c

index 8527d0b..686e665 100644 (file)
@@ -1,3 +1,15 @@
+2009-09-07  Nick Clifton  <nickc@redhat.com>
+
+       * gcc.c (this_is_linker_script): New variable.  Like
+       this_is_library_file but for the %T constructor.
+       (end_going_arg): If this_is_linker_script is set then locate the
+       script and insert a --script switch before it
+        (do_spec_2): Initialise this_is_linker_script.
+        (do_spec_1): Likewise.  Handle %T construct.
+        (eval_spec_function): Preserve this_is_linker_script.
+       * doc/invoke.texi: Document %T construct in spec files.
+       * config/m32c/m32c.h (LIB_SPEC): Use it.
+
 2009-09-07  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
        * rtl.h (PREFETCH_SCHEDULE_BARRIER_P): New macro.       
index dea5b55..ee092a5 100644 (file)
    thing when no CPU is specified, which defaults to R8C.  */
 #undef  LIB_SPEC
 #define LIB_SPEC "-( -lc %{msim*:-lsim}%{!msim*:-lnosys} -) \
-%{msim*:%{!T*: %{mcpu=m32cm:-Tsim24.ld}%{mcpu=m32c:-Tsim24.ld} \
-       %{!mcpu=m32cm:%{!mcpu=m32c:-Tsim16.ld}}}} \
-%{!T*:%{!msim*: %{mcpu=m16c:-Tm16c.ld} \
-               %{mcpu=m32cm:-Tm32cm.ld} \
-               %{mcpu=m32c:-Tm32c.ld} \
-               %{!mcpu=m16c:%{!mcpu=m32cm:%{!mcpu=m32c:-Tr8c.ld}}}}} \
+%{msim*:%{!T*: %{mcpu=m32cm:%Tsim24.ld}%{mcpu=m32c:%Tsim24.ld} \
+       %{!mcpu=m32cm:%{!mcpu=m32c:%Tsim16.ld}}}} \
+%{!T*:%{!msim*: %{mcpu=m16c:%Tm16c.ld} \
+               %{mcpu=m32cm:%Tm32cm.ld} \
+               %{mcpu=m32c:%Tm32c.ld} \
+               %{!mcpu=m16c:%{!mcpu=m32cm:%{!mcpu=m32c:%Tr8c.ld}}}}} \
 "
 
 /* Run-time Target Specification */
index 2b3acb7..b630ce3 100644 (file)
@@ -8840,7 +8840,16 @@ and @option{-imultilib} as necessary.
 @item %s
 Current argument is the name of a library or startup file of some sort.
 Search for that file in a standard list of directories and substitute
-the full name found.
+the full name found.  The current working directory is included in the
+list of directories scanned.
+
+@item %T
+Current argument is the name of a linker script.  Search for that file
+in the current list of directories to scan for libraries. If the file
+is located insert a @option{--script} option into the command line
+followed by the full path name found.  If the file is not found then
+generate an error message.  Note: the current working directory is not
+searched.
 
 @item %e@var{str}
 Print @var{str} as an error message.  @var{str} is terminated by a newline.
index 25deb49..a9ed7e2 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -427,7 +427,7 @@ or with constant text in a single argument.
  %b     substitute the basename of the input file being processed.
        This is the substring up to (and not including) the last period
        and not including the directory unless -save-temps was specified
-       to put temporaries in a different location.     
+       to put temporaries in a different location.
  %B    same as %b, but include the file suffix (text after the last period).
  %gSUFFIX
        substitute a file name that has suffix SUFFIX and is chosen
@@ -564,7 +564,7 @@ or with constant text in a single argument.
  %{!.S:X} substitutes X, if NOT processing a file with suffix S.
  %{,S:X}  substitutes X, if processing a file which will use spec S.
  %{!,S:X} substitutes X, if NOT processing a file which will use spec S.
-         
+
  %{S|T:X} substitutes X if either -S or -T was given to GCC.  This may be
          combined with '!', '.', ',', and '*' as above binding stronger
          than the OR.
@@ -3443,7 +3443,7 @@ add_linker_option (const char *option, int len)
   if (! linker_options)
     linker_options = XNEWVEC (char *, n_linker_options);
   else
-    linker_options = XRESIZEVEC (char *, linker_options, n_linker_options);  
+    linker_options = XRESIZEVEC (char *, linker_options, n_linker_options);
 
   linker_options [n_linker_options - 1] = save_string (option, len);
 }
@@ -4685,6 +4685,13 @@ static int this_is_output_file;
    search dirs for it.  */
 static int this_is_library_file;
 
+/* Nonzero means %T has been seen; the next arg to be terminated
+   is the name of a linker script and we should try all of the
+   standard search dirs for it.  If it is found insert a --script
+   command line switch and then substitute the full path in place,
+   otherwise generate an error message.  */
+static int this_is_linker_script;
+
 /* Nonzero means that the input of this command is coming from a pipe.  */
 static int input_from_pipe;
 
@@ -4705,6 +4712,19 @@ end_going_arg (void)
       string = XOBFINISH (&obstack, const char *);
       if (this_is_library_file)
        string = find_file (string);
+      if (this_is_linker_script)
+       {
+         char * full_script_path = find_a_file (&startfile_prefixes, string, R_OK, true);
+
+         if (full_script_path == NULL)
+           {
+             error (_("unable to locate default linker script '%s' in the library search paths"), string);
+             /* Script was not found on search path.  */
+             return;
+           }
+         store_arg ("--script", false, false);
+         string = full_script_path;
+       }
       store_arg (string, delete_this_arg, this_is_output_file);
       if (this_is_output_file)
        outfiles[input_file_number] = string;
@@ -4794,6 +4814,7 @@ do_spec_2 (const char *spec)
   delete_this_arg = 0;
   this_is_output_file = 0;
   this_is_library_file = 0;
+  this_is_linker_script = 0;
   input_from_pipe = 0;
   suffix_subst = NULL;
 
@@ -5081,6 +5102,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
        delete_this_arg = 0;
        this_is_output_file = 0;
        this_is_library_file = 0;
+       this_is_linker_script = 0;
        input_from_pipe = 0;
        break;
 
@@ -5100,6 +5122,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
        delete_this_arg = 0;
        this_is_output_file = 0;
        this_is_library_file = 0;
+       this_is_linker_script = 0;
        break;
 
       case '%':
@@ -5547,6 +5570,10 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
            this_is_library_file = 1;
            break;
 
+         case 'T':
+           this_is_linker_script = 1;
+           break;
+
          case 'V':
            outfiles[input_file_number] = NULL;
            break;
@@ -5921,6 +5948,7 @@ eval_spec_function (const char *func, const char *args)
   int save_this_is_output_file;
   int save_this_is_library_file;
   int save_input_from_pipe;
+  int save_this_is_linker_script;
   const char *save_suffix_subst;
 
 
@@ -5937,6 +5965,7 @@ eval_spec_function (const char *func, const char *args)
   save_delete_this_arg = delete_this_arg;
   save_this_is_output_file = this_is_output_file;
   save_this_is_library_file = this_is_library_file;
+  save_this_is_linker_script = this_is_linker_script;
   save_input_from_pipe = input_from_pipe;
   save_suffix_subst = suffix_subst;
 
@@ -5962,6 +5991,7 @@ eval_spec_function (const char *func, const char *args)
   delete_this_arg = save_delete_this_arg;
   this_is_output_file = save_this_is_output_file;
   this_is_library_file = save_this_is_library_file;
+  this_is_linker_script = save_this_is_linker_script;
   input_from_pipe = save_input_from_pipe;
   suffix_subst = save_suffix_subst;
 
@@ -6206,7 +6236,7 @@ handle_braces (const char *p)
            {
              if ((a_is_suffix || a_is_spectype) && a_is_starred)
                goto invalid;
-             
+
              if (!a_is_starred)
                disj_starred = false;
 
@@ -6220,7 +6250,7 @@ handle_braces (const char *p)
                    a_matched = input_spec_matches (atom, end_atom);
                  else
                    a_matched = switch_matches (atom, end_atom, a_is_starred);
-                 
+
                  if (a_matched != a_is_negated)
                    {
                      disj_matched = true;