aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-09-07 14:48:02 +0000
committerNick Clifton <nickc@gcc.gnu.org>2009-09-07 14:48:02 +0000
commit3beb864c19b34fc0e4dcfdc12e65f4b4a3eeddce (patch)
tree3854715e81aa3264e87605ef7883f359d39d6ea7 /gcc/gcc.c
parentd4e0a1c0569db470be17fa8c81fbc8b9106581a9 (diff)
downloadgcc-3beb864c19b34fc0e4dcfdc12e65f4b4a3eeddce.zip
gcc-3beb864c19b34fc0e4dcfdc12e65f4b4a3eeddce.tar.gz
gcc-3beb864c19b34fc0e4dcfdc12e65f4b4a3eeddce.tar.bz2
gcc.c (this_is_linker_script): New variable.
* 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. From-SVN: r151477
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 25deb49..a9ed7e2 100644
--- 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;