#endif
/* 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. */
static int n_linker_options;
static char **linker_options;
print_multi_lib = 1;
else if (! strcmp (argv[i], "-print-multi-directory"))
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))
{
int prev, j;
else if (argv[i][0] == '+' && argv[i][1] == 'e')
/* The +e options to the C++ front-end. */
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 int c = *p;
for (i = 1; i < argc; i++)
{
/* Just skip the switches that were handled by the preceding loop. */
- if (!strcmp (argv[i], "-Xlinker"))
- i++;
- else if (! strncmp (argv[i], "-Wl,", 4))
- ;
- else if (! strncmp (argv[i], "-Wa,", 4))
+ if (! strncmp (argv[i], "-Wa,", 4))
;
else if (! strncmp (argv[i], "-Wp,", 4))
;
switches[n_switches].valid = 0;
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 int c = *p;
}
else
{
- if ((argv[i][0] != '-' || argv[i][1] != 'l')
- && strcmp (argv[i], "-")
- && access (argv[i], R_OK) < 0)
+ if (strcmp (argv[i], "-") != 0 && access (argv[i], R_OK) < 0)
{
perror_with_name (argv[i]);
error_count++;
}
break;
- /* Dump out the options accumulated previously using %x,
- -Xlinker and -Wl,. */
+ /* Dump out the options accumulated previously using %x. */
case 'X':
for (i = 0; i < n_linker_options; i++)
{