1 /* Parse options for the GNU linker.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 Free Software Foundation, Inc.
6 This file is part of GLD, the Gnu Linker.
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include "libiberty.h"
28 #include "safe-ctype.h"
43 #ifndef PATH_SEPARATOR
44 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
45 #define PATH_SEPARATOR ';'
47 #define PATH_SEPARATOR ':'
51 /* Somewhere above, sys/stat.h got included . . . . */
52 #if !defined(S_ISDIR) && defined(S_IFDIR)
53 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
56 static void set_default_dirlist (char *);
57 static void set_section_start (char *, char *);
58 static void help (void);
60 /* Non-zero if we are processing a --defsym from the command line. */
61 int parsing_defsym = 0;
63 /* Codes used for the long options with no short synonyms. 150 isn't
64 special; it's just an arbitrary non-ASCII char value. */
72 OPTION_DYNAMIC_LINKER,
75 OPTION_EMBEDDED_RELOCS,
76 OPTION_EXPORT_DYNAMIC,
81 OPTION_NO_KEEP_MEMORY,
82 OPTION_NO_WARN_MISMATCH,
83 OPTION_NOINHIBIT_EXEC,
85 OPTION_NO_WHOLE_ARCHIVE,
88 OPTION_RETAIN_SYMBOLS_FILE,
100 OPTION_TRADITIONAL_FORMAT,
104 OPTION_VERSION_SCRIPT,
105 OPTION_VERSION_EXPORTS_SECTION,
107 OPTION_WARN_CONSTRUCTORS,
109 OPTION_WARN_MULTIPLE_GP,
111 OPTION_WARN_SECTION_ALIGN,
112 OPTION_SPLIT_BY_RELOC,
113 OPTION_SPLIT_BY_FILE ,
114 OPTION_WHOLE_ARCHIVE,
116 OPTION_NO_ADD_NEEDED,
120 OPTION_FORCE_EXE_SUFFIX,
122 OPTION_NO_GC_SECTIONS,
124 OPTION_CHECK_SECTIONS,
125 OPTION_NO_CHECK_SECTIONS,
129 OPTION_SECTION_START,
132 OPTION_ALLOW_SHLIB_UNDEFINED,
133 OPTION_NO_ALLOW_SHLIB_UNDEFINED,
134 OPTION_ALLOW_MULTIPLE_DEFINITION,
135 OPTION_NO_UNDEFINED_VERSION,
137 OPTION_SPARE_DYNAMIC_TAGS,
138 OPTION_NO_DEFINE_COMMON,
141 OPTION_STRIP_DISCARDED,
142 OPTION_NO_STRIP_DISCARDED,
143 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH,
144 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH,
146 OPTION_UNRESOLVED_SYMBOLS,
147 OPTION_WARN_UNRESOLVED_SYMBOLS,
148 OPTION_ERROR_UNRESOLVED_SYMBOLS,
149 OPTION_REDUCE_MEMORY_OVERHEADS
152 /* The long options. This structure is used for both the option
153 parsing and the help text. */
157 /* The long option information. */
159 /* The short option with the same meaning ('\0' if none). */
161 /* The name of the argument (NULL if none). */
163 /* The documentation string. If this is NULL, this is a synonym for
164 the previous option. */
167 /* Use one dash before long option name. */
169 /* Use two dashes before long option name. */
171 /* Only accept two dashes before the long option name.
172 This is an overloading of the use of this enum, since originally it
173 was only intended to tell the --help display function how to display
174 the long option name. This feature was added in order to resolve
175 the confusion about the -omagic command line switch. Is it setting
176 the output file name to "magic" or is it setting the NMAGIC flag on
177 the output ? It has been decided that it is setting the output file
178 name, and that if you want to set the NMAGIC flag you should use -N
181 /* Don't mention this option in --help output. */
186 static const struct ld_option ld_options[] =
188 { {NULL, required_argument, NULL, '\0'},
189 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
191 { {"architecture", required_argument, NULL, 'A'},
192 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES },
193 { {"format", required_argument, NULL, 'b'},
194 'b', N_("TARGET"), N_("Specify target for following input files"),
196 { {"mri-script", required_argument, NULL, 'c'},
197 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES },
198 { {"dc", no_argument, NULL, 'd'},
199 'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
200 { {"dp", no_argument, NULL, 'd'},
201 '\0', NULL, NULL, ONE_DASH },
202 { {"entry", required_argument, NULL, 'e'},
203 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
204 { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
205 'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
206 { {"EB", no_argument, NULL, OPTION_EB},
207 '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
208 { {"EL", no_argument, NULL, OPTION_EL},
209 '\0', NULL, N_("Link little-endian objects"), ONE_DASH },
210 { {"auxiliary", required_argument, NULL, 'f'},
211 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
213 { {"filter", required_argument, NULL, 'F'},
214 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
216 { {NULL, no_argument, NULL, '\0'},
217 'g', NULL, N_("Ignored"), ONE_DASH },
218 { {"gpsize", required_argument, NULL, 'G'},
219 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
221 { {"soname", required_argument, NULL, OPTION_SONAME},
222 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
223 { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
224 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
226 { {"library", required_argument, NULL, 'l'},
227 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
228 { {"library-path", required_argument, NULL, 'L'},
229 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
231 { {NULL, required_argument, NULL, '\0'},
232 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH },
233 { {"print-map", no_argument, NULL, 'M'},
234 'M', NULL, N_("Print map file on standard output"), TWO_DASHES },
235 { {"nmagic", no_argument, NULL, 'n'},
236 'n', NULL, N_("Do not page align data"), TWO_DASHES },
237 { {"omagic", no_argument, NULL, 'N'},
238 'N', NULL, N_("Do not page align data, do not make text readonly"),
239 EXACTLY_TWO_DASHES },
240 { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC},
241 '\0', NULL, N_("Page align data, make text readonly"),
242 EXACTLY_TWO_DASHES },
243 { {"output", required_argument, NULL, 'o'},
244 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES },
245 { {NULL, required_argument, NULL, '\0'},
246 'O', NULL, N_("Optimize output file"), ONE_DASH },
247 { {"Qy", no_argument, NULL, OPTION_IGNORE},
248 '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
249 { {"emit-relocs", no_argument, NULL, 'q'},
250 'q', NULL, "Generate relocations in final output", TWO_DASHES },
251 { {"relocatable", no_argument, NULL, 'r'},
252 'r', NULL, N_("Generate relocatable output"), TWO_DASHES },
253 { {NULL, no_argument, NULL, '\0'},
254 'i', NULL, NULL, ONE_DASH },
255 { {"just-symbols", required_argument, NULL, 'R'},
256 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
258 { {"strip-all", no_argument, NULL, 's'},
259 's', NULL, N_("Strip all symbols"), TWO_DASHES },
260 { {"strip-debug", no_argument, NULL, 'S'},
261 'S', NULL, N_("Strip debugging symbols"), TWO_DASHES },
262 { {"strip-discarded", no_argument, NULL, OPTION_STRIP_DISCARDED},
263 '\0', NULL, N_("Strip symbols in discarded sections"), TWO_DASHES },
264 { {"no-strip-discarded", no_argument, NULL, OPTION_NO_STRIP_DISCARDED},
265 '\0', NULL, N_("Do not strip symbols in discarded sections"), TWO_DASHES },
266 { {"trace", no_argument, NULL, 't'},
267 't', NULL, N_("Trace file opens"), TWO_DASHES },
268 { {"script", required_argument, NULL, 'T'},
269 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
270 { {"undefined", required_argument, NULL, 'u'},
271 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
273 { {"unique", optional_argument, NULL, OPTION_UNIQUE},
274 '\0', N_("[=SECTION]"),
275 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
276 { {"Ur", no_argument, NULL, OPTION_UR},
277 '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
278 { {"version", no_argument, NULL, OPTION_VERSION},
279 'v', NULL, N_("Print version information"), TWO_DASHES },
280 { {NULL, no_argument, NULL, '\0'},
281 'V', NULL, N_("Print version and emulation information"), ONE_DASH },
282 { {"discard-all", no_argument, NULL, 'x'},
283 'x', NULL, N_("Discard all local symbols"), TWO_DASHES },
284 { {"discard-locals", no_argument, NULL, 'X'},
285 'X', NULL, N_("Discard temporary local symbols (default)"), TWO_DASHES },
286 { {"discard-none", no_argument, NULL, OPTION_DISCARD_NONE},
287 '\0', NULL, N_("Don't discard any local symbols"), TWO_DASHES },
288 { {"trace-symbol", required_argument, NULL, 'y'},
289 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
290 { {NULL, required_argument, NULL, '\0'},
291 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
293 { {"start-group", no_argument, NULL, '('},
294 '(', NULL, N_("Start a group"), TWO_DASHES },
295 { {"end-group", no_argument, NULL, ')'},
296 ')', NULL, N_("End a group"), TWO_DASHES },
297 { {"accept-unknown-input-arch", no_argument, NULL,
298 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH},
300 N_("Accept input files whose architecture cannot be determined"),
302 { {"no-accept-unknown-input-arch", no_argument, NULL,
303 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
304 '\0', NULL, N_("Reject input files whose architecture is unknown"),
306 { {"assert", required_argument, NULL, OPTION_ASSERT},
307 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
308 { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
309 '\0', NULL, N_("Link against shared libraries"), ONE_DASH },
310 { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
311 '\0', NULL, NULL, ONE_DASH },
312 { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
313 '\0', NULL, NULL, ONE_DASH },
314 { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
315 '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
316 { {"dn", no_argument, NULL, OPTION_NON_SHARED},
317 '\0', NULL, NULL, ONE_DASH },
318 { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
319 '\0', NULL, NULL, ONE_DASH },
320 { {"static", no_argument, NULL, OPTION_NON_SHARED},
321 '\0', NULL, NULL, ONE_DASH },
322 { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
323 '\0', NULL, N_("Bind global references locally"), ONE_DASH },
324 { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
325 '\0', NULL, N_("Check section addresses for overlaps (default)"),
327 { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
328 '\0', NULL, N_("Do not check section addresses for overlaps"),
330 { {"cref", no_argument, NULL, OPTION_CREF},
331 '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
332 { {"defsym", required_argument, NULL, OPTION_DEFSYM},
333 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
334 { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
335 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
337 { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
338 '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
339 { {"fini", required_argument, NULL, OPTION_FINI},
340 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
341 { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
342 '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
343 { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
344 '\0', NULL, N_("Remove unused sections (on some targets)"),
346 { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
347 '\0', NULL, N_("Don't remove unused sections (default)"),
349 { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
350 '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
352 { {"help", no_argument, NULL, OPTION_HELP},
353 '\0', NULL, N_("Print option help"), TWO_DASHES },
354 { {"init", required_argument, NULL, OPTION_INIT},
355 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
356 { {"Map", required_argument, NULL, OPTION_MAP},
357 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH },
358 { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
359 '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
360 { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
361 '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
362 { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
363 '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES },
364 { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
365 '\0', NULL, N_("Do not allow unresolved references in object files"),
367 { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED},
368 '\0', NULL, N_("Allow unresolved references in shared libaries"),
370 { {"no-allow-shlib-undefined", no_argument, NULL,
371 OPTION_NO_ALLOW_SHLIB_UNDEFINED},
372 '\0', NULL, N_("Do not allow unresolved references in shared libs"),
374 { {"allow-multiple-definition", no_argument, NULL,
375 OPTION_ALLOW_MULTIPLE_DEFINITION},
376 '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES },
377 { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
378 '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
379 { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
380 '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
381 { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
382 '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
383 { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
384 '\0', NULL, N_("Create an output file even if errors occur"),
386 { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
387 '\0', NULL, NULL, NO_HELP },
388 { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB},
389 '\0', NULL, N_("Only use library directories specified on\n"
390 "\t\t\t\tthe command line"), ONE_DASH },
391 { {"oformat", required_argument, NULL, OPTION_OFORMAT},
392 '\0', N_("TARGET"), N_("Specify target of output file"),
393 EXACTLY_TWO_DASHES },
394 { {"qmagic", no_argument, NULL, OPTION_IGNORE},
395 '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
396 { {"reduce-memory-overheads", no_argument, NULL,
397 OPTION_REDUCE_MEMORY_OVERHEADS},
398 '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
400 { {"relax", no_argument, NULL, OPTION_RELAX},
401 '\0', NULL, N_("Relax branches on certain targets"), TWO_DASHES },
402 { {"retain-symbols-file", required_argument, NULL,
403 OPTION_RETAIN_SYMBOLS_FILE},
404 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
405 { {"rpath", required_argument, NULL, OPTION_RPATH},
406 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH },
407 { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
408 '\0', N_("PATH"), N_("Set link time shared library search path"),
410 { {"shared", no_argument, NULL, OPTION_SHARED},
411 '\0', NULL, N_("Create a shared library"), ONE_DASH },
412 { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */
413 '\0', NULL, NULL, ONE_DASH },
414 { {"pie", no_argument, NULL, OPTION_PIE},
415 '\0', NULL, N_("Create a position independent executable"), ONE_DASH },
416 { {"pic-executable", no_argument, NULL, OPTION_PIE},
417 '\0', NULL, NULL, TWO_DASHES },
418 { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
419 '\0', NULL, N_("Sort common symbols by size"), TWO_DASHES },
420 { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
421 '\0', NULL, NULL, NO_HELP },
422 { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
423 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
425 { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE},
426 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
428 { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC},
429 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
431 { {"stats", no_argument, NULL, OPTION_STATS},
432 '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
433 { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
434 '\0', NULL, N_("Display target specific options"), TWO_DASHES },
435 { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
436 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
437 { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
438 '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
439 { {"section-start", required_argument, NULL, OPTION_SECTION_START},
440 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
442 { {"Tbss", required_argument, NULL, OPTION_TBSS},
443 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
444 { {"Tdata", required_argument, NULL, OPTION_TDATA},
445 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
446 { {"Ttext", required_argument, NULL, OPTION_TTEXT},
447 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
448 { {"unresolved-symbols=<method>", required_argument, NULL,
449 OPTION_UNRESOLVED_SYMBOLS},
450 '\0', NULL, N_("How to handle unresolved symbols. <method> is:\n"
451 "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
452 "\t\t\t\tignore-in-shared-libs"), TWO_DASHES },
453 { {"verbose", no_argument, NULL, OPTION_VERBOSE},
454 '\0', NULL, N_("Output lots of information during link"), TWO_DASHES },
455 { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */
456 '\0', NULL, NULL, NO_HELP },
457 { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
458 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
459 { {"version-exports-section", required_argument, NULL,
460 OPTION_VERSION_EXPORTS_SECTION },
461 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
462 "\t\t\t\tSYMBOL as the version."), TWO_DASHES },
463 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
464 '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
465 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
466 '\0', NULL, N_("Warn if global constructors/destructors are seen"),
468 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
469 '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
470 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
471 '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
472 { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
473 '\0', NULL, N_("Warn if start of section changes due to alignment"),
475 { {"warn-unresolved-symbols", no_argument, NULL,
476 OPTION_WARN_UNRESOLVED_SYMBOLS},
477 '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
478 { {"error-unresolved-symbols", no_argument, NULL,
479 OPTION_ERROR_UNRESOLVED_SYMBOLS},
480 '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES },
481 { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
482 '\0', NULL, N_("Treat warnings as errors"),
484 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
485 '\0', NULL, N_("Include all objects from following archives"),
487 { {"add-needed", no_argument, NULL, OPTION_ADD_NEEDED},
488 '\0', NULL, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
489 "\t\t\t\tfollowing dynamic libs"), TWO_DASHES },
490 { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_NEEDED},
491 '\0', NULL, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
492 "\t\t\t\tin following dynamic libs"), TWO_DASHES },
493 { {"as-needed", no_argument, NULL, OPTION_AS_NEEDED},
494 '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
496 { {"no-as-needed", no_argument, NULL, OPTION_NO_AS_NEEDED},
497 '\0', NULL, N_("Always set DT_NEEDED for following dynamic libs"),
499 { {"wrap", required_argument, NULL, OPTION_WRAP},
500 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
503 #define OPTION_COUNT ARRAY_SIZE (ld_options)
506 parse_args (unsigned argc, char **argv)
511 char *default_dirlist = NULL;
513 struct option *longopts;
514 struct option *really_longopts;
516 enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
518 shortopts = xmalloc (OPTION_COUNT * 3 + 2);
519 longopts = xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
520 really_longopts = xmalloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
522 /* Starting the short option string with '-' is for programs that
523 expect options and other ARGV-elements in any order and that care about
524 the ordering of the two. We describe each non-option ARGV-element
525 as if it were the argument of an option with character code 1. */
530 for (i = 0; i < OPTION_COUNT; i++)
532 if (ld_options[i].shortopt != '\0')
534 shortopts[is] = ld_options[i].shortopt;
536 if (ld_options[i].opt.has_arg == required_argument
537 || ld_options[i].opt.has_arg == optional_argument)
541 if (ld_options[i].opt.has_arg == optional_argument)
548 if (ld_options[i].opt.name != NULL)
550 if (ld_options[i].control == EXACTLY_TWO_DASHES)
552 really_longopts[irl] = ld_options[i].opt;
557 longopts[il] = ld_options[i].opt;
562 shortopts[is] = '\0';
563 longopts[il].name = NULL;
564 really_longopts[irl].name = NULL;
566 ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
568 /* The -G option is ambiguous on different platforms. Sometimes it
569 specifies the largest data size to put into the small data
570 section. Sometimes it is equivalent to --shared. Unfortunately,
571 the first form takes an argument, while the second does not.
573 We need to permit the --shared form because on some platforms,
574 such as Solaris, gcc -shared will pass -G to the linker.
576 To permit either usage, we look through the argument list. If we
577 find -G not followed by a number, we change it into --shared.
578 This will work for most normal cases. */
579 for (i = 1; i < argc; i++)
580 if (strcmp (argv[i], "-G") == 0
582 || ! ISDIGIT (argv[i + 1][0])))
583 argv[i] = (char *) "--shared";
585 /* Because we permit long options to start with a single dash, and
586 we have a --library option, and the -l option is conventionally
587 used with an immediately following argument, we can have bad
588 results if somebody tries to use -l with a library whose name
589 happens to start with "ibrary", as in -li. We avoid problems by
590 simply turning -l into --library. This means that users will
591 have to use two dashes in order to use --library, which is OK
592 since that's how it is documented.
594 FIXME: It's possible that this problem can arise for other short
595 options as well, although the user does always have the recourse
596 of adding a space between the option and the argument. */
597 for (i = 1; i < argc; i++)
599 if (argv[i][0] == '-'
601 && argv[i][2] != '\0')
605 n = xmalloc (strlen (argv[i]) + 20);
606 sprintf (n, "--library=%s", argv[i] + 2);
617 /* Using last_optind lets us avoid calling ldemul_parse_args
618 multiple times on a single option, which would lead to
619 confusion in the internal static variables maintained by
620 getopt. This could otherwise happen for an argument like
621 -nx, in which the -n is parsed as a single option, and we
622 loop around to pick up the -x. */
623 if (optind != last_optind)
624 if (ldemul_parse_args (argc, argv))
627 /* getopt_long_only is like getopt_long, but '-' as well as '--'
628 can indicate a long option. */
630 last_optind = optind;
631 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
634 optind = last_optind;
635 optc = getopt_long (argc, argv, "-", really_longopts, &longind);
638 if (ldemul_handle_option (optc))
647 einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
649 einfo (_("%P%F: use the --help option for usage information\n"));
651 case 1: /* File name. */
652 lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL);
658 /* For HP/UX compatibility. Actually -a shared should mean
659 ``use only shared libraries'' but, then, we don't
660 currently support shared libraries on HP/UX anyhow. */
661 if (strcmp (optarg, "archive") == 0)
662 config.dynamic_link = FALSE;
663 else if (strcmp (optarg, "shared") == 0
664 || strcmp (optarg, "default") == 0)
665 config.dynamic_link = TRUE;
667 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg);
670 /* FIXME: We just ignore these, but we should handle them. */
671 if (strcmp (optarg, "definitions") == 0)
673 else if (strcmp (optarg, "nodefinitions") == 0)
675 else if (strcmp (optarg, "nosymbolic") == 0)
677 else if (strcmp (optarg, "pure-text") == 0)
680 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg);
683 ldfile_add_arch (optarg);
686 lang_add_target (optarg);
689 ldfile_open_command_file (optarg);
690 parser_input = input_mri_script;
693 case OPTION_CALL_SHARED:
694 config.dynamic_link = TRUE;
696 case OPTION_NON_SHARED:
697 config.dynamic_link = FALSE;
700 command_line.cref = TRUE;
701 link_info.notice_all = TRUE;
704 command_line.force_common_definition = TRUE;
708 lex_redirect (optarg);
709 parser_input = input_defsym;
715 case OPTION_DEMANGLE:
719 enum demangling_styles style;
721 style = cplus_demangle_name_to_style (optarg);
722 if (style == unknown_demangling)
723 einfo (_("%F%P: unknown demangling style `%s'"),
726 cplus_demangle_set_style (style);
729 case 'I': /* Used on Solaris. */
730 case OPTION_DYNAMIC_LINKER:
731 command_line.interpreter = optarg;
734 command_line.endian = ENDIAN_BIG;
737 command_line.endian = ENDIAN_LITTLE;
739 case OPTION_EMBEDDED_RELOCS:
740 command_line.embedded_relocs = TRUE;
742 case OPTION_EXPORT_DYNAMIC:
743 case 'E': /* HP/UX compatibility. */
744 link_info.export_dynamic = TRUE;
747 lang_add_entry (optarg, TRUE);
750 if (command_line.auxiliary_filters == NULL)
752 command_line.auxiliary_filters = xmalloc (2 * sizeof (char *));
753 command_line.auxiliary_filters[0] = optarg;
754 command_line.auxiliary_filters[1] = NULL;
762 for (p = command_line.auxiliary_filters; *p != NULL; p++)
764 command_line.auxiliary_filters
765 = xrealloc (command_line.auxiliary_filters,
766 (c + 2) * sizeof (char *));
767 command_line.auxiliary_filters[c] = optarg;
768 command_line.auxiliary_filters[c + 1] = NULL;
772 command_line.filter_shlib = optarg;
774 case OPTION_FORCE_EXE_SUFFIX:
775 command_line.force_exe_suffix = TRUE;
780 g_switch_value = strtoul (optarg, &end, 0);
782 einfo (_("%P%F: invalid number `%s'\n"), optarg);
788 case OPTION_GC_SECTIONS:
789 command_line.gc_sections = TRUE;
796 ldfile_add_library_path (optarg, TRUE);
799 lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL);
802 config.map_filename = "-";
805 /* Ignore. Was handled in a pre-parse. */
808 config.map_filename = optarg;
811 config.text_read_only = FALSE;
812 config.magic_demand_paged = FALSE;
813 config.dynamic_link = FALSE;
815 case OPTION_NO_OMAGIC:
816 config.text_read_only = TRUE;
817 config.magic_demand_paged = TRUE;
818 /* NB/ Does not set dynamic_link to TRUE.
819 Use --call-shared or -Bdynamic for this. */
822 config.magic_demand_paged = FALSE;
823 config.dynamic_link = FALSE;
825 case OPTION_NO_DEFINE_COMMON:
826 command_line.inhibit_common_definition = TRUE;
828 case OPTION_NO_DEMANGLE:
831 case OPTION_NO_GC_SECTIONS:
832 command_line.gc_sections = FALSE;
834 case OPTION_NO_KEEP_MEMORY:
835 link_info.keep_memory = FALSE;
837 case OPTION_NO_UNDEFINED:
838 link_info.unresolved_syms_in_objects
839 = how_to_report_unresolved_symbols;
841 case OPTION_ALLOW_SHLIB_UNDEFINED:
842 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
844 case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
845 link_info.unresolved_syms_in_shared_libs
846 = how_to_report_unresolved_symbols;
848 case OPTION_UNRESOLVED_SYMBOLS:
849 if (strcmp (optarg, "ignore-all") == 0)
851 link_info.unresolved_syms_in_objects = RM_IGNORE;
852 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
854 else if (strcmp (optarg, "report-all") == 0)
856 link_info.unresolved_syms_in_objects
857 = how_to_report_unresolved_symbols;
858 link_info.unresolved_syms_in_shared_libs
859 = how_to_report_unresolved_symbols;
861 else if (strcmp (optarg, "ignore-in-object-files") == 0)
863 link_info.unresolved_syms_in_objects = RM_IGNORE;
864 link_info.unresolved_syms_in_shared_libs
865 = how_to_report_unresolved_symbols;
867 else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
869 link_info.unresolved_syms_in_objects
870 = how_to_report_unresolved_symbols;
871 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
874 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg);
876 case OPTION_WARN_UNRESOLVED_SYMBOLS:
877 how_to_report_unresolved_symbols = RM_GENERATE_WARNING;
878 if (link_info.unresolved_syms_in_objects == RM_GENERATE_ERROR)
879 link_info.unresolved_syms_in_objects = RM_GENERATE_WARNING;
880 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
881 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_WARNING;
884 case OPTION_ERROR_UNRESOLVED_SYMBOLS:
885 how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
886 if (link_info.unresolved_syms_in_objects == RM_GENERATE_WARNING)
887 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
888 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_WARNING)
889 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
891 case OPTION_ALLOW_MULTIPLE_DEFINITION:
892 link_info.allow_multiple_definition = TRUE;
894 case OPTION_NO_UNDEFINED_VERSION:
895 link_info.allow_undefined_version = FALSE;
897 case OPTION_NO_WARN_MISMATCH:
898 command_line.warn_mismatch = FALSE;
900 case OPTION_NOINHIBIT_EXEC:
901 force_make_executable = TRUE;
903 case OPTION_NOSTDLIB:
904 config.only_cmd_line_lib_dirs = TRUE;
906 case OPTION_NO_WHOLE_ARCHIVE:
907 whole_archive = FALSE;
910 /* FIXME "-O<non-digits> <value>" used to set the address of
911 section <non-digits>. Was this for compatibility with
912 something, or can we create a new option to do that
913 (with a syntax similar to -defsym)?
914 getopt can't handle two args to an option without kludges. */
916 /* Enable optimizations of output files. */
917 link_info.optimize = strtoul (optarg, NULL, 0) ? TRUE : FALSE;
920 lang_add_output (optarg, 0);
923 lang_add_output_format (optarg, NULL, NULL, 0);
926 link_info.emitrelocations = TRUE;
930 if (optind == last_optind)
931 /* This can happen if the user put "-rpath,a" on the command
932 line. (Or something similar. The comma is important).
933 Getopt becomes confused and thinks that this is a -r option
934 but it cannot parse the text after the -r so it refuses to
935 increment the optind counter. Detect this case and issue
936 an error message here. We cannot just make this a warning,
937 increment optind, and continue because getopt is too confused
938 and will seg-fault the next time around. */
939 einfo(_("%P%F: bad -rpath option\n"));
941 link_info.relocatable = TRUE;
942 config.build_constructors = FALSE;
943 config.magic_demand_paged = FALSE;
944 config.text_read_only = FALSE;
945 config.dynamic_link = FALSE;
948 /* The GNU linker traditionally uses -R to mean to include
949 only the symbols from a file. The Solaris linker uses -R
950 to set the path used by the runtime linker to find
951 libraries. This is the GNU linker -rpath argument. We
952 try to support both simultaneously by checking the file
953 named. If it is a directory, rather than a regular file,
954 we assume -rpath was meant. */
958 if (stat (optarg, &s) >= 0
959 && ! S_ISDIR (s.st_mode))
961 lang_add_input_file (optarg,
962 lang_input_file_is_symbols_only_enum,
969 if (command_line.rpath == NULL)
970 command_line.rpath = xstrdup (optarg);
973 size_t rpath_len = strlen (command_line.rpath);
974 size_t optarg_len = strlen (optarg);
976 char *cp = command_line.rpath;
978 /* First see whether OPTARG is already in the path. */
983 while (optarg[idx] != '\0' && optarg[idx] == cp[idx])
985 if (optarg[idx] == '\0'
986 && (cp[idx] == '\0' || cp[idx] == ':'))
991 cp = strchr (cp, ':');
999 buf = xmalloc (rpath_len + optarg_len + 2);
1000 sprintf (buf, "%s:%s", command_line.rpath, optarg);
1001 free (command_line.rpath);
1002 command_line.rpath = buf;
1006 case OPTION_RPATH_LINK:
1007 if (command_line.rpath_link == NULL)
1008 command_line.rpath_link = xstrdup (optarg);
1013 buf = xmalloc (strlen (command_line.rpath_link)
1016 sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
1017 free (command_line.rpath_link);
1018 command_line.rpath_link = buf;
1022 command_line.relax = TRUE;
1024 case OPTION_RETAIN_SYMBOLS_FILE:
1025 add_keepsyms_file (optarg);
1028 link_info.strip = strip_debugger;
1031 link_info.strip = strip_all;
1033 case OPTION_STRIP_DISCARDED:
1034 link_info.strip_discarded = TRUE;
1036 case OPTION_NO_STRIP_DISCARDED:
1037 link_info.strip_discarded = FALSE;
1040 if (config.has_shared)
1042 link_info.shared = TRUE;
1043 /* When creating a shared library, the default
1044 behaviour is to ignore any unresolved references. */
1045 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1046 link_info.unresolved_syms_in_objects = RM_IGNORE;
1047 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1048 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1051 einfo (_("%P%F: -shared not supported\n"));
1054 if (config.has_shared)
1056 link_info.shared = TRUE;
1057 link_info.pie = TRUE;
1060 einfo (_("%P%F: -pie not supported\n"));
1062 case 'h': /* Used on Solaris. */
1064 command_line.soname = optarg;
1066 case OPTION_SORT_COMMON:
1067 config.sort_common = TRUE;
1070 config.stats = TRUE;
1072 case OPTION_SYMBOLIC:
1073 link_info.symbolic = TRUE;
1079 ldfile_open_command_file (optarg);
1080 parser_input = input_script;
1083 case OPTION_SECTION_START:
1089 /* Check for <something>=<somthing>... */
1090 optarg2 = strchr (optarg, '=');
1091 if (optarg2 == NULL)
1092 einfo (_("%P%F: invalid argument to option"
1093 " \"--section-start\"\n"));
1097 /* So far so good. Are all the args present? */
1098 if ((*optarg == '\0') || (*optarg2 == '\0'))
1099 einfo (_("%P%F: missing argument(s) to option"
1100 " \"--section-start\"\n"));
1102 /* We must copy the section name as set_section_start
1103 doesn't do it for us. */
1104 len = optarg2 - optarg;
1105 sec_name = xmalloc (len);
1106 memcpy (sec_name, optarg, len - 1);
1107 sec_name[len - 1] = 0;
1109 /* Then set it... */
1110 set_section_start (sec_name, optarg2);
1113 case OPTION_TARGET_HELP:
1114 /* Mention any target specific options. */
1115 ldemul_list_emulation_options (stdout);
1118 set_section_start (".bss", optarg);
1121 set_section_start (".data", optarg);
1124 set_section_start (".text", optarg);
1126 case OPTION_TRADITIONAL_FORMAT:
1127 link_info.traditional_format = TRUE;
1129 case OPTION_TASK_LINK:
1130 link_info.task_link = TRUE;
1131 /* Fall through - do an implied -r option. */
1133 link_info.relocatable = TRUE;
1134 config.build_constructors = TRUE;
1135 config.magic_demand_paged = FALSE;
1136 config.text_read_only = FALSE;
1137 config.dynamic_link = FALSE;
1140 ldlang_add_undef (optarg);
1144 lang_add_unique (optarg);
1146 config.unique_orphan_sections = TRUE;
1148 case OPTION_VERBOSE:
1150 version_printed = TRUE;
1151 trace_file_tries = TRUE;
1152 overflow_cutoff_limit = -2;
1156 version_printed = TRUE;
1160 version_printed = TRUE;
1162 case OPTION_VERSION:
1166 case OPTION_VERSION_SCRIPT:
1167 /* This option indicates a small script that only specifies
1168 version information. Read it, but don't assume that
1169 we've seen a linker script. */
1171 FILE *hold_script_handle;
1173 hold_script_handle = saved_script_handle;
1174 ldfile_open_command_file (optarg);
1175 saved_script_handle = hold_script_handle;
1176 parser_input = input_version_script;
1180 case OPTION_VERSION_EXPORTS_SECTION:
1181 /* This option records a version symbol to be applied to the
1182 symbols listed for export to be found in the object files
1183 .exports sections. */
1184 command_line.version_exports_section = optarg;
1186 case OPTION_WARN_COMMON:
1187 config.warn_common = TRUE;
1189 case OPTION_WARN_CONSTRUCTORS:
1190 config.warn_constructors = TRUE;
1192 case OPTION_WARN_FATAL:
1193 config.fatal_warnings = TRUE;
1195 case OPTION_WARN_MULTIPLE_GP:
1196 config.warn_multiple_gp = TRUE;
1198 case OPTION_WARN_ONCE:
1199 config.warn_once = TRUE;
1201 case OPTION_WARN_SECTION_ALIGN:
1202 config.warn_section_align = TRUE;
1204 case OPTION_WHOLE_ARCHIVE:
1205 whole_archive = TRUE;
1207 case OPTION_ADD_NEEDED:
1210 case OPTION_NO_ADD_NEEDED:
1213 case OPTION_AS_NEEDED:
1216 case OPTION_NO_AS_NEEDED:
1222 case OPTION_DISCARD_NONE:
1223 link_info.discard = discard_none;
1226 link_info.discard = discard_l;
1229 link_info.discard = discard_all;
1232 if (strncmp (optarg, "P,", 2) == 0)
1234 if (default_dirlist != NULL)
1235 free (default_dirlist);
1236 default_dirlist = xstrdup (optarg);
1241 case OPTION_SPARE_DYNAMIC_TAGS:
1242 link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0);
1244 case OPTION_SPLIT_BY_RELOC:
1246 config.split_by_reloc = strtoul (optarg, NULL, 0);
1248 config.split_by_reloc = 32768;
1250 case OPTION_SPLIT_BY_FILE:
1252 config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
1254 config.split_by_file = 1;
1256 case OPTION_CHECK_SECTIONS:
1257 command_line.check_section_addresses = TRUE;
1259 case OPTION_NO_CHECK_SECTIONS:
1260 command_line.check_section_addresses = FALSE;
1262 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
1263 command_line.accept_unknown_input_arch = TRUE;
1265 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
1266 command_line.accept_unknown_input_arch = FALSE;
1270 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1272 lang_enter_group ();
1277 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1279 lang_leave_group ();
1284 link_info.init_function = optarg;
1288 link_info.fini_function = optarg;
1291 case OPTION_REDUCE_MEMORY_OVERHEADS:
1292 command_line.reduce_memory_overheads = TRUE;
1293 if (config.hash_table_size == 0)
1294 config.hash_table_size = 1021;
1297 case OPTION_HASH_SIZE:
1299 bfd_size_type new_size;
1301 new_size = strtoul (optarg, NULL, 0);
1303 config.hash_table_size = new_size;
1305 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1312 lang_leave_group ();
1314 if (default_dirlist != NULL)
1316 set_default_dirlist (default_dirlist);
1317 free (default_dirlist);
1320 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1321 /* FIXME: Should we allow emulations a chance to set this ? */
1322 link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
1324 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1325 /* FIXME: Should we allow emulations a chance to set this ? */
1326 link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
1329 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1330 library search path. */
1333 set_default_dirlist (char *dirlist_ptr)
1339 p = strchr (dirlist_ptr, PATH_SEPARATOR);
1342 if (*dirlist_ptr != '\0')
1343 ldfile_add_library_path (dirlist_ptr, TRUE);
1346 dirlist_ptr = p + 1;
1351 set_section_start (char *sect, char *valstr)
1354 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1356 einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
1357 lang_section_start (sect, exp_intop (val));
1360 /* Print help messages for the options. */
1366 const char **targets, **pp;
1368 printf (_("Usage: %s [options] file...\n"), program_name);
1370 printf (_("Options:\n"));
1371 for (i = 0; i < OPTION_COUNT; i++)
1373 if (ld_options[i].doc != NULL)
1387 if (ld_options[j].shortopt != '\0'
1388 && ld_options[j].control != NO_HELP)
1390 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
1391 len += (comma ? 2 : 0) + 2;
1392 if (ld_options[j].arg != NULL)
1394 if (ld_options[j].opt.has_arg != optional_argument)
1399 printf ("%s", _(ld_options[j].arg));
1400 len += strlen (_(ld_options[j].arg));
1406 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1411 if (ld_options[j].opt.name != NULL
1412 && ld_options[j].control != NO_HELP)
1415 (ld_options[j].control == TWO_DASHES
1416 || ld_options[j].control == EXACTLY_TWO_DASHES);
1420 two_dashes ? "-" : "",
1421 ld_options[j].opt.name);
1422 len += ((comma ? 2 : 0)
1424 + (two_dashes ? 1 : 0)
1425 + strlen (ld_options[j].opt.name));
1426 if (ld_options[j].arg != NULL)
1428 printf (" %s", _(ld_options[j].arg));
1429 len += 1 + strlen (_(ld_options[j].arg));
1435 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1443 for (; len < 30; len++)
1446 printf ("%s\n", _(ld_options[i].doc));
1450 /* Note: Various tools (such as libtool) depend upon the
1451 format of the listings below - do not change them. */
1452 /* xgettext:c-format */
1453 printf (_("%s: supported targets:"), program_name);
1454 targets = bfd_target_list ();
1455 for (pp = targets; *pp != NULL; pp++)
1456 printf (" %s", *pp);
1460 /* xgettext:c-format */
1461 printf (_("%s: supported emulations: "), program_name);
1462 ldemul_list_emulations (stdout);
1465 /* xgettext:c-format */
1466 printf (_("%s: emulation specific options:\n"), program_name);
1467 ldemul_list_emulation_options (stdout);
1470 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);