* lexsup.c (parse_args): Recognize --no-whole-archive.
[deliverable/binutils-gdb.git] / ld / lexsup.c
CommitLineData
d4e5e3c3 1/* Parse options for the GNU linker.
80fd1f45 2 Copyright (C) 1991, 92, 93, 94, 1995 Free Software Foundation, Inc.
d4e5e3c3
DM
3
4This file is part of GLD, the Gnu Linker.
5
6GLD is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GLD is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GLD; see the file COPYING. If not, write to
943fbd5b 18the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
d4e5e3c3
DM
19
20#include "bfd.h"
21#include "sysdep.h"
22#include <stdio.h>
23#include <string.h>
22d3533c 24#include <ctype.h>
d4e5e3c3
DM
25#include "getopt.h"
26#include "bfdlink.h"
d4e5e3c3
DM
27#include "ld.h"
28#include "ldmain.h"
29#include "ldmisc.h"
30#include "ldexp.h"
31#include "ldlang.h"
32#include "ldgram.h"
33#include "ldlex.h"
34#include "ldfile.h"
4725fb48 35#include "ldver.h"
5753006b 36#include "ldemul.h"
d4e5e3c3 37
809ee7e0
ILT
38/* Somewhere above, sys/stat.h got included . . . . */
39#if !defined(S_ISDIR) && defined(S_IFDIR)
40#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
41#endif
42
d4e5e3c3
DM
43/* Omit args to avoid the possibility of clashing with a system header
44 that might disagree about consts. */
45unsigned long strtoul ();
46
47static void set_default_dirlist PARAMS ((char *dirlist_ptr));
48static void set_section_start PARAMS ((char *sect, char *valstr));
49
630f4ac9
ILT
50/* Non-zero if we are processing a --defsym from the command line. */
51int parsing_defsym = 0;
de71eb77 52
d4e5e3c3
DM
53void
54parse_args (argc, argv)
55 int argc;
56 char **argv;
57{
22d3533c 58 int i;
db770dfa 59 int ingroup = 0;
5753006b 60 char *default_dirlist = NULL;
db770dfa 61
d4e5e3c3
DM
62 /* Starting the short option string with '-' is for programs that
63 expect options and other ARGV-elements in any order and that care about
64 the ordering of the two. We describe each non-option ARGV-element
65 as if it were the argument of an option with character code 1. */
66
db770dfa 67 const char *shortopts =
3c8deccc 68 "-a:A:b:c:de:F::G:gh:iL:l:Mm:NnO:o:R:rSsT:tu:VvXxY:y:z:()";
d4e5e3c3 69
d5b79a89
DM
70 /* 150 isn't special; it's just an arbitrary non-ASCII char value. */
71
5753006b
ILT
72#define OPTION_ASSERT 150
73#define OPTION_CALL_SHARED (OPTION_ASSERT + 1)
bec7a138 74#define OPTION_DEFSYM (OPTION_CALL_SHARED + 1)
7fb9ca5f
ILT
75#define OPTION_DYNAMIC_LINKER (OPTION_DEFSYM + 1)
76#define OPTION_EB (OPTION_DYNAMIC_LINKER + 1)
bec7a138 77#define OPTION_EL (OPTION_EB + 1)
5753006b 78#define OPTION_EMBEDDED_RELOCS (OPTION_EL + 1)
de71eb77
SC
79#define OPTION_EXPORT_DYNAMIC (OPTION_EMBEDDED_RELOCS + 1)
80#define OPTION_HELP (OPTION_EXPORT_DYNAMIC + 1)
bec7a138
ILT
81#define OPTION_IGNORE (OPTION_HELP + 1)
82#define OPTION_MAP (OPTION_IGNORE + 1)
83#define OPTION_NO_KEEP_MEMORY (OPTION_MAP + 1)
84#define OPTION_NOINHIBIT_EXEC (OPTION_NO_KEEP_MEMORY + 1)
85#define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1)
3c8deccc
ILT
86#define OPTION_NO_WHOLE_ARCHIVE (OPTION_NON_SHARED + 1)
87#define OPTION_OFORMAT (OPTION_NO_WHOLE_ARCHIVE + 1)
bec7a138
ILT
88#define OPTION_RELAX (OPTION_OFORMAT + 1)
89#define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1)
809ee7e0 90#define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1)
3c8deccc
ILT
91#define OPTION_RPATH_LINK (OPTION_RPATH + 1)
92#define OPTION_SHARED (OPTION_RPATH_LINK + 1)
809ee7e0
ILT
93#define OPTION_SONAME (OPTION_SHARED + 1)
94#define OPTION_SORT_COMMON (OPTION_SONAME + 1)
229ba4b3
SC
95#define OPTION_STATS (OPTION_SORT_COMMON + 1)
96#define OPTION_SYMBOLIC (OPTION_STATS + 1)
4551e108 97#define OPTION_TBSS (OPTION_SYMBOLIC + 1)
bec7a138
ILT
98#define OPTION_TDATA (OPTION_TBSS + 1)
99#define OPTION_TTEXT (OPTION_TDATA + 1)
100#define OPTION_TRADITIONAL_FORMAT (OPTION_TTEXT + 1)
101#define OPTION_UR (OPTION_TRADITIONAL_FORMAT + 1)
de71eb77
SC
102#define OPTION_VERBOSE (OPTION_UR + 1)
103#define OPTION_VERSION (OPTION_VERBOSE + 1)
bec7a138 104#define OPTION_WARN_COMMON (OPTION_VERSION + 1)
80fd1f45
ILT
105#define OPTION_WARN_CONSTRUCTORS (OPTION_WARN_COMMON + 1)
106#define OPTION_WARN_ONCE (OPTION_WARN_CONSTRUCTORS + 1)
de71eb77
SC
107#define OPTION_SPLIT_BY_RELOC (OPTION_WARN_ONCE + 1)
108#define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1)
109#define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
229ba4b3 110
229ba4b3 111
d5b79a89 112 static struct option longopts[] = {
229ba4b3 113 /* Sorted alphabeticaly, except for the PE options grouped at the end. */
5753006b 114 {"assert", required_argument, NULL, OPTION_ASSERT},
db770dfa
ILT
115 {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
116 {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
4551e108 117 {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
d5b79a89 118 {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
d4e5e3c3 119 {"dc", no_argument, NULL, 'd'},
d5b79a89 120 {"defsym", required_argument, NULL, OPTION_DEFSYM},
809ee7e0 121 {"dll-verbose", no_argument, NULL, OPTION_VERSION}, /* Linux. */
2a9fa50c 122 {"dn", no_argument, NULL, OPTION_NON_SHARED},
d4e5e3c3 123 {"dp", no_argument, NULL, 'd'},
2a9fa50c 124 {"dy", no_argument, NULL, OPTION_CALL_SHARED},
7fb9ca5f 125 {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
d5b79a89 126 {"EB", no_argument, NULL, OPTION_EB},
d5b79a89 127 {"EL", no_argument, NULL, OPTION_EL},
de71eb77 128 {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
db770dfa 129 {"end-group", no_argument, NULL, ')'},
de71eb77 130 {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
d4e5e3c3 131 {"format", required_argument, NULL, 'b'},
d5b79a89 132 {"help", no_argument, NULL, OPTION_HELP},
d5b79a89 133 {"Map", required_argument, NULL, OPTION_MAP},
d5b79a89 134 {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
3c8deccc 135 {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
d5b79a89
DM
136 {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
137 {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
2a9fa50c 138 {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
d5b79a89 139 {"oformat", required_argument, NULL, OPTION_OFORMAT},
2a9fa50c 140 {"Qy", no_argument, NULL, OPTION_IGNORE},
cbbf9608 141 {"qmagic", no_argument, NULL, OPTION_IGNORE}, /* Linux compatibility. */
d5b79a89 142 {"relax", no_argument, NULL, OPTION_RELAX},
db770dfa 143 {"retain-symbols-file", required_argument, NULL, OPTION_RETAIN_SYMBOLS_FILE},
809ee7e0 144 {"rpath", required_argument, NULL, OPTION_RPATH},
3c8deccc 145 {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
db770dfa 146 {"shared", no_argument, NULL, OPTION_SHARED},
809ee7e0 147 {"soname", required_argument, NULL, OPTION_SONAME},
d5b79a89
DM
148 {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
149 {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
db770dfa 150 {"start-group", no_argument, NULL, '('},
d5b79a89 151 {"stats", no_argument, NULL, OPTION_STATS},
42792411 152 {"static", no_argument, NULL, OPTION_NON_SHARED},
d5b79a89 153 {"Tbss", required_argument, NULL, OPTION_TBSS},
d5b79a89 154 {"Tdata", required_argument, NULL, OPTION_TDATA},
d5b79a89 155 {"Ttext", required_argument, NULL, OPTION_TTEXT},
c96386c4 156 {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
d5b79a89 157 {"Ur", no_argument, NULL, OPTION_UR},
de71eb77 158 {"verbose", no_argument, NULL, OPTION_VERBOSE},
d5b79a89 159 {"version", no_argument, NULL, OPTION_VERSION},
d5b79a89 160 {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
80fd1f45 161 {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
809ee7e0 162 {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
de71eb77
SC
163 {"split-by-reloc", required_argument, NULL, OPTION_SPLIT_BY_RELOC},
164 {"split-by-file", no_argument, NULL, OPTION_SPLIT_BY_FILE},
165 {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
229ba4b3 166
229ba4b3 167
d4e5e3c3
DM
168 {NULL, no_argument, NULL, 0}
169 };
170
22d3533c
ILT
171 /* The -G option is ambiguous on different platforms. Sometimes it
172 specifies the largest data size to put into the small data
173 section. Sometimes it is equivalent to --shared. Unfortunately,
174 the first form takes an argument, while the second does not.
175
176 We need to permit the --shared form because on some platforms,
177 such as Solaris, gcc -shared will pass -G to the linker.
178
179 To permit either usage, we look through the argument list. If we
180 find -G not followed by a number, we change it into --shared.
181 This will work for most normal cases. */
182 for (i = 1; i < argc; i++)
183 if (strcmp (argv[i], "-G") == 0
184 && (i + 1 >= argc
185 || ! isdigit (argv[i + 1][0])))
186 argv[i] = (char *) "--shared";
187
d4e5e3c3
DM
188 while (1)
189 {
190 /* getopt_long_only is like getopt_long, but '-' as well as '--' can
191 indicate a long option. */
d5b79a89 192 int longind;
5753006b
ILT
193 int optc;
194
195 if (ldemul_parse_args (argc, argv))
196 continue;
197
198 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
d5b79a89 199
d4e5e3c3
DM
200 if (optc == -1)
201 break;
d4e5e3c3
DM
202 switch (optc)
203 {
204 default:
205 xexit (1);
206 case 1: /* File name. */
207 lang_add_input_file (optarg, lang_input_file_is_file_enum,
208 (char *) NULL);
209 break;
210
2a9fa50c
ILT
211 case OPTION_IGNORE:
212 break;
de71eb77
SC
213 case 'a':
214 /* For HP/UX compatibility. Actually -a shared should mean
215 ``use only shared libraries'' but, then, we don't
216 currently support shared libraries on HP/UX anyhow. */
217 if (strcmp (optarg, "archive") == 0)
218 config.dynamic_link = false;
219 else if (strcmp (optarg, "shared") == 0
220 || strcmp (optarg, "default") == 0)
221 config.dynamic_link = true;
222 else
223 einfo ("%P%F: unrecognized -a option `%s'\n", optarg);
224 break;
5753006b 225 case OPTION_ASSERT:
3c8deccc 226 /* FIXME: We just ignore these, but we should handle them. */
5753006b
ILT
227 if (strcmp (optarg, "definitions") == 0)
228 ;
229 else if (strcmp (optarg, "nodefinitions") == 0)
230 ;
231 else if (strcmp (optarg, "nosymbolic") == 0)
232 ;
233 else if (strcmp (optarg, "pure-text") == 0)
3c8deccc 234 ;
5753006b
ILT
235 else
236 einfo ("%P%F: unrecognized -assert option `%s'\n", optarg);
237 break;
d4e5e3c3
DM
238 case 'A':
239 ldfile_add_arch (optarg);
240 break;
d4e5e3c3
DM
241 case 'b':
242 lang_add_target (optarg);
243 break;
244 case 'c':
245 ldfile_open_command_file (optarg);
246 parser_input = input_mri_script;
247 yyparse ();
248 break;
d5b79a89 249 case OPTION_CALL_SHARED:
2a9fa50c
ILT
250 config.dynamic_link = true;
251 break;
252 case OPTION_NON_SHARED:
253 config.dynamic_link = false;
d4e5e3c3
DM
254 break;
255 case 'd':
256 command_line.force_common_definition = true;
257 break;
d5b79a89 258 case OPTION_DEFSYM:
630f4ac9 259 lex_string = optarg;
d4e5e3c3
DM
260 lex_redirect (optarg);
261 parser_input = input_defsym;
630f4ac9 262 parsing_defsym = 1;
d4e5e3c3 263 yyparse ();
630f4ac9
ILT
264 parsing_defsym = 0;
265 lex_string = NULL;
d4e5e3c3 266 break;
7fb9ca5f
ILT
267 case OPTION_DYNAMIC_LINKER:
268 command_line.interpreter = optarg;
269 break;
d5b79a89 270 case OPTION_EB:
86037281 271 command_line.endian = ENDIAN_BIG;
d4e5e3c3 272 break;
d5b79a89 273 case OPTION_EL:
86037281 274 command_line.endian = ENDIAN_LITTLE;
d4e5e3c3 275 break;
de71eb77
SC
276 case OPTION_EMBEDDED_RELOCS:
277 command_line.embedded_relocs = true;
278 break;
279 case OPTION_EXPORT_DYNAMIC:
280 command_line.export_dynamic = true;
281 break;
d4e5e3c3 282 case 'e':
3c8deccc 283 lang_add_entry (optarg, true);
d4e5e3c3
DM
284 break;
285 case 'F':
286 /* Ignore. */
287 break;
288 case 'G':
289 {
290 char *end;
291 g_switch_value = strtoul (optarg, &end, 0);
292 if (*end)
9d3898b2 293 einfo ("%P%F: invalid number `%s'\n", optarg);
d4e5e3c3
DM
294 }
295 break;
296 case 'g':
297 /* Ignore. */
298 break;
d5b79a89 299 case OPTION_HELP:
d4e5e3c3
DM
300 help ();
301 xexit (0);
302 break;
303 case 'L':
0cd82d00 304 ldfile_add_library_path (optarg, true);
d4e5e3c3
DM
305 break;
306 case 'l':
307 lang_add_input_file (optarg, lang_input_file_is_l_enum,
308 (char *) NULL);
309 break;
310 case 'M':
311 config.map_filename = "-";
312 break;
313 case 'm':
314 /* Ignore. Was handled in a pre-parse. */
315 break;
d5b79a89 316 case OPTION_MAP:
d4e5e3c3
DM
317 config.map_filename = optarg;
318 break;
319 case 'N':
320 config.text_read_only = false;
321 config.magic_demand_paged = false;
3c8deccc 322 config.dynamic_link = false;
d4e5e3c3
DM
323 break;
324 case 'n':
325 config.magic_demand_paged = false;
3c8deccc 326 config.dynamic_link = false;
d4e5e3c3 327 break;
d5b79a89 328 case OPTION_NO_KEEP_MEMORY:
d4e5e3c3
DM
329 link_info.keep_memory = false;
330 break;
d5b79a89 331 case OPTION_NOINHIBIT_EXEC:
d4e5e3c3
DM
332 force_make_executable = true;
333 break;
3c8deccc
ILT
334 case OPTION_NO_WHOLE_ARCHIVE:
335 whole_archive = false;
336 break;
d4e5e3c3
DM
337 case 'O':
338 /* FIXME "-O<non-digits> <value>" used to set the address of
339 section <non-digits>. Was this for compatibility with
340 something, or can we create a new option to do that
341 (with a syntax similar to -defsym)?
342 getopt can't handle two args to an option without kludges. */
d4e5e3c3
DM
343 break;
344 case 'o':
345 lang_add_output (optarg, 0);
346 break;
d5b79a89 347 case OPTION_OFORMAT:
86037281 348 lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
d4e5e3c3 349 break;
3e1fd33d 350 case 'i':
d4e5e3c3
DM
351 case 'r':
352 link_info.relocateable = true;
353 config.build_constructors = false;
354 config.magic_demand_paged = false;
355 config.text_read_only = false;
2a9fa50c 356 config.dynamic_link = false;
d4e5e3c3
DM
357 break;
358 case 'R':
809ee7e0
ILT
359 /* The GNU linker traditionally uses -R to mean to include
360 only the symbols from a file. The Solaris linker uses -R
361 to set the path used by the runtime linker to find
362 libraries. This is the GNU linker -rpath argument. We
363 try to support both simultaneously by checking the file
364 named. If it is a directory, rather than a regular file,
365 we assume -rpath was meant. */
366 {
367 struct stat s;
368
369 if (stat (optarg, &s) >= 0
370 && ! S_ISDIR (s.st_mode))
371 {
372 lang_add_input_file (optarg,
373 lang_input_file_is_symbols_only_enum,
374 (char *) NULL);
375 break;
376 }
377 }
378 /* Fall through. */
379 case OPTION_RPATH:
380 if (command_line.rpath == NULL)
381 command_line.rpath = buystring (optarg);
382 else
383 {
384 char *buf;
385
386 buf = xmalloc (strlen (command_line.rpath)
387 + strlen (optarg)
388 + 2);
389 sprintf (buf, "%s:%s", command_line.rpath, optarg);
390 free (command_line.rpath);
391 command_line.rpath = buf;
392 }
d4e5e3c3 393 break;
3c8deccc
ILT
394 case OPTION_RPATH_LINK:
395 if (command_line.rpath_link == NULL)
396 command_line.rpath_link = buystring (optarg);
397 else
398 {
399 char *buf;
400
401 buf = xmalloc (strlen (command_line.rpath_link)
402 + strlen (optarg)
403 + 2);
404 sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
405 free (command_line.rpath_link);
406 command_line.rpath_link = buf;
407 }
408 break;
d5b79a89 409 case OPTION_RELAX:
d4e5e3c3
DM
410 command_line.relax = true;
411 break;
d5b79a89 412 case OPTION_RETAIN_SYMBOLS_FILE:
d4e5e3c3
DM
413 add_keepsyms_file (optarg);
414 break;
415 case 'S':
416 link_info.strip = strip_debugger;
417 break;
418 case 's':
419 link_info.strip = strip_all;
420 break;
db770dfa
ILT
421 case OPTION_SHARED:
422 link_info.shared = true;
423 break;
5753006b 424 case 'h': /* Used on Solaris. */
809ee7e0
ILT
425 case OPTION_SONAME:
426 command_line.soname = optarg;
427 break;
d5b79a89 428 case OPTION_SORT_COMMON:
d4e5e3c3
DM
429 config.sort_common = true;
430 break;
d5b79a89 431 case OPTION_STATS:
d4e5e3c3
DM
432 config.stats = true;
433 break;
4551e108
ILT
434 case OPTION_SYMBOLIC:
435 link_info.symbolic = true;
436 break;
d4e5e3c3
DM
437 case 't':
438 trace_files = true;
439 break;
440 case 'T':
441 ldfile_open_command_file (optarg);
442 parser_input = input_script;
443 yyparse ();
444 break;
d5b79a89 445 case OPTION_TBSS:
d4e5e3c3
DM
446 set_section_start (".bss", optarg);
447 break;
d5b79a89 448 case OPTION_TDATA:
d4e5e3c3
DM
449 set_section_start (".data", optarg);
450 break;
d5b79a89 451 case OPTION_TTEXT:
d4e5e3c3
DM
452 set_section_start (".text", optarg);
453 break;
c96386c4
ILT
454 case OPTION_TRADITIONAL_FORMAT:
455 config.traditional_format = true;
456 break;
d5b79a89 457 case OPTION_UR:
d4e5e3c3
DM
458 link_info.relocateable = true;
459 config.build_constructors = true;
460 config.magic_demand_paged = false;
461 config.text_read_only = false;
2a9fa50c 462 config.dynamic_link = false;
d4e5e3c3
DM
463 break;
464 case 'u':
465 ldlang_add_undef (optarg);
466 break;
de71eb77 467 case OPTION_VERBOSE:
d4e5e3c3
DM
468 ldversion (1);
469 version_printed = true;
470 trace_file_tries = true;
471 break;
472 case 'v':
473 ldversion (0);
474 version_printed = true;
475 break;
de71eb77
SC
476 case 'V':
477 ldversion (1);
478 version_printed = true;
479 break;
d5b79a89 480 case OPTION_VERSION:
d4e5e3c3
DM
481 ldversion (0);
482 version_printed = true;
483 break;
d5b79a89 484 case OPTION_WARN_COMMON:
d4e5e3c3
DM
485 config.warn_common = true;
486 break;
80fd1f45
ILT
487 case OPTION_WARN_CONSTRUCTORS:
488 config.warn_constructors = true;
489 break;
809ee7e0
ILT
490 case OPTION_WARN_ONCE:
491 config.warn_once = true;
492 break;
de71eb77
SC
493 case OPTION_WHOLE_ARCHIVE:
494 whole_archive = true;
495 break;
d4e5e3c3
DM
496 case 'X':
497 link_info.discard = discard_l;
498 break;
499 case 'x':
500 link_info.discard = discard_all;
501 break;
d5b79a89 502 case 'Y':
5753006b
ILT
503 if (strncmp (optarg, "P,", 2) == 0)
504 optarg += 2;
505 default_dirlist = optarg;
d5b79a89 506 break;
d4e5e3c3
DM
507 case 'y':
508 add_ysym (optarg);
509 break;
22d3533c
ILT
510 case 'z':
511 /* We accept and ignore this option for Solaris
512 compatibility. Actually, on Solaris, optarg is not
513 ignored. Someday we should handle it correctly. FIXME. */
514 break;
de71eb77
SC
515 case OPTION_SPLIT_BY_RELOC:
516 config.split_by_reloc = atoi (optarg);
517 break;
518 case OPTION_SPLIT_BY_FILE:
519 config.split_by_file = true;
520 break;
db770dfa
ILT
521 case '(':
522 if (ingroup)
523 {
524 fprintf (stderr,
525 "%s: may not nest groups (--help for usage)\n",
526 program_name);
527 xexit (1);
528 }
529 lang_enter_group ();
530 ingroup = 1;
531 break;
532 case ')':
533 if (! ingroup)
534 {
535 fprintf (stderr,
536 "%s: group ended before it began (--help for usage)\n",
537 program_name);
538 xexit (1);
539 }
540 lang_leave_group ();
541 ingroup = 0;
542 break;
229ba4b3 543
d4e5e3c3
DM
544 }
545 }
db770dfa
ILT
546
547 if (ingroup)
548 lang_leave_group ();
5753006b
ILT
549
550 if (default_dirlist != NULL)
551 set_default_dirlist (default_dirlist);
552
d4e5e3c3
DM
553}
554
555/* Add the (colon-separated) elements of DIRLIST_PTR to the
556 library search path. */
557
558static void
559set_default_dirlist (dirlist_ptr)
560 char *dirlist_ptr;
561{
562 char *p;
563
564 while (1)
565 {
566 p = strchr (dirlist_ptr, ':');
567 if (p != NULL)
568 *p = 0;
569 if (*dirlist_ptr)
0cd82d00 570 ldfile_add_library_path (dirlist_ptr, true);
d4e5e3c3
DM
571 if (p == NULL)
572 break;
573 *p = ':';
574 dirlist_ptr = p + 1;
575 }
576}
577
578static void
579set_section_start (sect, valstr)
580 char *sect, *valstr;
581{
582 char *end;
583 unsigned long val = strtoul (valstr, &end, 16);
584 if (*end)
d5b79a89 585 einfo ("%P%F: invalid hex number `%s'\n", valstr);
d4e5e3c3
DM
586 lang_section_start (sect, exp_intop (val));
587}
229ba4b3 588\f
This page took 0.133947 seconds and 4 git commands to generate.