1 /* Parse options for the GNU linker.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005
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, 51 Franklin Street - Fifth Floor, Boston, MA
26 #include "libiberty.h"
29 #include "safe-ctype.h"
44 #ifndef PATH_SEPARATOR
45 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
46 #define PATH_SEPARATOR ';'
48 #define PATH_SEPARATOR ':'
52 /* Somewhere above, sys/stat.h got included . . . . */
53 #if !defined(S_ISDIR) && defined(S_IFDIR)
54 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
57 static void set_default_dirlist (char *);
58 static void set_section_start (char *, char *);
59 static void set_segment_start (const char *, char *);
60 static void help (void);
62 /* Non-zero if we are processing a --defsym from the command line. */
63 int parsing_defsym = 0;
65 /* Codes used for the long options with no short synonyms. 150 isn't
66 special; it's just an arbitrary non-ASCII char value. */
74 OPTION_DYNAMIC_LINKER,
78 OPTION_EMBEDDED_RELOCS,
79 OPTION_EXPORT_DYNAMIC,
84 OPTION_NO_KEEP_MEMORY,
85 OPTION_NO_WARN_MISMATCH,
86 OPTION_NOINHIBIT_EXEC,
88 OPTION_NO_WHOLE_ARCHIVE,
91 OPTION_RETAIN_SYMBOLS_FILE,
104 OPTION_TRADITIONAL_FORMAT,
108 OPTION_VERSION_SCRIPT,
109 OPTION_VERSION_EXPORTS_SECTION,
111 OPTION_WARN_CONSTRUCTORS,
113 OPTION_WARN_MULTIPLE_GP,
115 OPTION_WARN_SECTION_ALIGN,
116 OPTION_SPLIT_BY_RELOC,
117 OPTION_SPLIT_BY_FILE ,
118 OPTION_WHOLE_ARCHIVE,
120 OPTION_NO_ADD_NEEDED,
124 OPTION_FORCE_EXE_SUFFIX,
126 OPTION_NO_GC_SECTIONS,
127 OPTION_PRINT_GC_SECTIONS,
128 OPTION_NO_PRINT_GC_SECTIONS,
130 OPTION_CHECK_SECTIONS,
131 OPTION_NO_CHECK_SECTIONS,
135 OPTION_SECTION_START,
138 OPTION_ALLOW_SHLIB_UNDEFINED,
139 OPTION_NO_ALLOW_SHLIB_UNDEFINED,
140 OPTION_ALLOW_MULTIPLE_DEFINITION,
141 OPTION_NO_UNDEFINED_VERSION,
142 OPTION_DEFAULT_SYMVER,
143 OPTION_DEFAULT_IMPORTED_SYMVER,
145 OPTION_SPARE_DYNAMIC_TAGS,
146 OPTION_NO_DEFINE_COMMON,
149 OPTION_STRIP_DISCARDED,
150 OPTION_NO_STRIP_DISCARDED,
151 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH,
152 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH,
154 OPTION_UNRESOLVED_SYMBOLS,
155 OPTION_WARN_UNRESOLVED_SYMBOLS,
156 OPTION_ERROR_UNRESOLVED_SYMBOLS,
157 OPTION_WARN_SHARED_TEXTREL,
158 OPTION_REDUCE_MEMORY_OVERHEADS
161 /* The long options. This structure is used for both the option
162 parsing and the help text. */
166 /* The long option information. */
168 /* The short option with the same meaning ('\0' if none). */
170 /* The name of the argument (NULL if none). */
172 /* The documentation string. If this is NULL, this is a synonym for
173 the previous option. */
176 /* Use one dash before long option name. */
178 /* Use two dashes before long option name. */
180 /* Only accept two dashes before the long option name.
181 This is an overloading of the use of this enum, since originally it
182 was only intended to tell the --help display function how to display
183 the long option name. This feature was added in order to resolve
184 the confusion about the -omagic command line switch. Is it setting
185 the output file name to "magic" or is it setting the NMAGIC flag on
186 the output ? It has been decided that it is setting the output file
187 name, and that if you want to set the NMAGIC flag you should use -N
190 /* Don't mention this option in --help output. */
195 static const struct ld_option ld_options[] =
197 { {NULL, required_argument, NULL, '\0'},
198 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
200 { {"architecture", required_argument, NULL, 'A'},
201 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES },
202 { {"format", required_argument, NULL, 'b'},
203 'b', N_("TARGET"), N_("Specify target for following input files"),
205 { {"mri-script", required_argument, NULL, 'c'},
206 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES },
207 { {"dc", no_argument, NULL, 'd'},
208 'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
209 { {"dp", no_argument, NULL, 'd'},
210 '\0', NULL, NULL, ONE_DASH },
211 { {"entry", required_argument, NULL, 'e'},
212 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
213 { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
214 'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
215 { {"EB", no_argument, NULL, OPTION_EB},
216 '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
217 { {"EL", no_argument, NULL, OPTION_EL},
218 '\0', NULL, N_("Link little-endian objects"), ONE_DASH },
219 { {"auxiliary", required_argument, NULL, 'f'},
220 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
222 { {"filter", required_argument, NULL, 'F'},
223 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
225 { {NULL, no_argument, NULL, '\0'},
226 'g', NULL, N_("Ignored"), ONE_DASH },
227 { {"gpsize", required_argument, NULL, 'G'},
228 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
230 { {"soname", required_argument, NULL, OPTION_SONAME},
231 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
232 { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
233 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
235 { {"library", required_argument, NULL, 'l'},
236 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
237 { {"library-path", required_argument, NULL, 'L'},
238 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
240 { {"sysroot=<DIRECTORY>", required_argument, NULL, OPTION_SYSROOT},
241 '\0', NULL, N_("Override the default sysroot location"), TWO_DASHES },
242 { {NULL, required_argument, NULL, '\0'},
243 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH },
244 { {"print-map", no_argument, NULL, 'M'},
245 'M', NULL, N_("Print map file on standard output"), TWO_DASHES },
246 { {"nmagic", no_argument, NULL, 'n'},
247 'n', NULL, N_("Do not page align data"), TWO_DASHES },
248 { {"omagic", no_argument, NULL, 'N'},
249 'N', NULL, N_("Do not page align data, do not make text readonly"),
250 EXACTLY_TWO_DASHES },
251 { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC},
252 '\0', NULL, N_("Page align data, make text readonly"),
253 EXACTLY_TWO_DASHES },
254 { {"output", required_argument, NULL, 'o'},
255 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES },
256 { {NULL, required_argument, NULL, '\0'},
257 'O', NULL, N_("Optimize output file"), ONE_DASH },
258 { {"Qy", no_argument, NULL, OPTION_IGNORE},
259 '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
260 { {"emit-relocs", no_argument, NULL, 'q'},
261 'q', NULL, "Generate relocations in final output", TWO_DASHES },
262 { {"relocatable", no_argument, NULL, 'r'},
263 'r', NULL, N_("Generate relocatable output"), TWO_DASHES },
264 { {NULL, no_argument, NULL, '\0'},
265 'i', NULL, NULL, ONE_DASH },
266 { {"just-symbols", required_argument, NULL, 'R'},
267 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
269 { {"strip-all", no_argument, NULL, 's'},
270 's', NULL, N_("Strip all symbols"), TWO_DASHES },
271 { {"strip-debug", no_argument, NULL, 'S'},
272 'S', NULL, N_("Strip debugging symbols"), TWO_DASHES },
273 { {"strip-discarded", no_argument, NULL, OPTION_STRIP_DISCARDED},
274 '\0', NULL, N_("Strip symbols in discarded sections"), TWO_DASHES },
275 { {"no-strip-discarded", no_argument, NULL, OPTION_NO_STRIP_DISCARDED},
276 '\0', NULL, N_("Do not strip symbols in discarded sections"), TWO_DASHES },
277 { {"trace", no_argument, NULL, 't'},
278 't', NULL, N_("Trace file opens"), TWO_DASHES },
279 { {"script", required_argument, NULL, 'T'},
280 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
281 { {"undefined", required_argument, NULL, 'u'},
282 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
284 { {"unique", optional_argument, NULL, OPTION_UNIQUE},
285 '\0', N_("[=SECTION]"),
286 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
287 { {"Ur", no_argument, NULL, OPTION_UR},
288 '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
289 { {"version", no_argument, NULL, OPTION_VERSION},
290 'v', NULL, N_("Print version information"), TWO_DASHES },
291 { {NULL, no_argument, NULL, '\0'},
292 'V', NULL, N_("Print version and emulation information"), ONE_DASH },
293 { {"discard-all", no_argument, NULL, 'x'},
294 'x', NULL, N_("Discard all local symbols"), TWO_DASHES },
295 { {"discard-locals", no_argument, NULL, 'X'},
296 'X', NULL, N_("Discard temporary local symbols (default)"), TWO_DASHES },
297 { {"discard-none", no_argument, NULL, OPTION_DISCARD_NONE},
298 '\0', NULL, N_("Don't discard any local symbols"), TWO_DASHES },
299 { {"trace-symbol", required_argument, NULL, 'y'},
300 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
301 { {NULL, required_argument, NULL, '\0'},
302 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
304 { {"start-group", no_argument, NULL, '('},
305 '(', NULL, N_("Start a group"), TWO_DASHES },
306 { {"end-group", no_argument, NULL, ')'},
307 ')', NULL, N_("End a group"), TWO_DASHES },
308 { {"accept-unknown-input-arch", no_argument, NULL,
309 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH},
311 N_("Accept input files whose architecture cannot be determined"),
313 { {"no-accept-unknown-input-arch", no_argument, NULL,
314 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
315 '\0', NULL, N_("Reject input files whose architecture is unknown"),
317 { {"add-needed", no_argument, NULL, OPTION_ADD_NEEDED},
318 '\0', NULL, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
319 "\t\t\t\tfollowing dynamic libs"), TWO_DASHES },
320 { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_NEEDED},
321 '\0', NULL, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
322 "\t\t\t\tin following dynamic libs"), TWO_DASHES },
323 { {"as-needed", no_argument, NULL, OPTION_AS_NEEDED},
324 '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
326 { {"no-as-needed", no_argument, NULL, OPTION_NO_AS_NEEDED},
327 '\0', NULL, N_("Always set DT_NEEDED for following dynamic libs"),
329 { {"assert", required_argument, NULL, OPTION_ASSERT},
330 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
331 { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
332 '\0', NULL, N_("Link against shared libraries"), ONE_DASH },
333 { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
334 '\0', NULL, NULL, ONE_DASH },
335 { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
336 '\0', NULL, NULL, ONE_DASH },
337 { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
338 '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
339 { {"dn", no_argument, NULL, OPTION_NON_SHARED},
340 '\0', NULL, NULL, ONE_DASH },
341 { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
342 '\0', NULL, NULL, ONE_DASH },
343 { {"static", no_argument, NULL, OPTION_NON_SHARED},
344 '\0', NULL, NULL, ONE_DASH },
345 { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
346 '\0', NULL, N_("Bind global references locally"), ONE_DASH },
347 { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
348 '\0', NULL, N_("Check section addresses for overlaps (default)"),
350 { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
351 '\0', NULL, N_("Do not check section addresses for overlaps"),
353 { {"cref", no_argument, NULL, OPTION_CREF},
354 '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
355 { {"defsym", required_argument, NULL, OPTION_DEFSYM},
356 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
357 { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
358 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
360 { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
361 '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
362 { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
363 '\0', NULL, N_("Treat warnings as errors"),
365 { {"fini", required_argument, NULL, OPTION_FINI},
366 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
367 { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
368 '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
369 { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
370 '\0', NULL, N_("Remove unused sections (on some targets)"),
372 { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
373 '\0', NULL, N_("Don't remove unused sections (default)"),
375 { {"print-gc-sections", no_argument, NULL, OPTION_PRINT_GC_SECTIONS},
376 '\0', NULL, N_("List removed unused sections on stderr"),
378 { {"no-print-gc-sections", no_argument, NULL, OPTION_NO_PRINT_GC_SECTIONS},
379 '\0', NULL, N_("Do not list removed unused sections"),
381 { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
382 '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
384 { {"help", no_argument, NULL, OPTION_HELP},
385 '\0', NULL, N_("Print option help"), TWO_DASHES },
386 { {"init", required_argument, NULL, OPTION_INIT},
387 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
388 { {"Map", required_argument, NULL, OPTION_MAP},
389 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH },
390 { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
391 '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
392 { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
393 '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
394 { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
395 '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES },
396 { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
397 '\0', NULL, N_("Do not allow unresolved references in object files"),
399 { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED},
400 '\0', NULL, N_("Allow unresolved references in shared libaries"),
402 { {"no-allow-shlib-undefined", no_argument, NULL,
403 OPTION_NO_ALLOW_SHLIB_UNDEFINED},
404 '\0', NULL, N_("Do not allow unresolved references in shared libs"),
406 { {"allow-multiple-definition", no_argument, NULL,
407 OPTION_ALLOW_MULTIPLE_DEFINITION},
408 '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES },
409 { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
410 '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
411 { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER},
412 '\0', NULL, N_("Create default symbol version"), TWO_DASHES },
413 { {"default-imported-symver", no_argument, NULL,
414 OPTION_DEFAULT_IMPORTED_SYMVER},
415 '\0', NULL, N_("Create default symbol version for imported symbols"),
417 { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
418 '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
419 { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
420 '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
421 { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
422 '\0', NULL, N_("Create an output file even if errors occur"),
424 { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
425 '\0', NULL, NULL, NO_HELP },
426 { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB},
427 '\0', NULL, N_("Only use library directories specified on\n"
428 "\t\t\t\tthe command line"), ONE_DASH },
429 { {"oformat", required_argument, NULL, OPTION_OFORMAT},
430 '\0', N_("TARGET"), N_("Specify target of output file"),
431 EXACTLY_TWO_DASHES },
432 { {"qmagic", no_argument, NULL, OPTION_IGNORE},
433 '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
434 { {"reduce-memory-overheads", no_argument, NULL,
435 OPTION_REDUCE_MEMORY_OVERHEADS},
436 '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
438 { {"relax", no_argument, NULL, OPTION_RELAX},
439 '\0', NULL, N_("Relax branches on certain targets"), TWO_DASHES },
440 { {"retain-symbols-file", required_argument, NULL,
441 OPTION_RETAIN_SYMBOLS_FILE},
442 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
443 { {"rpath", required_argument, NULL, OPTION_RPATH},
444 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH },
445 { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
446 '\0', N_("PATH"), N_("Set link time shared library search path"),
448 { {"shared", no_argument, NULL, OPTION_SHARED},
449 '\0', NULL, N_("Create a shared library"), ONE_DASH },
450 { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */
451 '\0', NULL, NULL, ONE_DASH },
452 { {"pie", no_argument, NULL, OPTION_PIE},
453 '\0', NULL, N_("Create a position independent executable"), ONE_DASH },
454 { {"pic-executable", no_argument, NULL, OPTION_PIE},
455 '\0', NULL, NULL, TWO_DASHES },
456 { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
457 '\0', NULL, N_("Sort common symbols by size"), TWO_DASHES },
458 { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
459 '\0', NULL, NULL, NO_HELP },
460 { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
461 '\0', N_("name|alignment"),
462 N_("Sort sections by name or maximum alignment"), TWO_DASHES },
463 { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
464 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
466 { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE},
467 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
469 { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC},
470 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
472 { {"stats", no_argument, NULL, OPTION_STATS},
473 '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
474 { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
475 '\0', NULL, N_("Display target specific options"), TWO_DASHES },
476 { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
477 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
478 { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
479 '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
480 { {"section-start", required_argument, NULL, OPTION_SECTION_START},
481 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
483 { {"Tbss", required_argument, NULL, OPTION_TBSS},
484 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
485 { {"Tdata", required_argument, NULL, OPTION_TDATA},
486 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
487 { {"Ttext", required_argument, NULL, OPTION_TTEXT},
488 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
489 { {"unresolved-symbols=<method>", required_argument, NULL,
490 OPTION_UNRESOLVED_SYMBOLS},
491 '\0', NULL, N_("How to handle unresolved symbols. <method> is:\n"
492 "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
493 "\t\t\t\tignore-in-shared-libs"), TWO_DASHES },
494 { {"verbose", no_argument, NULL, OPTION_VERBOSE},
495 '\0', NULL, N_("Output lots of information during link"), TWO_DASHES },
496 { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */
497 '\0', NULL, NULL, NO_HELP },
498 { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
499 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
500 { {"version-exports-section", required_argument, NULL,
501 OPTION_VERSION_EXPORTS_SECTION },
502 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
503 "\t\t\t\tSYMBOL as the version."), TWO_DASHES },
504 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
505 '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
506 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
507 '\0', NULL, N_("Warn if global constructors/destructors are seen"),
509 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
510 '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
511 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
512 '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
513 { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
514 '\0', NULL, N_("Warn if start of section changes due to alignment"),
516 { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_SHARED_TEXTREL},
517 '\0', NULL, N_("Warn if shared object has DT_TEXTREL"),
519 { {"warn-unresolved-symbols", no_argument, NULL,
520 OPTION_WARN_UNRESOLVED_SYMBOLS},
521 '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
522 { {"error-unresolved-symbols", no_argument, NULL,
523 OPTION_ERROR_UNRESOLVED_SYMBOLS},
524 '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES },
525 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
526 '\0', NULL, N_("Include all objects from following archives"),
528 { {"wrap", required_argument, NULL, OPTION_WRAP},
529 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
532 #define OPTION_COUNT ARRAY_SIZE (ld_options)
535 parse_args (unsigned argc, char **argv)
540 char *default_dirlist = NULL;
542 struct option *longopts;
543 struct option *really_longopts;
545 enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
547 shortopts = xmalloc (OPTION_COUNT * 3 + 2);
548 longopts = xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
549 really_longopts = xmalloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
551 /* Starting the short option string with '-' is for programs that
552 expect options and other ARGV-elements in any order and that care about
553 the ordering of the two. We describe each non-option ARGV-element
554 as if it were the argument of an option with character code 1. */
559 for (i = 0; i < OPTION_COUNT; i++)
561 if (ld_options[i].shortopt != '\0')
563 shortopts[is] = ld_options[i].shortopt;
565 if (ld_options[i].opt.has_arg == required_argument
566 || ld_options[i].opt.has_arg == optional_argument)
570 if (ld_options[i].opt.has_arg == optional_argument)
577 if (ld_options[i].opt.name != NULL)
579 if (ld_options[i].control == EXACTLY_TWO_DASHES)
581 really_longopts[irl] = ld_options[i].opt;
586 longopts[il] = ld_options[i].opt;
591 shortopts[is] = '\0';
592 longopts[il].name = NULL;
593 really_longopts[irl].name = NULL;
595 ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
597 /* The -G option is ambiguous on different platforms. Sometimes it
598 specifies the largest data size to put into the small data
599 section. Sometimes it is equivalent to --shared. Unfortunately,
600 the first form takes an argument, while the second does not.
602 We need to permit the --shared form because on some platforms,
603 such as Solaris, gcc -shared will pass -G to the linker.
605 To permit either usage, we look through the argument list. If we
606 find -G not followed by a number, we change it into --shared.
607 This will work for most normal cases. */
608 for (i = 1; i < argc; i++)
609 if (strcmp (argv[i], "-G") == 0
611 || ! ISDIGIT (argv[i + 1][0])))
612 argv[i] = (char *) "--shared";
614 /* Because we permit long options to start with a single dash, and
615 we have a --library option, and the -l option is conventionally
616 used with an immediately following argument, we can have bad
617 results if somebody tries to use -l with a library whose name
618 happens to start with "ibrary", as in -li. We avoid problems by
619 simply turning -l into --library. This means that users will
620 have to use two dashes in order to use --library, which is OK
621 since that's how it is documented.
623 FIXME: It's possible that this problem can arise for other short
624 options as well, although the user does always have the recourse
625 of adding a space between the option and the argument. */
626 for (i = 1; i < argc; i++)
628 if (argv[i][0] == '-'
630 && argv[i][2] != '\0')
634 n = xmalloc (strlen (argv[i]) + 20);
635 sprintf (n, "--library=%s", argv[i] + 2);
646 /* Using last_optind lets us avoid calling ldemul_parse_args
647 multiple times on a single option, which would lead to
648 confusion in the internal static variables maintained by
649 getopt. This could otherwise happen for an argument like
650 -nx, in which the -n is parsed as a single option, and we
651 loop around to pick up the -x. */
652 if (optind != last_optind)
653 if (ldemul_parse_args (argc, argv))
656 /* getopt_long_only is like getopt_long, but '-' as well as '--'
657 can indicate a long option. */
659 last_optind = optind;
660 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
663 optind = last_optind;
664 optc = getopt_long (argc, argv, "-", really_longopts, &longind);
667 if (ldemul_handle_option (optc))
676 einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
678 einfo (_("%P%F: use the --help option for usage information\n"));
680 case 1: /* File name. */
681 lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL);
687 /* For HP/UX compatibility. Actually -a shared should mean
688 ``use only shared libraries'' but, then, we don't
689 currently support shared libraries on HP/UX anyhow. */
690 if (strcmp (optarg, "archive") == 0)
691 config.dynamic_link = FALSE;
692 else if (strcmp (optarg, "shared") == 0
693 || strcmp (optarg, "default") == 0)
694 config.dynamic_link = TRUE;
696 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg);
699 /* FIXME: We just ignore these, but we should handle them. */
700 if (strcmp (optarg, "definitions") == 0)
702 else if (strcmp (optarg, "nodefinitions") == 0)
704 else if (strcmp (optarg, "nosymbolic") == 0)
706 else if (strcmp (optarg, "pure-text") == 0)
709 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg);
712 ldfile_add_arch (optarg);
715 lang_add_target (optarg);
718 ldfile_open_command_file (optarg);
719 parser_input = input_mri_script;
722 case OPTION_CALL_SHARED:
723 config.dynamic_link = TRUE;
725 case OPTION_NON_SHARED:
726 config.dynamic_link = FALSE;
729 command_line.cref = TRUE;
730 link_info.notice_all = TRUE;
733 command_line.force_common_definition = TRUE;
737 lex_redirect (optarg);
738 parser_input = input_defsym;
744 case OPTION_DEMANGLE:
748 enum demangling_styles style;
750 style = cplus_demangle_name_to_style (optarg);
751 if (style == unknown_demangling)
752 einfo (_("%F%P: unknown demangling style `%s'"),
755 cplus_demangle_set_style (style);
758 case 'I': /* Used on Solaris. */
759 case OPTION_DYNAMIC_LINKER:
760 command_line.interpreter = optarg;
763 /* Already handled in ldmain.c. */
766 command_line.endian = ENDIAN_BIG;
769 command_line.endian = ENDIAN_LITTLE;
771 case OPTION_EMBEDDED_RELOCS:
772 command_line.embedded_relocs = TRUE;
774 case OPTION_EXPORT_DYNAMIC:
775 case 'E': /* HP/UX compatibility. */
776 link_info.export_dynamic = TRUE;
779 lang_add_entry (optarg, TRUE);
782 if (command_line.auxiliary_filters == NULL)
784 command_line.auxiliary_filters = xmalloc (2 * sizeof (char *));
785 command_line.auxiliary_filters[0] = optarg;
786 command_line.auxiliary_filters[1] = NULL;
794 for (p = command_line.auxiliary_filters; *p != NULL; p++)
796 command_line.auxiliary_filters
797 = xrealloc (command_line.auxiliary_filters,
798 (c + 2) * sizeof (char *));
799 command_line.auxiliary_filters[c] = optarg;
800 command_line.auxiliary_filters[c + 1] = NULL;
804 command_line.filter_shlib = optarg;
806 case OPTION_FORCE_EXE_SUFFIX:
807 command_line.force_exe_suffix = TRUE;
812 g_switch_value = strtoul (optarg, &end, 0);
814 einfo (_("%P%F: invalid number `%s'\n"), optarg);
820 case OPTION_GC_SECTIONS:
821 link_info.gc_sections = TRUE;
823 case OPTION_PRINT_GC_SECTIONS:
824 link_info.print_gc_sections = TRUE;
831 ldfile_add_library_path (optarg, TRUE);
834 lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL);
837 config.map_filename = "-";
840 /* Ignore. Was handled in a pre-parse. */
843 config.map_filename = optarg;
846 config.text_read_only = FALSE;
847 config.magic_demand_paged = FALSE;
848 config.dynamic_link = FALSE;
850 case OPTION_NO_OMAGIC:
851 config.text_read_only = TRUE;
852 config.magic_demand_paged = TRUE;
853 /* NB/ Does not set dynamic_link to TRUE.
854 Use --call-shared or -Bdynamic for this. */
857 config.magic_demand_paged = FALSE;
858 config.dynamic_link = FALSE;
860 case OPTION_NO_DEFINE_COMMON:
861 command_line.inhibit_common_definition = TRUE;
863 case OPTION_NO_DEMANGLE:
866 case OPTION_NO_GC_SECTIONS:
867 link_info.gc_sections = FALSE;
869 case OPTION_NO_PRINT_GC_SECTIONS:
870 link_info.print_gc_sections = FALSE;
872 case OPTION_NO_KEEP_MEMORY:
873 link_info.keep_memory = FALSE;
875 case OPTION_NO_UNDEFINED:
876 link_info.unresolved_syms_in_objects
877 = how_to_report_unresolved_symbols;
879 case OPTION_ALLOW_SHLIB_UNDEFINED:
880 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
882 case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
883 link_info.unresolved_syms_in_shared_libs
884 = how_to_report_unresolved_symbols;
886 case OPTION_UNRESOLVED_SYMBOLS:
887 if (strcmp (optarg, "ignore-all") == 0)
889 link_info.unresolved_syms_in_objects = RM_IGNORE;
890 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
892 else if (strcmp (optarg, "report-all") == 0)
894 link_info.unresolved_syms_in_objects
895 = how_to_report_unresolved_symbols;
896 link_info.unresolved_syms_in_shared_libs
897 = how_to_report_unresolved_symbols;
899 else if (strcmp (optarg, "ignore-in-object-files") == 0)
901 link_info.unresolved_syms_in_objects = RM_IGNORE;
902 link_info.unresolved_syms_in_shared_libs
903 = how_to_report_unresolved_symbols;
905 else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
907 link_info.unresolved_syms_in_objects
908 = how_to_report_unresolved_symbols;
909 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
912 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg);
914 case OPTION_WARN_UNRESOLVED_SYMBOLS:
915 how_to_report_unresolved_symbols = RM_GENERATE_WARNING;
916 if (link_info.unresolved_syms_in_objects == RM_GENERATE_ERROR)
917 link_info.unresolved_syms_in_objects = RM_GENERATE_WARNING;
918 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
919 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_WARNING;
922 case OPTION_ERROR_UNRESOLVED_SYMBOLS:
923 how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
924 if (link_info.unresolved_syms_in_objects == RM_GENERATE_WARNING)
925 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
926 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_WARNING)
927 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
929 case OPTION_ALLOW_MULTIPLE_DEFINITION:
930 link_info.allow_multiple_definition = TRUE;
932 case OPTION_NO_UNDEFINED_VERSION:
933 link_info.allow_undefined_version = FALSE;
935 case OPTION_DEFAULT_SYMVER:
936 link_info.create_default_symver = TRUE;
938 case OPTION_DEFAULT_IMPORTED_SYMVER:
939 link_info.default_imported_symver = TRUE;
941 case OPTION_NO_WARN_MISMATCH:
942 command_line.warn_mismatch = FALSE;
944 case OPTION_NOINHIBIT_EXEC:
945 force_make_executable = TRUE;
947 case OPTION_NOSTDLIB:
948 config.only_cmd_line_lib_dirs = TRUE;
950 case OPTION_NO_WHOLE_ARCHIVE:
951 whole_archive = FALSE;
954 /* FIXME "-O<non-digits> <value>" used to set the address of
955 section <non-digits>. Was this for compatibility with
956 something, or can we create a new option to do that
957 (with a syntax similar to -defsym)?
958 getopt can't handle two args to an option without kludges. */
960 /* Enable optimizations of output files. */
961 link_info.optimize = strtoul (optarg, NULL, 0) ? TRUE : FALSE;
964 lang_add_output (optarg, 0);
967 lang_add_output_format (optarg, NULL, NULL, 0);
970 link_info.emitrelocations = TRUE;
974 if (optind == last_optind)
975 /* This can happen if the user put "-rpath,a" on the command
976 line. (Or something similar. The comma is important).
977 Getopt becomes confused and thinks that this is a -r option
978 but it cannot parse the text after the -r so it refuses to
979 increment the optind counter. Detect this case and issue
980 an error message here. We cannot just make this a warning,
981 increment optind, and continue because getopt is too confused
982 and will seg-fault the next time around. */
983 einfo(_("%P%F: bad -rpath option\n"));
985 link_info.relocatable = TRUE;
986 config.build_constructors = FALSE;
987 config.magic_demand_paged = FALSE;
988 config.text_read_only = FALSE;
989 config.dynamic_link = FALSE;
992 /* The GNU linker traditionally uses -R to mean to include
993 only the symbols from a file. The Solaris linker uses -R
994 to set the path used by the runtime linker to find
995 libraries. This is the GNU linker -rpath argument. We
996 try to support both simultaneously by checking the file
997 named. If it is a directory, rather than a regular file,
998 we assume -rpath was meant. */
1002 if (stat (optarg, &s) >= 0
1003 && ! S_ISDIR (s.st_mode))
1005 lang_add_input_file (optarg,
1006 lang_input_file_is_symbols_only_enum,
1013 if (command_line.rpath == NULL)
1014 command_line.rpath = xstrdup (optarg);
1017 size_t rpath_len = strlen (command_line.rpath);
1018 size_t optarg_len = strlen (optarg);
1020 char *cp = command_line.rpath;
1022 /* First see whether OPTARG is already in the path. */
1027 while (optarg[idx] != '\0' && optarg[idx] == cp[idx])
1029 if (optarg[idx] == '\0'
1030 && (cp[idx] == '\0' || cp[idx] == ':'))
1034 /* Not yet found. */
1035 cp = strchr (cp, ':');
1043 buf = xmalloc (rpath_len + optarg_len + 2);
1044 sprintf (buf, "%s:%s", command_line.rpath, optarg);
1045 free (command_line.rpath);
1046 command_line.rpath = buf;
1050 case OPTION_RPATH_LINK:
1051 if (command_line.rpath_link == NULL)
1052 command_line.rpath_link = xstrdup (optarg);
1057 buf = xmalloc (strlen (command_line.rpath_link)
1060 sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
1061 free (command_line.rpath_link);
1062 command_line.rpath_link = buf;
1066 command_line.relax = TRUE;
1068 case OPTION_RETAIN_SYMBOLS_FILE:
1069 add_keepsyms_file (optarg);
1072 link_info.strip = strip_debugger;
1075 link_info.strip = strip_all;
1077 case OPTION_STRIP_DISCARDED:
1078 link_info.strip_discarded = TRUE;
1080 case OPTION_NO_STRIP_DISCARDED:
1081 link_info.strip_discarded = FALSE;
1084 if (config.has_shared)
1086 link_info.shared = TRUE;
1087 /* When creating a shared library, the default
1088 behaviour is to ignore any unresolved references. */
1089 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1090 link_info.unresolved_syms_in_objects = RM_IGNORE;
1091 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1092 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1095 einfo (_("%P%F: -shared not supported\n"));
1098 if (config.has_shared)
1100 link_info.shared = TRUE;
1101 link_info.pie = TRUE;
1104 einfo (_("%P%F: -pie not supported\n"));
1106 case 'h': /* Used on Solaris. */
1108 command_line.soname = optarg;
1110 case OPTION_SORT_COMMON:
1111 config.sort_common = TRUE;
1113 case OPTION_SORT_SECTION:
1114 if (strcmp (optarg, N_("name")) == 0)
1115 sort_section = by_name;
1116 else if (strcmp (optarg, N_("alignment")) == 0)
1117 sort_section = by_alignment;
1119 einfo (_("%P%F: invalid section sorting option: %s\n"),
1123 config.stats = TRUE;
1125 case OPTION_SYMBOLIC:
1126 link_info.symbolic = TRUE;
1132 ldfile_open_command_file (optarg);
1133 parser_input = input_script;
1136 case OPTION_SECTION_START:
1142 /* Check for <something>=<somthing>... */
1143 optarg2 = strchr (optarg, '=');
1144 if (optarg2 == NULL)
1145 einfo (_("%P%F: invalid argument to option"
1146 " \"--section-start\"\n"));
1150 /* So far so good. Are all the args present? */
1151 if ((*optarg == '\0') || (*optarg2 == '\0'))
1152 einfo (_("%P%F: missing argument(s) to option"
1153 " \"--section-start\"\n"));
1155 /* We must copy the section name as set_section_start
1156 doesn't do it for us. */
1157 len = optarg2 - optarg;
1158 sec_name = xmalloc (len);
1159 memcpy (sec_name, optarg, len - 1);
1160 sec_name[len - 1] = 0;
1162 /* Then set it... */
1163 set_section_start (sec_name, optarg2);
1166 case OPTION_TARGET_HELP:
1167 /* Mention any target specific options. */
1168 ldemul_list_emulation_options (stdout);
1171 set_segment_start (".bss", optarg);
1174 set_segment_start (".data", optarg);
1177 set_segment_start (".text", optarg);
1179 case OPTION_TRADITIONAL_FORMAT:
1180 link_info.traditional_format = TRUE;
1182 case OPTION_TASK_LINK:
1183 link_info.task_link = TRUE;
1184 /* Fall through - do an implied -r option. */
1186 link_info.relocatable = TRUE;
1187 config.build_constructors = TRUE;
1188 config.magic_demand_paged = FALSE;
1189 config.text_read_only = FALSE;
1190 config.dynamic_link = FALSE;
1193 ldlang_add_undef (optarg);
1197 lang_add_unique (optarg);
1199 config.unique_orphan_sections = TRUE;
1201 case OPTION_VERBOSE:
1203 version_printed = TRUE;
1204 trace_file_tries = TRUE;
1205 overflow_cutoff_limit = -2;
1209 version_printed = TRUE;
1213 version_printed = TRUE;
1215 case OPTION_VERSION:
1219 case OPTION_VERSION_SCRIPT:
1220 /* This option indicates a small script that only specifies
1221 version information. Read it, but don't assume that
1222 we've seen a linker script. */
1224 FILE *hold_script_handle;
1226 hold_script_handle = saved_script_handle;
1227 ldfile_open_command_file (optarg);
1228 saved_script_handle = hold_script_handle;
1229 parser_input = input_version_script;
1233 case OPTION_VERSION_EXPORTS_SECTION:
1234 /* This option records a version symbol to be applied to the
1235 symbols listed for export to be found in the object files
1236 .exports sections. */
1237 command_line.version_exports_section = optarg;
1239 case OPTION_WARN_COMMON:
1240 config.warn_common = TRUE;
1242 case OPTION_WARN_CONSTRUCTORS:
1243 config.warn_constructors = TRUE;
1245 case OPTION_WARN_FATAL:
1246 config.fatal_warnings = TRUE;
1248 case OPTION_WARN_MULTIPLE_GP:
1249 config.warn_multiple_gp = TRUE;
1251 case OPTION_WARN_ONCE:
1252 config.warn_once = TRUE;
1254 case OPTION_WARN_SECTION_ALIGN:
1255 config.warn_section_align = TRUE;
1257 case OPTION_WARN_SHARED_TEXTREL:
1258 link_info.warn_shared_textrel = TRUE;
1260 case OPTION_WHOLE_ARCHIVE:
1261 whole_archive = TRUE;
1263 case OPTION_ADD_NEEDED:
1266 case OPTION_NO_ADD_NEEDED:
1269 case OPTION_AS_NEEDED:
1272 case OPTION_NO_AS_NEEDED:
1278 case OPTION_DISCARD_NONE:
1279 link_info.discard = discard_none;
1282 link_info.discard = discard_l;
1285 link_info.discard = discard_all;
1288 if (strncmp (optarg, "P,", 2) == 0)
1290 if (default_dirlist != NULL)
1291 free (default_dirlist);
1292 default_dirlist = xstrdup (optarg);
1297 case OPTION_SPARE_DYNAMIC_TAGS:
1298 link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0);
1300 case OPTION_SPLIT_BY_RELOC:
1302 config.split_by_reloc = strtoul (optarg, NULL, 0);
1304 config.split_by_reloc = 32768;
1306 case OPTION_SPLIT_BY_FILE:
1308 config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
1310 config.split_by_file = 1;
1312 case OPTION_CHECK_SECTIONS:
1313 command_line.check_section_addresses = TRUE;
1315 case OPTION_NO_CHECK_SECTIONS:
1316 command_line.check_section_addresses = FALSE;
1318 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
1319 command_line.accept_unknown_input_arch = TRUE;
1321 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
1322 command_line.accept_unknown_input_arch = FALSE;
1326 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1328 lang_enter_group ();
1333 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1335 lang_leave_group ();
1340 link_info.init_function = optarg;
1344 link_info.fini_function = optarg;
1347 case OPTION_REDUCE_MEMORY_OVERHEADS:
1348 command_line.reduce_memory_overheads = TRUE;
1349 if (config.hash_table_size == 0)
1350 config.hash_table_size = 1021;
1353 case OPTION_HASH_SIZE:
1355 bfd_size_type new_size;
1357 new_size = strtoul (optarg, NULL, 0);
1359 config.hash_table_size = new_size;
1361 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1368 lang_leave_group ();
1370 if (default_dirlist != NULL)
1372 set_default_dirlist (default_dirlist);
1373 free (default_dirlist);
1376 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1377 /* FIXME: Should we allow emulations a chance to set this ? */
1378 link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
1380 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1381 /* FIXME: Should we allow emulations a chance to set this ? */
1382 link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
1385 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1386 library search path. */
1389 set_default_dirlist (char *dirlist_ptr)
1395 p = strchr (dirlist_ptr, PATH_SEPARATOR);
1398 if (*dirlist_ptr != '\0')
1399 ldfile_add_library_path (dirlist_ptr, TRUE);
1402 dirlist_ptr = p + 1;
1407 set_section_start (char *sect, char *valstr)
1410 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1412 einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
1413 lang_section_start (sect, exp_intop (val), NULL);
1417 set_segment_start (const char *section, char *valstr)
1423 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1425 einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
1426 /* If we already have an entry for this segment, update the existing
1429 for (seg = segments; seg; seg = seg->next)
1430 if (strcmp (seg->name, name) == 0)
1435 /* There was no existing value so we must create a new segment
1437 seg = stat_alloc (sizeof (*seg));
1441 /* Add it to the linked list of segments. */
1442 seg->next = segments;
1444 /* Historically, -Ttext and friends set the base address of a
1445 particular section. For backwards compatibility, we still do
1446 that. If a SEGMENT_START directive is seen, the section address
1447 assignment will be disabled. */
1448 lang_section_start (section, exp_intop (val), seg);
1452 /* Print help messages for the options. */
1458 const char **targets, **pp;
1461 printf (_("Usage: %s [options] file...\n"), program_name);
1463 printf (_("Options:\n"));
1464 for (i = 0; i < OPTION_COUNT; i++)
1466 if (ld_options[i].doc != NULL)
1479 if (ld_options[j].shortopt != '\0'
1480 && ld_options[j].control != NO_HELP)
1482 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
1483 len += (comma ? 2 : 0) + 2;
1484 if (ld_options[j].arg != NULL)
1486 if (ld_options[j].opt.has_arg != optional_argument)
1491 printf ("%s", _(ld_options[j].arg));
1492 len += strlen (_(ld_options[j].arg));
1498 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1503 if (ld_options[j].opt.name != NULL
1504 && ld_options[j].control != NO_HELP)
1507 (ld_options[j].control == TWO_DASHES
1508 || ld_options[j].control == EXACTLY_TWO_DASHES);
1512 two_dashes ? "-" : "",
1513 ld_options[j].opt.name);
1514 len += ((comma ? 2 : 0)
1516 + (two_dashes ? 1 : 0)
1517 + strlen (ld_options[j].opt.name));
1518 if (ld_options[j].arg != NULL)
1520 printf (" %s", _(ld_options[j].arg));
1521 len += 1 + strlen (_(ld_options[j].arg));
1527 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1535 for (; len < 30; len++)
1538 printf ("%s\n", _(ld_options[i].doc));
1541 printf (_(" @FILE"));
1542 for (len = strlen (" @FILE"); len < 30; len++)
1544 printf (_("Read options from FILE\n"));
1546 /* Note: Various tools (such as libtool) depend upon the
1547 format of the listings below - do not change them. */
1548 /* xgettext:c-format */
1549 printf (_("%s: supported targets:"), program_name);
1550 targets = bfd_target_list ();
1551 for (pp = targets; *pp != NULL; pp++)
1552 printf (" %s", *pp);
1556 /* xgettext:c-format */
1557 printf (_("%s: supported emulations: "), program_name);
1558 ldemul_list_emulations (stdout);
1561 /* xgettext:c-format */
1562 printf (_("%s: emulation specific options:\n"), program_name);
1563 ldemul_list_emulation_options (stdout);
1566 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);