]> Git Repo - binutils.git/blame - ld/lexsup.c
* lexsup.c (parse_args): Handle --wrap.
[binutils.git] / ld / lexsup.c
CommitLineData
d4e5e3c3 1/* Parse options for the GNU linker.
4b7d2399 2 Copyright (C) 1991, 92, 93, 94, 95, 1996 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 105#define OPTION_WARN_CONSTRUCTORS (OPTION_WARN_COMMON + 1)
4b7d2399
ILT
106#define OPTION_WARN_MULTIPLE_GP (OPTION_WARN_CONSTRUCTORS + 1)
107#define OPTION_WARN_ONCE (OPTION_WARN_MULTIPLE_GP + 1)
de71eb77
SC
108#define OPTION_SPLIT_BY_RELOC (OPTION_WARN_ONCE + 1)
109#define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1)
110#define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
e3d73386 111#define OPTION_WRAP (OPTION_WHOLE_ARCHIVE + 1)
229ba4b3 112
d5b79a89 113 static struct option longopts[] = {
229ba4b3 114 /* Sorted alphabeticaly, except for the PE options grouped at the end. */
5753006b 115 {"assert", required_argument, NULL, OPTION_ASSERT},
db770dfa
ILT
116 {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
117 {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
4551e108 118 {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
d5b79a89 119 {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
d4e5e3c3 120 {"dc", no_argument, NULL, 'd'},
d5b79a89 121 {"defsym", required_argument, NULL, OPTION_DEFSYM},
809ee7e0 122 {"dll-verbose", no_argument, NULL, OPTION_VERSION}, /* Linux. */
2a9fa50c 123 {"dn", no_argument, NULL, OPTION_NON_SHARED},
d4e5e3c3 124 {"dp", no_argument, NULL, 'd'},
2a9fa50c 125 {"dy", no_argument, NULL, OPTION_CALL_SHARED},
7fb9ca5f 126 {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
d5b79a89 127 {"EB", no_argument, NULL, OPTION_EB},
d5b79a89 128 {"EL", no_argument, NULL, OPTION_EL},
de71eb77 129 {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
db770dfa 130 {"end-group", no_argument, NULL, ')'},
de71eb77 131 {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
d4e5e3c3 132 {"format", required_argument, NULL, 'b'},
d5b79a89 133 {"help", no_argument, NULL, OPTION_HELP},
d5b79a89 134 {"Map", required_argument, NULL, OPTION_MAP},
d5b79a89 135 {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
3c8deccc 136 {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
d5b79a89
DM
137 {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
138 {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
2a9fa50c 139 {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
d5b79a89 140 {"oformat", required_argument, NULL, OPTION_OFORMAT},
2a9fa50c 141 {"Qy", no_argument, NULL, OPTION_IGNORE},
cbbf9608 142 {"qmagic", no_argument, NULL, OPTION_IGNORE}, /* Linux compatibility. */
d5b79a89 143 {"relax", no_argument, NULL, OPTION_RELAX},
db770dfa 144 {"retain-symbols-file", required_argument, NULL, OPTION_RETAIN_SYMBOLS_FILE},
809ee7e0 145 {"rpath", required_argument, NULL, OPTION_RPATH},
3c8deccc 146 {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
db770dfa 147 {"shared", no_argument, NULL, OPTION_SHARED},
809ee7e0 148 {"soname", required_argument, NULL, OPTION_SONAME},
d5b79a89
DM
149 {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
150 {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
db770dfa 151 {"start-group", no_argument, NULL, '('},
d5b79a89 152 {"stats", no_argument, NULL, OPTION_STATS},
42792411 153 {"static", no_argument, NULL, OPTION_NON_SHARED},
d5b79a89 154 {"Tbss", required_argument, NULL, OPTION_TBSS},
d5b79a89 155 {"Tdata", required_argument, NULL, OPTION_TDATA},
d5b79a89 156 {"Ttext", required_argument, NULL, OPTION_TTEXT},
c96386c4 157 {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
d5b79a89 158 {"Ur", no_argument, NULL, OPTION_UR},
de71eb77 159 {"verbose", no_argument, NULL, OPTION_VERBOSE},
d5b79a89 160 {"version", no_argument, NULL, OPTION_VERSION},
d5b79a89 161 {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
80fd1f45 162 {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
4b7d2399 163 {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
809ee7e0 164 {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
de71eb77
SC
165 {"split-by-reloc", required_argument, NULL, OPTION_SPLIT_BY_RELOC},
166 {"split-by-file", no_argument, NULL, OPTION_SPLIT_BY_FILE},
167 {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
e3d73386 168 {"wrap", required_argument, NULL, OPTION_WRAP},
229ba4b3 169
d4e5e3c3
DM
170 {NULL, no_argument, NULL, 0}
171 };
172
22d3533c
ILT
173 /* The -G option is ambiguous on different platforms. Sometimes it
174 specifies the largest data size to put into the small data
175 section. Sometimes it is equivalent to --shared. Unfortunately,
176 the first form takes an argument, while the second does not.
177
178 We need to permit the --shared form because on some platforms,
179 such as Solaris, gcc -shared will pass -G to the linker.
180
181 To permit either usage, we look through the argument list. If we
182 find -G not followed by a number, we change it into --shared.
183 This will work for most normal cases. */
184 for (i = 1; i < argc; i++)
185 if (strcmp (argv[i], "-G") == 0
186 && (i + 1 >= argc
187 || ! isdigit (argv[i + 1][0])))
188 argv[i] = (char *) "--shared";
189
d4e5e3c3
DM
190 while (1)
191 {
192 /* getopt_long_only is like getopt_long, but '-' as well as '--' can
193 indicate a long option. */
d5b79a89 194 int longind;
5753006b
ILT
195 int optc;
196
197 if (ldemul_parse_args (argc, argv))
198 continue;
199
200 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
d5b79a89 201
d4e5e3c3
DM
202 if (optc == -1)
203 break;
d4e5e3c3
DM
204 switch (optc)
205 {
206 default:
207 xexit (1);
208 case 1: /* File name. */
209 lang_add_input_file (optarg, lang_input_file_is_file_enum,
210 (char *) NULL);
211 break;
212
2a9fa50c
ILT
213 case OPTION_IGNORE:
214 break;
de71eb77
SC
215 case 'a':
216 /* For HP/UX compatibility. Actually -a shared should mean
217 ``use only shared libraries'' but, then, we don't
218 currently support shared libraries on HP/UX anyhow. */
219 if (strcmp (optarg, "archive") == 0)
220 config.dynamic_link = false;
221 else if (strcmp (optarg, "shared") == 0
222 || strcmp (optarg, "default") == 0)
223 config.dynamic_link = true;
224 else
225 einfo ("%P%F: unrecognized -a option `%s'\n", optarg);
226 break;
5753006b 227 case OPTION_ASSERT:
3c8deccc 228 /* FIXME: We just ignore these, but we should handle them. */
5753006b
ILT
229 if (strcmp (optarg, "definitions") == 0)
230 ;
231 else if (strcmp (optarg, "nodefinitions") == 0)
232 ;
233 else if (strcmp (optarg, "nosymbolic") == 0)
234 ;
235 else if (strcmp (optarg, "pure-text") == 0)
3c8deccc 236 ;
5753006b
ILT
237 else
238 einfo ("%P%F: unrecognized -assert option `%s'\n", optarg);
239 break;
d4e5e3c3
DM
240 case 'A':
241 ldfile_add_arch (optarg);
242 break;
d4e5e3c3
DM
243 case 'b':
244 lang_add_target (optarg);
245 break;
246 case 'c':
247 ldfile_open_command_file (optarg);
248 parser_input = input_mri_script;
249 yyparse ();
250 break;
d5b79a89 251 case OPTION_CALL_SHARED:
2a9fa50c
ILT
252 config.dynamic_link = true;
253 break;
254 case OPTION_NON_SHARED:
255 config.dynamic_link = false;
d4e5e3c3
DM
256 break;
257 case 'd':
258 command_line.force_common_definition = true;
259 break;
d5b79a89 260 case OPTION_DEFSYM:
630f4ac9 261 lex_string = optarg;
d4e5e3c3
DM
262 lex_redirect (optarg);
263 parser_input = input_defsym;
630f4ac9 264 parsing_defsym = 1;
d4e5e3c3 265 yyparse ();
630f4ac9
ILT
266 parsing_defsym = 0;
267 lex_string = NULL;
d4e5e3c3 268 break;
7fb9ca5f
ILT
269 case OPTION_DYNAMIC_LINKER:
270 command_line.interpreter = optarg;
271 break;
d5b79a89 272 case OPTION_EB:
86037281 273 command_line.endian = ENDIAN_BIG;
d4e5e3c3 274 break;
d5b79a89 275 case OPTION_EL:
86037281 276 command_line.endian = ENDIAN_LITTLE;
d4e5e3c3 277 break;
de71eb77
SC
278 case OPTION_EMBEDDED_RELOCS:
279 command_line.embedded_relocs = true;
280 break;
281 case OPTION_EXPORT_DYNAMIC:
282 command_line.export_dynamic = true;
283 break;
d4e5e3c3 284 case 'e':
3c8deccc 285 lang_add_entry (optarg, true);
d4e5e3c3
DM
286 break;
287 case 'F':
288 /* Ignore. */
289 break;
290 case 'G':
291 {
292 char *end;
293 g_switch_value = strtoul (optarg, &end, 0);
294 if (*end)
9d3898b2 295 einfo ("%P%F: invalid number `%s'\n", optarg);
d4e5e3c3
DM
296 }
297 break;
298 case 'g':
299 /* Ignore. */
300 break;
d5b79a89 301 case OPTION_HELP:
d4e5e3c3
DM
302 help ();
303 xexit (0);
304 break;
305 case 'L':
0cd82d00 306 ldfile_add_library_path (optarg, true);
d4e5e3c3
DM
307 break;
308 case 'l':
309 lang_add_input_file (optarg, lang_input_file_is_l_enum,
310 (char *) NULL);
311 break;
312 case 'M':
313 config.map_filename = "-";
314 break;
315 case 'm':
316 /* Ignore. Was handled in a pre-parse. */
317 break;
d5b79a89 318 case OPTION_MAP:
d4e5e3c3
DM
319 config.map_filename = optarg;
320 break;
321 case 'N':
322 config.text_read_only = false;
323 config.magic_demand_paged = false;
3c8deccc 324 config.dynamic_link = false;
d4e5e3c3
DM
325 break;
326 case 'n':
327 config.magic_demand_paged = false;
3c8deccc 328 config.dynamic_link = false;
d4e5e3c3 329 break;
d5b79a89 330 case OPTION_NO_KEEP_MEMORY:
d4e5e3c3
DM
331 link_info.keep_memory = false;
332 break;
d5b79a89 333 case OPTION_NOINHIBIT_EXEC:
d4e5e3c3
DM
334 force_make_executable = true;
335 break;
3c8deccc
ILT
336 case OPTION_NO_WHOLE_ARCHIVE:
337 whole_archive = false;
338 break;
d4e5e3c3
DM
339 case 'O':
340 /* FIXME "-O<non-digits> <value>" used to set the address of
341 section <non-digits>. Was this for compatibility with
342 something, or can we create a new option to do that
343 (with a syntax similar to -defsym)?
344 getopt can't handle two args to an option without kludges. */
d4e5e3c3
DM
345 break;
346 case 'o':
347 lang_add_output (optarg, 0);
348 break;
d5b79a89 349 case OPTION_OFORMAT:
86037281 350 lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
d4e5e3c3 351 break;
3e1fd33d 352 case 'i':
d4e5e3c3
DM
353 case 'r':
354 link_info.relocateable = true;
355 config.build_constructors = false;
356 config.magic_demand_paged = false;
357 config.text_read_only = false;
2a9fa50c 358 config.dynamic_link = false;
d4e5e3c3
DM
359 break;
360 case 'R':
809ee7e0
ILT
361 /* The GNU linker traditionally uses -R to mean to include
362 only the symbols from a file. The Solaris linker uses -R
363 to set the path used by the runtime linker to find
364 libraries. This is the GNU linker -rpath argument. We
365 try to support both simultaneously by checking the file
366 named. If it is a directory, rather than a regular file,
367 we assume -rpath was meant. */
368 {
369 struct stat s;
370
371 if (stat (optarg, &s) >= 0
372 && ! S_ISDIR (s.st_mode))
373 {
374 lang_add_input_file (optarg,
375 lang_input_file_is_symbols_only_enum,
376 (char *) NULL);
377 break;
378 }
379 }
380 /* Fall through. */
381 case OPTION_RPATH:
382 if (command_line.rpath == NULL)
383 command_line.rpath = buystring (optarg);
384 else
385 {
386 char *buf;
387
388 buf = xmalloc (strlen (command_line.rpath)
389 + strlen (optarg)
390 + 2);
391 sprintf (buf, "%s:%s", command_line.rpath, optarg);
392 free (command_line.rpath);
393 command_line.rpath = buf;
394 }
d4e5e3c3 395 break;
3c8deccc
ILT
396 case OPTION_RPATH_LINK:
397 if (command_line.rpath_link == NULL)
398 command_line.rpath_link = buystring (optarg);
399 else
400 {
401 char *buf;
402
403 buf = xmalloc (strlen (command_line.rpath_link)
404 + strlen (optarg)
405 + 2);
406 sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
407 free (command_line.rpath_link);
408 command_line.rpath_link = buf;
409 }
410 break;
d5b79a89 411 case OPTION_RELAX:
d4e5e3c3
DM
412 command_line.relax = true;
413 break;
d5b79a89 414 case OPTION_RETAIN_SYMBOLS_FILE:
d4e5e3c3
DM
415 add_keepsyms_file (optarg);
416 break;
417 case 'S':
418 link_info.strip = strip_debugger;
419 break;
420 case 's':
421 link_info.strip = strip_all;
422 break;
db770dfa
ILT
423 case OPTION_SHARED:
424 link_info.shared = true;
425 break;
5753006b 426 case 'h': /* Used on Solaris. */
809ee7e0
ILT
427 case OPTION_SONAME:
428 command_line.soname = optarg;
429 break;
d5b79a89 430 case OPTION_SORT_COMMON:
d4e5e3c3
DM
431 config.sort_common = true;
432 break;
d5b79a89 433 case OPTION_STATS:
d4e5e3c3
DM
434 config.stats = true;
435 break;
4551e108
ILT
436 case OPTION_SYMBOLIC:
437 link_info.symbolic = true;
438 break;
d4e5e3c3
DM
439 case 't':
440 trace_files = true;
441 break;
442 case 'T':
443 ldfile_open_command_file (optarg);
444 parser_input = input_script;
445 yyparse ();
446 break;
d5b79a89 447 case OPTION_TBSS:
d4e5e3c3
DM
448 set_section_start (".bss", optarg);
449 break;
d5b79a89 450 case OPTION_TDATA:
d4e5e3c3
DM
451 set_section_start (".data", optarg);
452 break;
d5b79a89 453 case OPTION_TTEXT:
d4e5e3c3
DM
454 set_section_start (".text", optarg);
455 break;
c96386c4
ILT
456 case OPTION_TRADITIONAL_FORMAT:
457 config.traditional_format = true;
458 break;
d5b79a89 459 case OPTION_UR:
d4e5e3c3
DM
460 link_info.relocateable = true;
461 config.build_constructors = true;
462 config.magic_demand_paged = false;
463 config.text_read_only = false;
2a9fa50c 464 config.dynamic_link = false;
d4e5e3c3
DM
465 break;
466 case 'u':
467 ldlang_add_undef (optarg);
468 break;
de71eb77 469 case OPTION_VERBOSE:
d4e5e3c3
DM
470 ldversion (1);
471 version_printed = true;
472 trace_file_tries = true;
473 break;
474 case 'v':
475 ldversion (0);
476 version_printed = true;
477 break;
de71eb77
SC
478 case 'V':
479 ldversion (1);
480 version_printed = true;
481 break;
d5b79a89 482 case OPTION_VERSION:
d4e5e3c3
DM
483 ldversion (0);
484 version_printed = true;
485 break;
d5b79a89 486 case OPTION_WARN_COMMON:
d4e5e3c3
DM
487 config.warn_common = true;
488 break;
80fd1f45
ILT
489 case OPTION_WARN_CONSTRUCTORS:
490 config.warn_constructors = true;
491 break;
4b7d2399
ILT
492 case OPTION_WARN_MULTIPLE_GP:
493 config.warn_multiple_gp = true;
494 break;
809ee7e0
ILT
495 case OPTION_WARN_ONCE:
496 config.warn_once = true;
497 break;
de71eb77
SC
498 case OPTION_WHOLE_ARCHIVE:
499 whole_archive = true;
500 break;
e3d73386
ILT
501 case OPTION_WRAP:
502 if (link_info.wrap_hash == NULL)
503 {
504 link_info.wrap_hash = ((struct bfd_hash_table *)
505 xmalloc (sizeof (struct bfd_hash_table)));
506 if (! bfd_hash_table_init_n (link_info.wrap_hash,
507 bfd_hash_newfunc,
508 61))
509 einfo ("%P%F: bfd_hash_table_init failed: %E\n");
510 }
511 if (bfd_hash_lookup (link_info.wrap_hash, optarg, true, true)
512 == NULL)
513 einfo ("%P%F: bfd_hash_lookup failed: %E\n");
514 break;
d4e5e3c3
DM
515 case 'X':
516 link_info.discard = discard_l;
517 break;
518 case 'x':
519 link_info.discard = discard_all;
520 break;
d5b79a89 521 case 'Y':
5753006b
ILT
522 if (strncmp (optarg, "P,", 2) == 0)
523 optarg += 2;
524 default_dirlist = optarg;
d5b79a89 525 break;
d4e5e3c3
DM
526 case 'y':
527 add_ysym (optarg);
528 break;
22d3533c
ILT
529 case 'z':
530 /* We accept and ignore this option for Solaris
531 compatibility. Actually, on Solaris, optarg is not
532 ignored. Someday we should handle it correctly. FIXME. */
533 break;
de71eb77
SC
534 case OPTION_SPLIT_BY_RELOC:
535 config.split_by_reloc = atoi (optarg);
536 break;
537 case OPTION_SPLIT_BY_FILE:
538 config.split_by_file = true;
539 break;
db770dfa
ILT
540 case '(':
541 if (ingroup)
542 {
543 fprintf (stderr,
544 "%s: may not nest groups (--help for usage)\n",
545 program_name);
546 xexit (1);
547 }
548 lang_enter_group ();
549 ingroup = 1;
550 break;
551 case ')':
552 if (! ingroup)
553 {
554 fprintf (stderr,
555 "%s: group ended before it began (--help for usage)\n",
556 program_name);
557 xexit (1);
558 }
559 lang_leave_group ();
560 ingroup = 0;
561 break;
229ba4b3 562
d4e5e3c3
DM
563 }
564 }
db770dfa
ILT
565
566 if (ingroup)
567 lang_leave_group ();
5753006b
ILT
568
569 if (default_dirlist != NULL)
570 set_default_dirlist (default_dirlist);
571
d4e5e3c3
DM
572}
573
574/* Add the (colon-separated) elements of DIRLIST_PTR to the
575 library search path. */
576
577static void
578set_default_dirlist (dirlist_ptr)
579 char *dirlist_ptr;
580{
581 char *p;
582
583 while (1)
584 {
585 p = strchr (dirlist_ptr, ':');
586 if (p != NULL)
587 *p = 0;
588 if (*dirlist_ptr)
0cd82d00 589 ldfile_add_library_path (dirlist_ptr, true);
d4e5e3c3
DM
590 if (p == NULL)
591 break;
592 *p = ':';
593 dirlist_ptr = p + 1;
594 }
595}
596
597static void
598set_section_start (sect, valstr)
599 char *sect, *valstr;
600{
601 char *end;
602 unsigned long val = strtoul (valstr, &end, 16);
603 if (*end)
d5b79a89 604 einfo ("%P%F: invalid hex number `%s'\n", valstr);
d4e5e3c3
DM
605 lang_section_start (sect, exp_intop (val));
606}
229ba4b3 607\f
This page took 0.231949 seconds and 4 git commands to generate.