1 /* Parse options for the GNU linker.
2 Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
4 This file is part of GLD, the Gnu Linker.
6 GLD is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GLD is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GLD; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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)
43 /* Omit args to avoid the possibility of clashing with a system header
44 that might disagree about consts. */
45 unsigned long strtoul ();
47 static void set_default_dirlist PARAMS ((char *dirlist_ptr));
48 static void set_section_start PARAMS ((char *sect, char *valstr));
49 static void help PARAMS ((void));
51 /* Non-zero if we are processing a --defsym from the command line. */
52 int parsing_defsym = 0;
54 /* Codes used for the long options with no short synonyms. 150 isn't
55 special; it's just an arbitrary non-ASCII char value. */
57 #define OPTION_ASSERT 150
58 #define OPTION_CALL_SHARED (OPTION_ASSERT + 1)
59 #define OPTION_DEFSYM (OPTION_CALL_SHARED + 1)
60 #define OPTION_DYNAMIC_LINKER (OPTION_DEFSYM + 1)
61 #define OPTION_EB (OPTION_DYNAMIC_LINKER + 1)
62 #define OPTION_EL (OPTION_EB + 1)
63 #define OPTION_EMBEDDED_RELOCS (OPTION_EL + 1)
64 #define OPTION_EXPORT_DYNAMIC (OPTION_EMBEDDED_RELOCS + 1)
65 #define OPTION_HELP (OPTION_EXPORT_DYNAMIC + 1)
66 #define OPTION_IGNORE (OPTION_HELP + 1)
67 #define OPTION_MAP (OPTION_IGNORE + 1)
68 #define OPTION_NO_KEEP_MEMORY (OPTION_MAP + 1)
69 #define OPTION_NOINHIBIT_EXEC (OPTION_NO_KEEP_MEMORY + 1)
70 #define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1)
71 #define OPTION_NO_WHOLE_ARCHIVE (OPTION_NON_SHARED + 1)
72 #define OPTION_OFORMAT (OPTION_NO_WHOLE_ARCHIVE + 1)
73 #define OPTION_RELAX (OPTION_OFORMAT + 1)
74 #define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1)
75 #define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1)
76 #define OPTION_RPATH_LINK (OPTION_RPATH + 1)
77 #define OPTION_SHARED (OPTION_RPATH_LINK + 1)
78 #define OPTION_SONAME (OPTION_SHARED + 1)
79 #define OPTION_SORT_COMMON (OPTION_SONAME + 1)
80 #define OPTION_STATS (OPTION_SORT_COMMON + 1)
81 #define OPTION_SYMBOLIC (OPTION_STATS + 1)
82 #define OPTION_TBSS (OPTION_SYMBOLIC + 1)
83 #define OPTION_TDATA (OPTION_TBSS + 1)
84 #define OPTION_TTEXT (OPTION_TDATA + 1)
85 #define OPTION_TRADITIONAL_FORMAT (OPTION_TTEXT + 1)
86 #define OPTION_UR (OPTION_TRADITIONAL_FORMAT + 1)
87 #define OPTION_VERBOSE (OPTION_UR + 1)
88 #define OPTION_VERSION (OPTION_VERBOSE + 1)
89 #define OPTION_WARN_COMMON (OPTION_VERSION + 1)
90 #define OPTION_WARN_CONSTRUCTORS (OPTION_WARN_COMMON + 1)
91 #define OPTION_WARN_MULTIPLE_GP (OPTION_WARN_CONSTRUCTORS + 1)
92 #define OPTION_WARN_ONCE (OPTION_WARN_MULTIPLE_GP + 1)
93 #define OPTION_SPLIT_BY_RELOC (OPTION_WARN_ONCE + 1)
94 #define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1)
95 #define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
96 #define OPTION_WRAP (OPTION_WHOLE_ARCHIVE + 1)
98 /* The long options. This structure is used for both the option
99 parsing and the help text. */
103 /* The long option information. */
105 /* The short option with the same meaning ('\0' if none). */
107 /* The name of the argument (NULL if none). */
109 /* The documentation string. If this is NULL, this is a synonym for
110 the previous option. */
114 /* Use one dash before long option name. */
116 /* Use two dashes before long option name. */
118 /* Don't mention this option in --help output. */
123 static const struct ld_option ld_options[] =
125 { {NULL, required_argument, NULL, '\0'},
126 'a', "KEYWORD", "Shared library control for HP/UX compatibility",
128 { {"architecture", required_argument, NULL, 'A'},
129 'A', "ARCH", "Set architecture" , TWO_DASHES },
130 { {"format", required_argument, NULL, 'b'},
131 'b', "TARGET", "Specify target for following input files", TWO_DASHES },
132 { {"mri-script", required_argument, NULL, 'c'},
133 'c', "FILE", "Read MRI format linker script", TWO_DASHES },
134 { {"dc", no_argument, NULL, 'd'},
135 'd', NULL, "Force common symbols to be defined", ONE_DASH },
136 { {"dp", no_argument, NULL, 'd'},
137 '\0', NULL, NULL, ONE_DASH },
138 { {"entry", required_argument, NULL, 'e'},
139 'e', "ADDRESS", "Set start address", TWO_DASHES },
140 { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
141 'E', NULL, "Export all dynamic symbols", TWO_DASHES },
142 { {NULL, optional_argument, NULL, '\0'},
143 'F', "[FORMAT]", "Ignored", ONE_DASH },
144 { {NULL, no_argument, NULL, '\0'},
145 'g', NULL, "Ignored", ONE_DASH },
146 { {"gpsize", required_argument, NULL, 'G'},
147 'G', "SIZE", "Small data size (if no size, same as --shared)",
149 { {"soname", required_argument, NULL, OPTION_SONAME},
150 'h', "FILENAME", "Set internal name of shared library", ONE_DASH },
151 { {"library", required_argument, NULL, 'l'},
152 'l', "LIBNAME", "Search for library LIBNAME", TWO_DASHES },
153 { {"library-path", required_argument, NULL, 'L'},
154 'L', "DIRECTORY", "Add DIRECTORY to library search path", TWO_DASHES },
155 { {NULL, required_argument, NULL, '\0'},
156 'm', "EMULATION", "Set emulation", ONE_DASH },
157 { {"print-map", no_argument, NULL, 'M'},
158 'M', NULL, "Print map file on standard output", TWO_DASHES },
159 { {"nmagic", no_argument, NULL, 'n'},
160 'n', NULL, "Do not page align data", TWO_DASHES },
161 { {"omagic", no_argument, NULL, 'N'},
162 'N', NULL, "Do not page align data, do not make text readonly",
164 { {"output", required_argument, NULL, 'o'},
165 'o', "FILE", "Set output file name", TWO_DASHES },
166 { {NULL, required_argument, NULL, '\0'},
167 'O', NULL, "Ignored", ONE_DASH },
168 { {"relocateable", no_argument, NULL, 'r'},
169 'r', NULL, "Generate relocateable output", TWO_DASHES },
170 { {NULL, no_argument, NULL, '\0'},
171 'i', NULL, NULL, ONE_DASH },
172 { {"just-symbols", required_argument, NULL, 'R'},
173 'R', "FILE", "Just link symbols (if directory, same as --rpath)",
175 { {"strip-all", no_argument, NULL, 's'},
176 's', NULL, "Strip all symbols", TWO_DASHES },
177 { {"strip-debug", no_argument, NULL, 'S'},
178 'S', NULL, "Strip debugging symbols", TWO_DASHES },
179 { {"trace", no_argument, NULL, 't'},
180 't', NULL, "Trace file opens", TWO_DASHES },
181 { {"script", required_argument, NULL, 'T'},
182 'T', "FILE", "Read linker script", TWO_DASHES },
183 { {"undefined", required_argument, NULL, 'u'},
184 'u', "SYMBOL", "Start with undefined reference to SYMBOL", TWO_DASHES },
185 { {"version", no_argument, NULL, OPTION_VERSION},
186 'v', NULL, "Print version information", TWO_DASHES },
187 { {NULL, no_argument, NULL, '\0'},
188 'V', NULL, "Print version and emulation information", ONE_DASH },
189 { {"discard-all", no_argument, NULL, 'x'},
190 'x', NULL, "Discard all local symbols", TWO_DASHES },
191 { {"discard-locals", no_argument, NULL, 'X'},
192 'X', NULL, "Discard temporary local symbols", TWO_DASHES },
193 { {"trace-symbol", required_argument, NULL, 'y'},
194 'y', "SYMBOL", "Trace mentions of SYMBOL", TWO_DASHES },
195 { {NULL, required_argument, NULL, '\0'},
196 'Y', "PATH", "Default search path for Solaris compatibility", ONE_DASH },
197 { {NULL, required_argument, NULL, '\0'},
198 'z', "KEYWORD", "Ignored for Solaris compatibility", ONE_DASH },
199 { {"start-group", no_argument, NULL, '('},
200 '(', NULL, "Start a group", TWO_DASHES },
201 { {"end-group", no_argument, NULL, ')'},
202 ')', NULL, "End a group", TWO_DASHES },
203 { {"assert", required_argument, NULL, OPTION_ASSERT},
204 '\0', "KEYWORD", "Ignored for SunOS compatibility", ONE_DASH },
205 { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
206 '\0', NULL, "Link against shared libraries", ONE_DASH },
207 { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
208 '\0', NULL, NULL, ONE_DASH },
209 { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
210 '\0', NULL, NULL, ONE_DASH },
211 { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
212 '\0', NULL, "Do not link against shared libraries", ONE_DASH },
213 { {"dn", no_argument, NULL, OPTION_NON_SHARED},
214 '\0', NULL, NULL, ONE_DASH },
215 { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
216 '\0', NULL, NULL, ONE_DASH },
217 { {"static", no_argument, NULL, OPTION_NON_SHARED},
218 '\0', NULL, NULL, ONE_DASH },
219 { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
220 '\0', NULL, "Bind global references locally", ONE_DASH },
221 { {"defsym", required_argument, NULL, OPTION_DEFSYM},
222 '\0', "SYMBOL=EXPRESSION", "Define a symbol", TWO_DASHES },
223 { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
224 '\0', "PROGRAM", "Set the dynamic linker to use", TWO_DASHES },
225 { {"EB", no_argument, NULL, OPTION_EB},
226 '\0', NULL, "Link big-endian objects", ONE_DASH },
227 { {"EL", no_argument, NULL, OPTION_EL},
228 '\0', NULL, "Link little-endian objects", ONE_DASH },
229 { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
230 '\0', NULL, "Generate embedded relocs", TWO_DASHES},
231 { {"help", no_argument, NULL, OPTION_HELP},
232 '\0', NULL, "Print option help", TWO_DASHES },
233 { {"Map", required_argument, NULL, OPTION_MAP},
234 '\0', "FILE", "Write a map file", ONE_DASH },
235 { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
236 '\0', NULL, "Use less memory and more disk I/O", TWO_DASHES },
237 { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
238 '\0', NULL, "Turn off --whole-archive", TWO_DASHES },
239 { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
240 '\0', NULL, "Create an output file even if errors occur", TWO_DASHES },
241 { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
242 '\0', NULL, NULL, NO_HELP },
243 { {"oformat", required_argument, NULL, OPTION_OFORMAT},
244 '\0', "TARGET", "Specify target of output file", TWO_DASHES },
245 { {"qmagic", no_argument, NULL, OPTION_IGNORE},
246 '\0', NULL, "Ignored for Linux compatibility", ONE_DASH },
247 { {"Qy", no_argument, NULL, OPTION_IGNORE},
248 '\0', NULL, "Ignored for SVR4 compatibility", ONE_DASH },
249 { {"relax", no_argument, NULL, OPTION_RELAX},
250 '\0', NULL, "Relax branches on certain targets", TWO_DASHES },
251 { {"retain-symbols-file", required_argument, NULL,
252 OPTION_RETAIN_SYMBOLS_FILE},
253 '\0', "FILE", "Keep only symbols listed in FILE", TWO_DASHES },
254 { {"rpath", required_argument, NULL, OPTION_RPATH},
255 '\0', "PATH", "Set runtime shared library search path", ONE_DASH },
256 { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
257 '\0', "PATH", "Set line time shared library search path", ONE_DASH },
258 { {"shared", no_argument, NULL, OPTION_SHARED},
259 '\0', NULL, "Create a shared library", ONE_DASH },
260 { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */
261 '\0', NULL, NULL, ONE_DASH },
262 { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
263 '\0', NULL, "Sort common symbols by size", TWO_DASHES },
264 { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
265 '\0', NULL, NULL, NO_HELP },
266 { {"split-by-file", no_argument, NULL, OPTION_SPLIT_BY_FILE},
267 '\0', NULL, "Split output sections for each file", TWO_DASHES },
268 { {"split-by-reloc", required_argument, NULL, OPTION_SPLIT_BY_RELOC},
269 '\0', "COUNT", "Split output sections every COUNT relocs", TWO_DASHES },
270 { {"stats", no_argument, NULL, OPTION_STATS},
271 '\0', NULL, "Print memory usage statistics", TWO_DASHES },
272 { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
273 '\0', NULL, "Use same format as native linker", TWO_DASHES },
274 { {"Tbss", required_argument, NULL, OPTION_TBSS},
275 '\0', "ADDRESS", "Set address of .bss section", ONE_DASH },
276 { {"Tdata", required_argument, NULL, OPTION_TDATA},
277 '\0', "ADDRESS", "Set address of .data section", ONE_DASH },
278 { {"Ttext", required_argument, NULL, OPTION_TTEXT},
279 '\0', "ADDRESS", "Set address of .text section", ONE_DASH },
280 { {"Ur", no_argument, NULL, OPTION_UR},
281 '\0', NULL, "Build global constructor/destructor tables", ONE_DASH },
282 { {"verbose", no_argument, NULL, OPTION_VERBOSE},
283 '\0', NULL, "Output lots of information during link", TWO_DASHES },
284 { {"dll-verbose", no_argument, NULL, OPTION_VERSION}, /* Linux. */
285 '\0', NULL, NULL, NO_HELP },
286 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
287 '\0', NULL, "Warn about duplicate common symbols", TWO_DASHES },
288 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
289 '\0', NULL, "Warn if global constructors/destructors are seen",
291 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
292 '\0', NULL, "Warn if the multiple GP values are used", TWO_DASHES },
293 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
294 '\0', NULL, "Warn only once per undefined symbol", TWO_DASHES },
295 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
296 '\0', NULL, "Include all objects from following archives", TWO_DASHES },
297 { {"wrap", required_argument, NULL, OPTION_WRAP},
298 '\0', "SYMBOL", "Use wrapper functions for SYMBOL", TWO_DASHES }
301 #define OPTION_COUNT (sizeof ld_options / sizeof ld_options[0])
304 parse_args (argc, argv)
310 char *default_dirlist = NULL;
311 char shortopts[OPTION_COUNT * 3 + 2];
312 struct option longopts[OPTION_COUNT + 1];
314 /* Starting the short option string with '-' is for programs that
315 expect options and other ARGV-elements in any order and that care about
316 the ordering of the two. We describe each non-option ARGV-element
317 as if it were the argument of an option with character code 1. */
321 for (i = 0; i < OPTION_COUNT; i++)
323 if (ld_options[i].shortopt != '\0')
325 shortopts[is] = ld_options[i].shortopt;
327 if (ld_options[i].opt.has_arg == required_argument
328 || ld_options[i].opt.has_arg == optional_argument)
332 if (ld_options[i].opt.has_arg == optional_argument)
339 if (ld_options[i].opt.name != NULL)
341 longopts[il] = ld_options[i].opt;
345 shortopts[is] = '\0';
346 longopts[il].name = NULL;
348 /* The -G option is ambiguous on different platforms. Sometimes it
349 specifies the largest data size to put into the small data
350 section. Sometimes it is equivalent to --shared. Unfortunately,
351 the first form takes an argument, while the second does not.
353 We need to permit the --shared form because on some platforms,
354 such as Solaris, gcc -shared will pass -G to the linker.
356 To permit either usage, we look through the argument list. If we
357 find -G not followed by a number, we change it into --shared.
358 This will work for most normal cases. */
359 for (i = 1; i < argc; i++)
360 if (strcmp (argv[i], "-G") == 0
362 || ! isdigit (argv[i + 1][0])))
363 argv[i] = (char *) "--shared";
367 /* getopt_long_only is like getopt_long, but '-' as well as '--' can
368 indicate a long option. */
372 if (ldemul_parse_args (argc, argv))
375 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
383 case 1: /* File name. */
384 lang_add_input_file (optarg, lang_input_file_is_file_enum,
391 /* For HP/UX compatibility. Actually -a shared should mean
392 ``use only shared libraries'' but, then, we don't
393 currently support shared libraries on HP/UX anyhow. */
394 if (strcmp (optarg, "archive") == 0)
395 config.dynamic_link = false;
396 else if (strcmp (optarg, "shared") == 0
397 || strcmp (optarg, "default") == 0)
398 config.dynamic_link = true;
400 einfo ("%P%F: unrecognized -a option `%s'\n", optarg);
403 /* FIXME: We just ignore these, but we should handle them. */
404 if (strcmp (optarg, "definitions") == 0)
406 else if (strcmp (optarg, "nodefinitions") == 0)
408 else if (strcmp (optarg, "nosymbolic") == 0)
410 else if (strcmp (optarg, "pure-text") == 0)
413 einfo ("%P%F: unrecognized -assert option `%s'\n", optarg);
416 ldfile_add_arch (optarg);
419 lang_add_target (optarg);
422 ldfile_open_command_file (optarg);
423 parser_input = input_mri_script;
426 case OPTION_CALL_SHARED:
427 config.dynamic_link = true;
429 case OPTION_NON_SHARED:
430 config.dynamic_link = false;
433 command_line.force_common_definition = true;
437 lex_redirect (optarg);
438 parser_input = input_defsym;
444 case OPTION_DYNAMIC_LINKER:
445 command_line.interpreter = optarg;
448 command_line.endian = ENDIAN_BIG;
451 command_line.endian = ENDIAN_LITTLE;
453 case OPTION_EMBEDDED_RELOCS:
454 command_line.embedded_relocs = true;
456 case OPTION_EXPORT_DYNAMIC:
457 case 'E': /* HP/UX compatibility. */
458 command_line.export_dynamic = true;
461 lang_add_entry (optarg, true);
469 g_switch_value = strtoul (optarg, &end, 0);
471 einfo ("%P%F: invalid number `%s'\n", optarg);
482 ldfile_add_library_path (optarg, true);
485 lang_add_input_file (optarg, lang_input_file_is_l_enum,
489 config.map_filename = "-";
492 /* Ignore. Was handled in a pre-parse. */
495 config.map_filename = optarg;
498 config.text_read_only = false;
499 config.magic_demand_paged = false;
500 config.dynamic_link = false;
503 config.magic_demand_paged = false;
504 config.dynamic_link = false;
506 case OPTION_NO_KEEP_MEMORY:
507 link_info.keep_memory = false;
509 case OPTION_NOINHIBIT_EXEC:
510 force_make_executable = true;
512 case OPTION_NO_WHOLE_ARCHIVE:
513 whole_archive = false;
516 /* FIXME "-O<non-digits> <value>" used to set the address of
517 section <non-digits>. Was this for compatibility with
518 something, or can we create a new option to do that
519 (with a syntax similar to -defsym)?
520 getopt can't handle two args to an option without kludges. */
523 lang_add_output (optarg, 0);
526 lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
530 link_info.relocateable = true;
531 config.build_constructors = false;
532 config.magic_demand_paged = false;
533 config.text_read_only = false;
534 config.dynamic_link = false;
537 /* The GNU linker traditionally uses -R to mean to include
538 only the symbols from a file. The Solaris linker uses -R
539 to set the path used by the runtime linker to find
540 libraries. This is the GNU linker -rpath argument. We
541 try to support both simultaneously by checking the file
542 named. If it is a directory, rather than a regular file,
543 we assume -rpath was meant. */
547 if (stat (optarg, &s) >= 0
548 && ! S_ISDIR (s.st_mode))
550 lang_add_input_file (optarg,
551 lang_input_file_is_symbols_only_enum,
558 if (command_line.rpath == NULL)
559 command_line.rpath = buystring (optarg);
564 buf = xmalloc (strlen (command_line.rpath)
567 sprintf (buf, "%s:%s", command_line.rpath, optarg);
568 free (command_line.rpath);
569 command_line.rpath = buf;
572 case OPTION_RPATH_LINK:
573 if (command_line.rpath_link == NULL)
574 command_line.rpath_link = buystring (optarg);
579 buf = xmalloc (strlen (command_line.rpath_link)
582 sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
583 free (command_line.rpath_link);
584 command_line.rpath_link = buf;
588 command_line.relax = true;
590 case OPTION_RETAIN_SYMBOLS_FILE:
591 add_keepsyms_file (optarg);
594 link_info.strip = strip_debugger;
597 link_info.strip = strip_all;
600 link_info.shared = true;
602 case 'h': /* Used on Solaris. */
604 command_line.soname = optarg;
606 case OPTION_SORT_COMMON:
607 config.sort_common = true;
612 case OPTION_SYMBOLIC:
613 link_info.symbolic = true;
619 ldfile_open_command_file (optarg);
620 parser_input = input_script;
624 set_section_start (".bss", optarg);
627 set_section_start (".data", optarg);
630 set_section_start (".text", optarg);
632 case OPTION_TRADITIONAL_FORMAT:
633 link_info.traditional_format = true;
636 link_info.relocateable = true;
637 config.build_constructors = true;
638 config.magic_demand_paged = false;
639 config.text_read_only = false;
640 config.dynamic_link = false;
643 ldlang_add_undef (optarg);
647 version_printed = true;
648 trace_file_tries = true;
652 version_printed = true;
656 version_printed = true;
660 version_printed = true;
662 case OPTION_WARN_COMMON:
663 config.warn_common = true;
665 case OPTION_WARN_CONSTRUCTORS:
666 config.warn_constructors = true;
668 case OPTION_WARN_MULTIPLE_GP:
669 config.warn_multiple_gp = true;
671 case OPTION_WARN_ONCE:
672 config.warn_once = true;
674 case OPTION_WHOLE_ARCHIVE:
675 whole_archive = true;
681 link_info.discard = discard_l;
684 link_info.discard = discard_all;
687 if (strncmp (optarg, "P,", 2) == 0)
689 default_dirlist = optarg;
695 /* We accept and ignore this option for Solaris
696 compatibility. Actually, on Solaris, optarg is not
697 ignored. Someday we should handle it correctly. FIXME. */
699 case OPTION_SPLIT_BY_RELOC:
700 config.split_by_reloc = atoi (optarg);
702 case OPTION_SPLIT_BY_FILE:
703 config.split_by_file = true;
709 "%s: may not nest groups (--help for usage)\n",
720 "%s: group ended before it began (--help for usage)\n",
734 if (default_dirlist != NULL)
735 set_default_dirlist (default_dirlist);
739 /* Add the (colon-separated) elements of DIRLIST_PTR to the
740 library search path. */
743 set_default_dirlist (dirlist_ptr)
750 p = strchr (dirlist_ptr, ':');
754 ldfile_add_library_path (dirlist_ptr, true);
763 set_section_start (sect, valstr)
767 unsigned long val = strtoul (valstr, &end, 16);
769 einfo ("%P%F: invalid hex number `%s'\n", valstr);
770 lang_section_start (sect, exp_intop (val));
773 /* Print help messages for the options. */
779 const char **targets, **pp;
781 printf ("Usage: %s [options] file...\n", program_name);
783 printf ("Options:\n");
784 for (i = 0; i < OPTION_COUNT; i++)
786 if (ld_options[i].doc != NULL)
800 if (ld_options[j].shortopt != '\0'
801 && ld_options[j].control != NO_HELP)
803 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
804 len += (comma ? 2 : 0) + 2;
805 if (ld_options[j].arg != NULL)
807 if (ld_options[j].opt.has_arg != optional_argument)
812 printf ("%s", ld_options[j].arg);
813 len += strlen (ld_options[j].arg);
819 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
824 if (ld_options[j].opt.name != NULL
825 && ld_options[j].control != NO_HELP)
829 ld_options[j].control == TWO_DASHES ? "-" : "",
830 ld_options[j].opt.name);
831 len += ((comma ? 2 : 0)
833 + (ld_options[j].control == TWO_DASHES ? 1 : 0)
834 + strlen (ld_options[j].opt.name));
835 if (ld_options[j].arg != NULL)
837 printf (" %s", ld_options[j].arg);
838 len += 1 + strlen (ld_options[j].arg);
844 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
852 for (; len < 30; len++)
855 printf ("%s\n", ld_options[i].doc);
859 printf ("%s: supported targets:", program_name);
860 targets = bfd_target_list ();
861 for (pp = targets; *pp != NULL; pp++)
866 printf ("%s: supported emulations: ", program_name);
867 ldemul_list_emulations (stdout);