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
,
101 OPTION_TRADITIONAL_FORMAT
,
105 OPTION_VERSION_SCRIPT
,
106 OPTION_VERSION_EXPORTS_SECTION
,
108 OPTION_WARN_CONSTRUCTORS
,
110 OPTION_WARN_MULTIPLE_GP
,
112 OPTION_WARN_SECTION_ALIGN
,
113 OPTION_SPLIT_BY_RELOC
,
114 OPTION_SPLIT_BY_FILE
,
115 OPTION_WHOLE_ARCHIVE
,
117 OPTION_NO_ADD_NEEDED
,
121 OPTION_FORCE_EXE_SUFFIX
,
123 OPTION_NO_GC_SECTIONS
,
125 OPTION_CHECK_SECTIONS
,
126 OPTION_NO_CHECK_SECTIONS
,
130 OPTION_SECTION_START
,
133 OPTION_ALLOW_SHLIB_UNDEFINED
,
134 OPTION_NO_ALLOW_SHLIB_UNDEFINED
,
135 OPTION_ALLOW_MULTIPLE_DEFINITION
,
136 OPTION_NO_UNDEFINED_VERSION
,
138 OPTION_SPARE_DYNAMIC_TAGS
,
139 OPTION_NO_DEFINE_COMMON
,
142 OPTION_STRIP_DISCARDED
,
143 OPTION_NO_STRIP_DISCARDED
,
144 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
,
145 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
,
147 OPTION_UNRESOLVED_SYMBOLS
,
148 OPTION_WARN_UNRESOLVED_SYMBOLS
,
149 OPTION_ERROR_UNRESOLVED_SYMBOLS
,
150 OPTION_WARN_SHARED_TEXTREL
,
151 OPTION_REDUCE_MEMORY_OVERHEADS
154 /* The long options. This structure is used for both the option
155 parsing and the help text. */
159 /* The long option information. */
161 /* The short option with the same meaning ('\0' if none). */
163 /* The name of the argument (NULL if none). */
165 /* The documentation string. If this is NULL, this is a synonym for
166 the previous option. */
169 /* Use one dash before long option name. */
171 /* Use two dashes before long option name. */
173 /* Only accept two dashes before the long option name.
174 This is an overloading of the use of this enum, since originally it
175 was only intended to tell the --help display function how to display
176 the long option name. This feature was added in order to resolve
177 the confusion about the -omagic command line switch. Is it setting
178 the output file name to "magic" or is it setting the NMAGIC flag on
179 the output ? It has been decided that it is setting the output file
180 name, and that if you want to set the NMAGIC flag you should use -N
183 /* Don't mention this option in --help output. */
188 static const struct ld_option ld_options
[] =
190 { {NULL
, required_argument
, NULL
, '\0'},
191 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
193 { {"architecture", required_argument
, NULL
, 'A'},
194 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
195 { {"format", required_argument
, NULL
, 'b'},
196 'b', N_("TARGET"), N_("Specify target for following input files"),
198 { {"mri-script", required_argument
, NULL
, 'c'},
199 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
200 { {"dc", no_argument
, NULL
, 'd'},
201 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
202 { {"dp", no_argument
, NULL
, 'd'},
203 '\0', NULL
, NULL
, ONE_DASH
},
204 { {"entry", required_argument
, NULL
, 'e'},
205 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
206 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
207 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
208 { {"EB", no_argument
, NULL
, OPTION_EB
},
209 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
210 { {"EL", no_argument
, NULL
, OPTION_EL
},
211 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
212 { {"auxiliary", required_argument
, NULL
, 'f'},
213 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
215 { {"filter", required_argument
, NULL
, 'F'},
216 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
218 { {NULL
, no_argument
, NULL
, '\0'},
219 'g', NULL
, N_("Ignored"), ONE_DASH
},
220 { {"gpsize", required_argument
, NULL
, 'G'},
221 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
223 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
224 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
225 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
226 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
228 { {"library", required_argument
, NULL
, 'l'},
229 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
230 { {"library-path", required_argument
, NULL
, 'L'},
231 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
233 { {NULL
, required_argument
, NULL
, '\0'},
234 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
235 { {"print-map", no_argument
, NULL
, 'M'},
236 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
237 { {"nmagic", no_argument
, NULL
, 'n'},
238 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
239 { {"omagic", no_argument
, NULL
, 'N'},
240 'N', NULL
, N_("Do not page align data, do not make text readonly"),
241 EXACTLY_TWO_DASHES
},
242 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
243 '\0', NULL
, N_("Page align data, make text readonly"),
244 EXACTLY_TWO_DASHES
},
245 { {"output", required_argument
, NULL
, 'o'},
246 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
247 { {NULL
, required_argument
, NULL
, '\0'},
248 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
249 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
250 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
251 { {"emit-relocs", no_argument
, NULL
, 'q'},
252 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
253 { {"relocatable", no_argument
, NULL
, 'r'},
254 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
255 { {NULL
, no_argument
, NULL
, '\0'},
256 'i', NULL
, NULL
, ONE_DASH
},
257 { {"just-symbols", required_argument
, NULL
, 'R'},
258 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
260 { {"strip-all", no_argument
, NULL
, 's'},
261 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
262 { {"strip-debug", no_argument
, NULL
, 'S'},
263 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
264 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
265 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
266 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
267 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
268 { {"trace", no_argument
, NULL
, 't'},
269 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
270 { {"script", required_argument
, NULL
, 'T'},
271 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
272 { {"undefined", required_argument
, NULL
, 'u'},
273 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
275 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
276 '\0', N_("[=SECTION]"),
277 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
278 { {"Ur", no_argument
, NULL
, OPTION_UR
},
279 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
280 { {"version", no_argument
, NULL
, OPTION_VERSION
},
281 'v', NULL
, N_("Print version information"), TWO_DASHES
},
282 { {NULL
, no_argument
, NULL
, '\0'},
283 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
284 { {"discard-all", no_argument
, NULL
, 'x'},
285 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
286 { {"discard-locals", no_argument
, NULL
, 'X'},
287 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
288 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
289 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
290 { {"trace-symbol", required_argument
, NULL
, 'y'},
291 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
292 { {NULL
, required_argument
, NULL
, '\0'},
293 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
295 { {"start-group", no_argument
, NULL
, '('},
296 '(', NULL
, N_("Start a group"), TWO_DASHES
},
297 { {"end-group", no_argument
, NULL
, ')'},
298 ')', NULL
, N_("End a group"), TWO_DASHES
},
299 { {"accept-unknown-input-arch", no_argument
, NULL
,
300 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
302 N_("Accept input files whose architecture cannot be determined"),
304 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
305 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
306 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
308 { {"add-needed", no_argument
, NULL
, OPTION_ADD_NEEDED
},
309 '\0', NULL
, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
310 "\t\t\t\tfollowing dynamic libs"), TWO_DASHES
},
311 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_NEEDED
},
312 '\0', NULL
, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
313 "\t\t\t\tin following dynamic libs"), TWO_DASHES
},
314 { {"as-needed", no_argument
, NULL
, OPTION_AS_NEEDED
},
315 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
317 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_AS_NEEDED
},
318 '\0', NULL
, N_("Always set DT_NEEDED for following dynamic libs"),
320 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
321 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
322 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
323 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
324 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
325 '\0', NULL
, NULL
, ONE_DASH
},
326 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
327 '\0', NULL
, NULL
, ONE_DASH
},
328 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
329 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
330 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
331 '\0', NULL
, NULL
, ONE_DASH
},
332 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
333 '\0', NULL
, NULL
, ONE_DASH
},
334 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
335 '\0', NULL
, NULL
, ONE_DASH
},
336 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
337 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
338 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
339 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
341 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
342 '\0', NULL
, N_("Do not check section addresses for overlaps"),
344 { {"cref", no_argument
, NULL
, OPTION_CREF
},
345 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
346 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
347 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
348 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
349 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
351 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
352 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
353 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
354 '\0', NULL
, N_("Treat warnings as errors"),
356 { {"fini", required_argument
, NULL
, OPTION_FINI
},
357 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
358 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
359 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
360 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
361 '\0', NULL
, N_("Remove unused sections (on some targets)"),
363 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
364 '\0', NULL
, N_("Don't remove unused sections (default)"),
366 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
367 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
369 { {"help", no_argument
, NULL
, OPTION_HELP
},
370 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
371 { {"init", required_argument
, NULL
, OPTION_INIT
},
372 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
373 { {"Map", required_argument
, NULL
, OPTION_MAP
},
374 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
375 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
376 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
377 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
378 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
379 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
380 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
381 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
382 '\0', NULL
, N_("Do not allow unresolved references in object files"),
384 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
385 '\0', NULL
, N_("Allow unresolved references in shared libaries"),
387 { {"no-allow-shlib-undefined", no_argument
, NULL
,
388 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
389 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
391 { {"allow-multiple-definition", no_argument
, NULL
,
392 OPTION_ALLOW_MULTIPLE_DEFINITION
},
393 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
394 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
395 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
396 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
397 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
398 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
399 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
400 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
401 '\0', NULL
, N_("Create an output file even if errors occur"),
403 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
404 '\0', NULL
, NULL
, NO_HELP
},
405 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
406 '\0', NULL
, N_("Only use library directories specified on\n"
407 "\t\t\t\tthe command line"), ONE_DASH
},
408 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
409 '\0', N_("TARGET"), N_("Specify target of output file"),
410 EXACTLY_TWO_DASHES
},
411 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
412 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
413 { {"reduce-memory-overheads", no_argument
, NULL
,
414 OPTION_REDUCE_MEMORY_OVERHEADS
},
415 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
417 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
418 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
419 { {"retain-symbols-file", required_argument
, NULL
,
420 OPTION_RETAIN_SYMBOLS_FILE
},
421 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
422 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
423 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
424 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
425 '\0', N_("PATH"), N_("Set link time shared library search path"),
427 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
428 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
429 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
430 '\0', NULL
, NULL
, ONE_DASH
},
431 { {"pie", no_argument
, NULL
, OPTION_PIE
},
432 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
433 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
434 '\0', NULL
, NULL
, TWO_DASHES
},
435 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
436 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
437 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
438 '\0', NULL
, NULL
, NO_HELP
},
439 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
440 '\0', N_("name|alignment"),
441 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
442 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
443 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
445 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
446 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
448 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
449 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
451 { {"stats", no_argument
, NULL
, OPTION_STATS
},
452 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
453 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
454 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
455 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
456 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
457 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
458 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
459 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
460 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
462 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
463 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
464 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
465 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
466 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
467 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
468 { {"unresolved-symbols=<method>", required_argument
, NULL
,
469 OPTION_UNRESOLVED_SYMBOLS
},
470 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
471 "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
472 "\t\t\t\tignore-in-shared-libs"), TWO_DASHES
},
473 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
474 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
475 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
476 '\0', NULL
, NULL
, NO_HELP
},
477 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
478 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
479 { {"version-exports-section", required_argument
, NULL
,
480 OPTION_VERSION_EXPORTS_SECTION
},
481 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
482 "\t\t\t\tSYMBOL as the version."), TWO_DASHES
},
483 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
484 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
485 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
486 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
488 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
489 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
490 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
491 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
492 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
493 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
495 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_SHARED_TEXTREL
},
496 '\0', NULL
, N_("Warn if shared object has DT_TEXTREL"),
498 { {"warn-unresolved-symbols", no_argument
, NULL
,
499 OPTION_WARN_UNRESOLVED_SYMBOLS
},
500 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
501 { {"error-unresolved-symbols", no_argument
, NULL
,
502 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
503 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
504 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
505 '\0', NULL
, N_("Include all objects from following archives"),
507 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
508 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
511 #define OPTION_COUNT ARRAY_SIZE (ld_options)
514 parse_args (unsigned argc
, char **argv
)
519 char *default_dirlist
= NULL
;
521 struct option
*longopts
;
522 struct option
*really_longopts
;
524 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
526 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
527 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
528 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
530 /* Starting the short option string with '-' is for programs that
531 expect options and other ARGV-elements in any order and that care about
532 the ordering of the two. We describe each non-option ARGV-element
533 as if it were the argument of an option with character code 1. */
538 for (i
= 0; i
< OPTION_COUNT
; i
++)
540 if (ld_options
[i
].shortopt
!= '\0')
542 shortopts
[is
] = ld_options
[i
].shortopt
;
544 if (ld_options
[i
].opt
.has_arg
== required_argument
545 || ld_options
[i
].opt
.has_arg
== optional_argument
)
549 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
556 if (ld_options
[i
].opt
.name
!= NULL
)
558 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
560 really_longopts
[irl
] = ld_options
[i
].opt
;
565 longopts
[il
] = ld_options
[i
].opt
;
570 shortopts
[is
] = '\0';
571 longopts
[il
].name
= NULL
;
572 really_longopts
[irl
].name
= NULL
;
574 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
576 /* The -G option is ambiguous on different platforms. Sometimes it
577 specifies the largest data size to put into the small data
578 section. Sometimes it is equivalent to --shared. Unfortunately,
579 the first form takes an argument, while the second does not.
581 We need to permit the --shared form because on some platforms,
582 such as Solaris, gcc -shared will pass -G to the linker.
584 To permit either usage, we look through the argument list. If we
585 find -G not followed by a number, we change it into --shared.
586 This will work for most normal cases. */
587 for (i
= 1; i
< argc
; i
++)
588 if (strcmp (argv
[i
], "-G") == 0
590 || ! ISDIGIT (argv
[i
+ 1][0])))
591 argv
[i
] = (char *) "--shared";
593 /* Because we permit long options to start with a single dash, and
594 we have a --library option, and the -l option is conventionally
595 used with an immediately following argument, we can have bad
596 results if somebody tries to use -l with a library whose name
597 happens to start with "ibrary", as in -li. We avoid problems by
598 simply turning -l into --library. This means that users will
599 have to use two dashes in order to use --library, which is OK
600 since that's how it is documented.
602 FIXME: It's possible that this problem can arise for other short
603 options as well, although the user does always have the recourse
604 of adding a space between the option and the argument. */
605 for (i
= 1; i
< argc
; i
++)
607 if (argv
[i
][0] == '-'
609 && argv
[i
][2] != '\0')
613 n
= xmalloc (strlen (argv
[i
]) + 20);
614 sprintf (n
, "--library=%s", argv
[i
] + 2);
625 /* Using last_optind lets us avoid calling ldemul_parse_args
626 multiple times on a single option, which would lead to
627 confusion in the internal static variables maintained by
628 getopt. This could otherwise happen for an argument like
629 -nx, in which the -n is parsed as a single option, and we
630 loop around to pick up the -x. */
631 if (optind
!= last_optind
)
632 if (ldemul_parse_args (argc
, argv
))
635 /* getopt_long_only is like getopt_long, but '-' as well as '--'
636 can indicate a long option. */
638 last_optind
= optind
;
639 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
642 optind
= last_optind
;
643 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
646 if (ldemul_handle_option (optc
))
655 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
657 einfo (_("%P%F: use the --help option for usage information\n"));
659 case 1: /* File name. */
660 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
666 /* For HP/UX compatibility. Actually -a shared should mean
667 ``use only shared libraries'' but, then, we don't
668 currently support shared libraries on HP/UX anyhow. */
669 if (strcmp (optarg
, "archive") == 0)
670 config
.dynamic_link
= FALSE
;
671 else if (strcmp (optarg
, "shared") == 0
672 || strcmp (optarg
, "default") == 0)
673 config
.dynamic_link
= TRUE
;
675 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
678 /* FIXME: We just ignore these, but we should handle them. */
679 if (strcmp (optarg
, "definitions") == 0)
681 else if (strcmp (optarg
, "nodefinitions") == 0)
683 else if (strcmp (optarg
, "nosymbolic") == 0)
685 else if (strcmp (optarg
, "pure-text") == 0)
688 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
691 ldfile_add_arch (optarg
);
694 lang_add_target (optarg
);
697 ldfile_open_command_file (optarg
);
698 parser_input
= input_mri_script
;
701 case OPTION_CALL_SHARED
:
702 config
.dynamic_link
= TRUE
;
704 case OPTION_NON_SHARED
:
705 config
.dynamic_link
= FALSE
;
708 command_line
.cref
= TRUE
;
709 link_info
.notice_all
= TRUE
;
712 command_line
.force_common_definition
= TRUE
;
716 lex_redirect (optarg
);
717 parser_input
= input_defsym
;
723 case OPTION_DEMANGLE
:
727 enum demangling_styles style
;
729 style
= cplus_demangle_name_to_style (optarg
);
730 if (style
== unknown_demangling
)
731 einfo (_("%F%P: unknown demangling style `%s'"),
734 cplus_demangle_set_style (style
);
737 case 'I': /* Used on Solaris. */
738 case OPTION_DYNAMIC_LINKER
:
739 command_line
.interpreter
= optarg
;
742 command_line
.endian
= ENDIAN_BIG
;
745 command_line
.endian
= ENDIAN_LITTLE
;
747 case OPTION_EMBEDDED_RELOCS
:
748 command_line
.embedded_relocs
= TRUE
;
750 case OPTION_EXPORT_DYNAMIC
:
751 case 'E': /* HP/UX compatibility. */
752 link_info
.export_dynamic
= TRUE
;
755 lang_add_entry (optarg
, TRUE
);
758 if (command_line
.auxiliary_filters
== NULL
)
760 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
761 command_line
.auxiliary_filters
[0] = optarg
;
762 command_line
.auxiliary_filters
[1] = NULL
;
770 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
772 command_line
.auxiliary_filters
773 = xrealloc (command_line
.auxiliary_filters
,
774 (c
+ 2) * sizeof (char *));
775 command_line
.auxiliary_filters
[c
] = optarg
;
776 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
780 command_line
.filter_shlib
= optarg
;
782 case OPTION_FORCE_EXE_SUFFIX
:
783 command_line
.force_exe_suffix
= TRUE
;
788 g_switch_value
= strtoul (optarg
, &end
, 0);
790 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
796 case OPTION_GC_SECTIONS
:
797 command_line
.gc_sections
= TRUE
;
804 ldfile_add_library_path (optarg
, TRUE
);
807 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
810 config
.map_filename
= "-";
813 /* Ignore. Was handled in a pre-parse. */
816 config
.map_filename
= optarg
;
819 config
.text_read_only
= FALSE
;
820 config
.magic_demand_paged
= FALSE
;
821 config
.dynamic_link
= FALSE
;
823 case OPTION_NO_OMAGIC
:
824 config
.text_read_only
= TRUE
;
825 config
.magic_demand_paged
= TRUE
;
826 /* NB/ Does not set dynamic_link to TRUE.
827 Use --call-shared or -Bdynamic for this. */
830 config
.magic_demand_paged
= FALSE
;
831 config
.dynamic_link
= FALSE
;
833 case OPTION_NO_DEFINE_COMMON
:
834 command_line
.inhibit_common_definition
= TRUE
;
836 case OPTION_NO_DEMANGLE
:
839 case OPTION_NO_GC_SECTIONS
:
840 command_line
.gc_sections
= FALSE
;
842 case OPTION_NO_KEEP_MEMORY
:
843 link_info
.keep_memory
= FALSE
;
845 case OPTION_NO_UNDEFINED
:
846 link_info
.unresolved_syms_in_objects
847 = how_to_report_unresolved_symbols
;
849 case OPTION_ALLOW_SHLIB_UNDEFINED
:
850 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
852 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
853 link_info
.unresolved_syms_in_shared_libs
854 = how_to_report_unresolved_symbols
;
856 case OPTION_UNRESOLVED_SYMBOLS
:
857 if (strcmp (optarg
, "ignore-all") == 0)
859 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
860 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
862 else if (strcmp (optarg
, "report-all") == 0)
864 link_info
.unresolved_syms_in_objects
865 = how_to_report_unresolved_symbols
;
866 link_info
.unresolved_syms_in_shared_libs
867 = how_to_report_unresolved_symbols
;
869 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
871 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
872 link_info
.unresolved_syms_in_shared_libs
873 = how_to_report_unresolved_symbols
;
875 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
877 link_info
.unresolved_syms_in_objects
878 = how_to_report_unresolved_symbols
;
879 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
882 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
884 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
885 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
886 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
887 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
888 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
889 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
892 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
893 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
894 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
895 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
896 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
897 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
899 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
900 link_info
.allow_multiple_definition
= TRUE
;
902 case OPTION_NO_UNDEFINED_VERSION
:
903 link_info
.allow_undefined_version
= FALSE
;
905 case OPTION_NO_WARN_MISMATCH
:
906 command_line
.warn_mismatch
= FALSE
;
908 case OPTION_NOINHIBIT_EXEC
:
909 force_make_executable
= TRUE
;
911 case OPTION_NOSTDLIB
:
912 config
.only_cmd_line_lib_dirs
= TRUE
;
914 case OPTION_NO_WHOLE_ARCHIVE
:
915 whole_archive
= FALSE
;
918 /* FIXME "-O<non-digits> <value>" used to set the address of
919 section <non-digits>. Was this for compatibility with
920 something, or can we create a new option to do that
921 (with a syntax similar to -defsym)?
922 getopt can't handle two args to an option without kludges. */
924 /* Enable optimizations of output files. */
925 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
928 lang_add_output (optarg
, 0);
931 lang_add_output_format (optarg
, NULL
, NULL
, 0);
934 link_info
.emitrelocations
= TRUE
;
938 if (optind
== last_optind
)
939 /* This can happen if the user put "-rpath,a" on the command
940 line. (Or something similar. The comma is important).
941 Getopt becomes confused and thinks that this is a -r option
942 but it cannot parse the text after the -r so it refuses to
943 increment the optind counter. Detect this case and issue
944 an error message here. We cannot just make this a warning,
945 increment optind, and continue because getopt is too confused
946 and will seg-fault the next time around. */
947 einfo(_("%P%F: bad -rpath option\n"));
949 link_info
.relocatable
= TRUE
;
950 config
.build_constructors
= FALSE
;
951 config
.magic_demand_paged
= FALSE
;
952 config
.text_read_only
= FALSE
;
953 config
.dynamic_link
= FALSE
;
956 /* The GNU linker traditionally uses -R to mean to include
957 only the symbols from a file. The Solaris linker uses -R
958 to set the path used by the runtime linker to find
959 libraries. This is the GNU linker -rpath argument. We
960 try to support both simultaneously by checking the file
961 named. If it is a directory, rather than a regular file,
962 we assume -rpath was meant. */
966 if (stat (optarg
, &s
) >= 0
967 && ! S_ISDIR (s
.st_mode
))
969 lang_add_input_file (optarg
,
970 lang_input_file_is_symbols_only_enum
,
977 if (command_line
.rpath
== NULL
)
978 command_line
.rpath
= xstrdup (optarg
);
981 size_t rpath_len
= strlen (command_line
.rpath
);
982 size_t optarg_len
= strlen (optarg
);
984 char *cp
= command_line
.rpath
;
986 /* First see whether OPTARG is already in the path. */
991 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
993 if (optarg
[idx
] == '\0'
994 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
999 cp
= strchr (cp
, ':');
1007 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
1008 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
1009 free (command_line
.rpath
);
1010 command_line
.rpath
= buf
;
1014 case OPTION_RPATH_LINK
:
1015 if (command_line
.rpath_link
== NULL
)
1016 command_line
.rpath_link
= xstrdup (optarg
);
1021 buf
= xmalloc (strlen (command_line
.rpath_link
)
1024 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
1025 free (command_line
.rpath_link
);
1026 command_line
.rpath_link
= buf
;
1030 command_line
.relax
= TRUE
;
1032 case OPTION_RETAIN_SYMBOLS_FILE
:
1033 add_keepsyms_file (optarg
);
1036 link_info
.strip
= strip_debugger
;
1039 link_info
.strip
= strip_all
;
1041 case OPTION_STRIP_DISCARDED
:
1042 link_info
.strip_discarded
= TRUE
;
1044 case OPTION_NO_STRIP_DISCARDED
:
1045 link_info
.strip_discarded
= FALSE
;
1048 if (config
.has_shared
)
1050 link_info
.shared
= TRUE
;
1051 /* When creating a shared library, the default
1052 behaviour is to ignore any unresolved references. */
1053 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1054 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1055 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1056 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1059 einfo (_("%P%F: -shared not supported\n"));
1062 if (config
.has_shared
)
1064 link_info
.shared
= TRUE
;
1065 link_info
.pie
= TRUE
;
1068 einfo (_("%P%F: -pie not supported\n"));
1070 case 'h': /* Used on Solaris. */
1072 command_line
.soname
= optarg
;
1074 case OPTION_SORT_COMMON
:
1075 config
.sort_common
= TRUE
;
1077 case OPTION_SORT_SECTION
:
1078 if (strcmp (optarg
, N_("name")) == 0)
1079 sort_section
= by_name
;
1080 else if (strcmp (optarg
, N_("alignment")) == 0)
1081 sort_section
= by_alignment
;
1083 einfo (_("%P%F: invalid section sorting option: %s\n"),
1087 config
.stats
= TRUE
;
1089 case OPTION_SYMBOLIC
:
1090 link_info
.symbolic
= TRUE
;
1096 ldfile_open_command_file (optarg
);
1097 parser_input
= input_script
;
1100 case OPTION_SECTION_START
:
1106 /* Check for <something>=<somthing>... */
1107 optarg2
= strchr (optarg
, '=');
1108 if (optarg2
== NULL
)
1109 einfo (_("%P%F: invalid argument to option"
1110 " \"--section-start\"\n"));
1114 /* So far so good. Are all the args present? */
1115 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1116 einfo (_("%P%F: missing argument(s) to option"
1117 " \"--section-start\"\n"));
1119 /* We must copy the section name as set_section_start
1120 doesn't do it for us. */
1121 len
= optarg2
- optarg
;
1122 sec_name
= xmalloc (len
);
1123 memcpy (sec_name
, optarg
, len
- 1);
1124 sec_name
[len
- 1] = 0;
1126 /* Then set it... */
1127 set_section_start (sec_name
, optarg2
);
1130 case OPTION_TARGET_HELP
:
1131 /* Mention any target specific options. */
1132 ldemul_list_emulation_options (stdout
);
1135 set_section_start (".bss", optarg
);
1138 set_section_start (".data", optarg
);
1141 set_section_start (".text", optarg
);
1143 case OPTION_TRADITIONAL_FORMAT
:
1144 link_info
.traditional_format
= TRUE
;
1146 case OPTION_TASK_LINK
:
1147 link_info
.task_link
= TRUE
;
1148 /* Fall through - do an implied -r option. */
1150 link_info
.relocatable
= TRUE
;
1151 config
.build_constructors
= TRUE
;
1152 config
.magic_demand_paged
= FALSE
;
1153 config
.text_read_only
= FALSE
;
1154 config
.dynamic_link
= FALSE
;
1157 ldlang_add_undef (optarg
);
1161 lang_add_unique (optarg
);
1163 config
.unique_orphan_sections
= TRUE
;
1165 case OPTION_VERBOSE
:
1167 version_printed
= TRUE
;
1168 trace_file_tries
= TRUE
;
1169 overflow_cutoff_limit
= -2;
1173 version_printed
= TRUE
;
1177 version_printed
= TRUE
;
1179 case OPTION_VERSION
:
1183 case OPTION_VERSION_SCRIPT
:
1184 /* This option indicates a small script that only specifies
1185 version information. Read it, but don't assume that
1186 we've seen a linker script. */
1188 FILE *hold_script_handle
;
1190 hold_script_handle
= saved_script_handle
;
1191 ldfile_open_command_file (optarg
);
1192 saved_script_handle
= hold_script_handle
;
1193 parser_input
= input_version_script
;
1197 case OPTION_VERSION_EXPORTS_SECTION
:
1198 /* This option records a version symbol to be applied to the
1199 symbols listed for export to be found in the object files
1200 .exports sections. */
1201 command_line
.version_exports_section
= optarg
;
1203 case OPTION_WARN_COMMON
:
1204 config
.warn_common
= TRUE
;
1206 case OPTION_WARN_CONSTRUCTORS
:
1207 config
.warn_constructors
= TRUE
;
1209 case OPTION_WARN_FATAL
:
1210 config
.fatal_warnings
= TRUE
;
1212 case OPTION_WARN_MULTIPLE_GP
:
1213 config
.warn_multiple_gp
= TRUE
;
1215 case OPTION_WARN_ONCE
:
1216 config
.warn_once
= TRUE
;
1218 case OPTION_WARN_SECTION_ALIGN
:
1219 config
.warn_section_align
= TRUE
;
1221 case OPTION_WARN_SHARED_TEXTREL
:
1222 link_info
.warn_shared_textrel
= TRUE
;
1224 case OPTION_WHOLE_ARCHIVE
:
1225 whole_archive
= TRUE
;
1227 case OPTION_ADD_NEEDED
:
1230 case OPTION_NO_ADD_NEEDED
:
1233 case OPTION_AS_NEEDED
:
1236 case OPTION_NO_AS_NEEDED
:
1242 case OPTION_DISCARD_NONE
:
1243 link_info
.discard
= discard_none
;
1246 link_info
.discard
= discard_l
;
1249 link_info
.discard
= discard_all
;
1252 if (strncmp (optarg
, "P,", 2) == 0)
1254 if (default_dirlist
!= NULL
)
1255 free (default_dirlist
);
1256 default_dirlist
= xstrdup (optarg
);
1261 case OPTION_SPARE_DYNAMIC_TAGS
:
1262 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1264 case OPTION_SPLIT_BY_RELOC
:
1266 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1268 config
.split_by_reloc
= 32768;
1270 case OPTION_SPLIT_BY_FILE
:
1272 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1274 config
.split_by_file
= 1;
1276 case OPTION_CHECK_SECTIONS
:
1277 command_line
.check_section_addresses
= TRUE
;
1279 case OPTION_NO_CHECK_SECTIONS
:
1280 command_line
.check_section_addresses
= FALSE
;
1282 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1283 command_line
.accept_unknown_input_arch
= TRUE
;
1285 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1286 command_line
.accept_unknown_input_arch
= FALSE
;
1290 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1292 lang_enter_group ();
1297 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1299 lang_leave_group ();
1304 link_info
.init_function
= optarg
;
1308 link_info
.fini_function
= optarg
;
1311 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1312 command_line
.reduce_memory_overheads
= TRUE
;
1313 if (config
.hash_table_size
== 0)
1314 config
.hash_table_size
= 1021;
1317 case OPTION_HASH_SIZE
:
1319 bfd_size_type new_size
;
1321 new_size
= strtoul (optarg
, NULL
, 0);
1323 config
.hash_table_size
= new_size
;
1325 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1332 lang_leave_group ();
1334 if (default_dirlist
!= NULL
)
1336 set_default_dirlist (default_dirlist
);
1337 free (default_dirlist
);
1340 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1341 /* FIXME: Should we allow emulations a chance to set this ? */
1342 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1344 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1345 /* FIXME: Should we allow emulations a chance to set this ? */
1346 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1349 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1350 library search path. */
1353 set_default_dirlist (char *dirlist_ptr
)
1359 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1362 if (*dirlist_ptr
!= '\0')
1363 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1366 dirlist_ptr
= p
+ 1;
1371 set_section_start (char *sect
, char *valstr
)
1374 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1376 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1377 lang_section_start (sect
, exp_intop (val
));
1380 /* Print help messages for the options. */
1386 const char **targets
, **pp
;
1388 printf (_("Usage: %s [options] file...\n"), program_name
);
1390 printf (_("Options:\n"));
1391 for (i
= 0; i
< OPTION_COUNT
; i
++)
1393 if (ld_options
[i
].doc
!= NULL
)
1407 if (ld_options
[j
].shortopt
!= '\0'
1408 && ld_options
[j
].control
!= NO_HELP
)
1410 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1411 len
+= (comma
? 2 : 0) + 2;
1412 if (ld_options
[j
].arg
!= NULL
)
1414 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1419 printf ("%s", _(ld_options
[j
].arg
));
1420 len
+= strlen (_(ld_options
[j
].arg
));
1426 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1431 if (ld_options
[j
].opt
.name
!= NULL
1432 && ld_options
[j
].control
!= NO_HELP
)
1435 (ld_options
[j
].control
== TWO_DASHES
1436 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1440 two_dashes
? "-" : "",
1441 ld_options
[j
].opt
.name
);
1442 len
+= ((comma
? 2 : 0)
1444 + (two_dashes
? 1 : 0)
1445 + strlen (ld_options
[j
].opt
.name
));
1446 if (ld_options
[j
].arg
!= NULL
)
1448 printf (" %s", _(ld_options
[j
].arg
));
1449 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1455 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1463 for (; len
< 30; len
++)
1466 printf ("%s\n", _(ld_options
[i
].doc
));
1470 /* Note: Various tools (such as libtool) depend upon the
1471 format of the listings below - do not change them. */
1472 /* xgettext:c-format */
1473 printf (_("%s: supported targets:"), program_name
);
1474 targets
= bfd_target_list ();
1475 for (pp
= targets
; *pp
!= NULL
; pp
++)
1476 printf (" %s", *pp
);
1480 /* xgettext:c-format */
1481 printf (_("%s: supported emulations: "), program_name
);
1482 ldemul_list_emulations (stdout
);
1485 /* xgettext:c-format */
1486 printf (_("%s: emulation specific options:\n"), program_name
);
1487 ldemul_list_emulation_options (stdout
);
1490 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);