Commit 368dfd3a by Torbjorn Granlund

(process_command): Handle -Wl, and -Xlinker similar to -l,

i.e., preserve their order with respect to linker input files.

From-SVN: r8349
parent 10bcde0d
...@@ -757,7 +757,7 @@ static char *link_command_spec = "\ ...@@ -757,7 +757,7 @@ static char *link_command_spec = "\
#endif #endif
/* A vector of options to give to the linker. /* A vector of options to give to the linker.
These options are accumulated by -Xlinker and -Wl, These options are accumulated by %x,
and substituted into the linker command with %X. */ and substituted into the linker command with %X. */
static int n_linker_options; static int n_linker_options;
static char **linker_options; static char **linker_options;
...@@ -2519,54 +2519,6 @@ process_command (argc, argv) ...@@ -2519,54 +2519,6 @@ process_command (argc, argv)
print_multi_lib = 1; print_multi_lib = 1;
else if (! strcmp (argv[i], "-print-multi-directory")) else if (! strcmp (argv[i], "-print-multi-directory"))
print_multi_directory = 1; print_multi_directory = 1;
else if (! strcmp (argv[i], "-Xlinker"))
{
/* Pass the argument of this option to the linker when we link. */
if (i + 1 == argc)
fatal ("argument to `-Xlinker' is missing");
n_linker_options++;
if (!linker_options)
linker_options
= (char **) xmalloc (n_linker_options * sizeof (char **));
else
linker_options
= (char **) xrealloc (linker_options,
n_linker_options * sizeof (char **));
linker_options[n_linker_options - 1] = argv[++i];
}
else if (! strncmp (argv[i], "-Wl,", 4))
{
int prev, j;
/* Pass the rest of this option to the linker when we link. */
n_linker_options++;
if (!linker_options)
linker_options
= (char **) xmalloc (n_linker_options * sizeof (char **));
else
linker_options
= (char **) xrealloc (linker_options,
n_linker_options * sizeof (char **));
/* Split the argument at commas. */
prev = 4;
for (j = 4; argv[i][j]; j++)
if (argv[i][j] == ',')
{
linker_options[n_linker_options - 1]
= save_string (argv[i] + prev, j - prev);
n_linker_options++;
linker_options
= (char **) xrealloc (linker_options,
n_linker_options * sizeof (char **));
prev = j + 1;
}
/* Record the part after the last comma. */
linker_options[n_linker_options - 1] = argv[i] + prev;
}
else if (! strncmp (argv[i], "-Wa,", 4)) else if (! strncmp (argv[i], "-Wa,", 4))
{ {
int prev, j; int prev, j;
...@@ -2630,7 +2582,19 @@ process_command (argc, argv) ...@@ -2630,7 +2582,19 @@ process_command (argc, argv)
else if (argv[i][0] == '+' && argv[i][1] == 'e') else if (argv[i][0] == '+' && argv[i][1] == 'e')
/* The +e options to the C++ front-end. */ /* The +e options to the C++ front-end. */
n_switches++; n_switches++;
else if (argv[i][0] == '-' && argv[i][1] != 0 && argv[i][1] != 'l') else if (strncmp (argv[i], "-Wl,", 4) == 0)
n_infiles++;
else if (strcmp (argv[i], "-Xlinker") == 0)
{
if (i + 1 == argc)
fatal ("argument to `-Xlinker' is missing");
n_infiles++;
i++;
}
else if (strncmp (argv[i], "-l", 2) == 0)
n_infiles++;
else if (argv[i][0] == '-' && argv[i][1] != 0)
{ {
register char *p = &argv[i][1]; register char *p = &argv[i][1];
register int c = *p; register int c = *p;
...@@ -2801,11 +2765,7 @@ process_command (argc, argv) ...@@ -2801,11 +2765,7 @@ process_command (argc, argv)
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
/* Just skip the switches that were handled by the preceding loop. */ /* Just skip the switches that were handled by the preceding loop. */
if (!strcmp (argv[i], "-Xlinker")) if (! strncmp (argv[i], "-Wa,", 4))
i++;
else if (! strncmp (argv[i], "-Wl,", 4))
;
else if (! strncmp (argv[i], "-Wa,", 4))
; ;
else if (! strncmp (argv[i], "-Wp,", 4)) else if (! strncmp (argv[i], "-Wp,", 4))
; ;
...@@ -2832,7 +2792,22 @@ process_command (argc, argv) ...@@ -2832,7 +2792,22 @@ process_command (argc, argv)
switches[n_switches].valid = 0; switches[n_switches].valid = 0;
n_switches++; n_switches++;
} }
else if (argv[i][0] == '-' && argv[i][1] != 0 && argv[i][1] != 'l') else if (strncmp (argv[i], "-Wl,", 4) == 0)
{
infiles[n_infiles].language = spec_lang;
infiles[n_infiles++].name = argv[i] + 4;
}
else if (strcmp (argv[i], "-Xlinker") == 0)
{
infiles[n_infiles].language = spec_lang;
infiles[n_infiles++].name = argv[++i];
}
else if (strncmp (argv[i], "-l", 2) == 0)
{
infiles[n_infiles].language = spec_lang;
infiles[n_infiles++].name = argv[i];
}
else if (argv[i][0] == '-' && argv[i][1] != 0)
{ {
register char *p = &argv[i][1]; register char *p = &argv[i][1];
register int c = *p; register int c = *p;
...@@ -2905,9 +2880,7 @@ process_command (argc, argv) ...@@ -2905,9 +2880,7 @@ process_command (argc, argv)
} }
else else
{ {
if ((argv[i][0] != '-' || argv[i][1] != 'l') if (strcmp (argv[i], "-") != 0 && access (argv[i], R_OK) < 0)
&& strcmp (argv[i], "-")
&& access (argv[i], R_OK) < 0)
{ {
perror_with_name (argv[i]); perror_with_name (argv[i]);
error_count++; error_count++;
...@@ -3427,8 +3400,7 @@ do_spec_1 (spec, inswitch, soft_matched_part) ...@@ -3427,8 +3400,7 @@ do_spec_1 (spec, inswitch, soft_matched_part)
} }
break; break;
/* Dump out the options accumulated previously using %x, /* Dump out the options accumulated previously using %x. */
-Xlinker and -Wl,. */
case 'X': case 'X':
for (i = 0; i < n_linker_options; i++) for (i = 0; i < n_linker_options; i++)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment