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_REDUCE_MEMORY_OVERHEADS
153 /* The long options. This structure is used for both the option
154 parsing and the help text. */
158 /* The long option information. */
160 /* The short option with the same meaning ('\0' if none). */
162 /* The name of the argument (NULL if none). */
164 /* The documentation string. If this is NULL, this is a synonym for
165 the previous option. */
168 /* Use one dash before long option name. */
170 /* Use two dashes before long option name. */
172 /* Only accept two dashes before the long option name.
173 This is an overloading of the use of this enum, since originally it
174 was only intended to tell the --help display function how to display
175 the long option name. This feature was added in order to resolve
176 the confusion about the -omagic command line switch. Is it setting
177 the output file name to "magic" or is it setting the NMAGIC flag on
178 the output ? It has been decided that it is setting the output file
179 name, and that if you want to set the NMAGIC flag you should use -N
182 /* Don't mention this option in --help output. */
187 static const struct ld_option ld_options
[] =
189 { {NULL
, required_argument
, NULL
, '\0'},
190 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
192 { {"architecture", required_argument
, NULL
, 'A'},
193 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
194 { {"format", required_argument
, NULL
, 'b'},
195 'b', N_("TARGET"), N_("Specify target for following input files"),
197 { {"mri-script", required_argument
, NULL
, 'c'},
198 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
199 { {"dc", no_argument
, NULL
, 'd'},
200 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
201 { {"dp", no_argument
, NULL
, 'd'},
202 '\0', NULL
, NULL
, ONE_DASH
},
203 { {"entry", required_argument
, NULL
, 'e'},
204 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
205 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
206 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
207 { {"EB", no_argument
, NULL
, OPTION_EB
},
208 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
209 { {"EL", no_argument
, NULL
, OPTION_EL
},
210 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
211 { {"auxiliary", required_argument
, NULL
, 'f'},
212 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
214 { {"filter", required_argument
, NULL
, 'F'},
215 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
217 { {NULL
, no_argument
, NULL
, '\0'},
218 'g', NULL
, N_("Ignored"), ONE_DASH
},
219 { {"gpsize", required_argument
, NULL
, 'G'},
220 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
222 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
223 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
224 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
225 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
227 { {"library", required_argument
, NULL
, 'l'},
228 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
229 { {"library-path", required_argument
, NULL
, 'L'},
230 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
232 { {NULL
, required_argument
, NULL
, '\0'},
233 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
234 { {"print-map", no_argument
, NULL
, 'M'},
235 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
236 { {"nmagic", no_argument
, NULL
, 'n'},
237 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
238 { {"omagic", no_argument
, NULL
, 'N'},
239 'N', NULL
, N_("Do not page align data, do not make text readonly"),
240 EXACTLY_TWO_DASHES
},
241 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
242 '\0', NULL
, N_("Page align data, make text readonly"),
243 EXACTLY_TWO_DASHES
},
244 { {"output", required_argument
, NULL
, 'o'},
245 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
246 { {NULL
, required_argument
, NULL
, '\0'},
247 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
248 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
249 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
250 { {"emit-relocs", no_argument
, NULL
, 'q'},
251 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
252 { {"relocatable", no_argument
, NULL
, 'r'},
253 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
254 { {NULL
, no_argument
, NULL
, '\0'},
255 'i', NULL
, NULL
, ONE_DASH
},
256 { {"just-symbols", required_argument
, NULL
, 'R'},
257 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
259 { {"strip-all", no_argument
, NULL
, 's'},
260 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
261 { {"strip-debug", no_argument
, NULL
, 'S'},
262 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
263 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
264 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
265 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
266 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
267 { {"trace", no_argument
, NULL
, 't'},
268 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
269 { {"script", required_argument
, NULL
, 'T'},
270 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
271 { {"undefined", required_argument
, NULL
, 'u'},
272 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
274 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
275 '\0', N_("[=SECTION]"),
276 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
277 { {"Ur", no_argument
, NULL
, OPTION_UR
},
278 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
279 { {"version", no_argument
, NULL
, OPTION_VERSION
},
280 'v', NULL
, N_("Print version information"), TWO_DASHES
},
281 { {NULL
, no_argument
, NULL
, '\0'},
282 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
283 { {"discard-all", no_argument
, NULL
, 'x'},
284 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
285 { {"discard-locals", no_argument
, NULL
, 'X'},
286 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
287 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
288 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
289 { {"trace-symbol", required_argument
, NULL
, 'y'},
290 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
291 { {NULL
, required_argument
, NULL
, '\0'},
292 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
294 { {"start-group", no_argument
, NULL
, '('},
295 '(', NULL
, N_("Start a group"), TWO_DASHES
},
296 { {"end-group", no_argument
, NULL
, ')'},
297 ')', NULL
, N_("End a group"), TWO_DASHES
},
298 { {"accept-unknown-input-arch", no_argument
, NULL
,
299 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
301 N_("Accept input files whose architecture cannot be determined"),
303 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
304 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
305 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
307 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
308 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
309 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
310 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
311 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
312 '\0', NULL
, NULL
, ONE_DASH
},
313 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
314 '\0', NULL
, NULL
, ONE_DASH
},
315 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
316 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
317 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
318 '\0', NULL
, NULL
, ONE_DASH
},
319 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
320 '\0', NULL
, NULL
, ONE_DASH
},
321 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
322 '\0', NULL
, NULL
, ONE_DASH
},
323 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
324 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
325 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
326 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
328 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
329 '\0', NULL
, N_("Do not check section addresses for overlaps"),
331 { {"cref", no_argument
, NULL
, OPTION_CREF
},
332 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
333 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
334 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
335 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
336 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
338 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
339 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
340 { {"fini", required_argument
, NULL
, OPTION_FINI
},
341 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
342 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
343 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
344 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
345 '\0', NULL
, N_("Remove unused sections (on some targets)"),
347 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
348 '\0', NULL
, N_("Don't remove unused sections (default)"),
350 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
351 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
353 { {"help", no_argument
, NULL
, OPTION_HELP
},
354 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
355 { {"init", required_argument
, NULL
, OPTION_INIT
},
356 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
357 { {"Map", required_argument
, NULL
, OPTION_MAP
},
358 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
359 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
360 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
361 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
362 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
363 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
364 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
365 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
366 '\0', NULL
, N_("Do not allow unresolved references in object files"),
368 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
369 '\0', NULL
, N_("Allow unresolved references in shared libaries"),
371 { {"no-allow-shlib-undefined", no_argument
, NULL
,
372 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
373 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
375 { {"allow-multiple-definition", no_argument
, NULL
,
376 OPTION_ALLOW_MULTIPLE_DEFINITION
},
377 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
378 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
379 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
380 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
381 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
382 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
383 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
384 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
385 '\0', NULL
, N_("Create an output file even if errors occur"),
387 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
388 '\0', NULL
, NULL
, NO_HELP
},
389 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
390 '\0', NULL
, N_("Only use library directories specified on\n"
391 "\t\t\t\tthe command line"), ONE_DASH
},
392 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
393 '\0', N_("TARGET"), N_("Specify target of output file"),
394 EXACTLY_TWO_DASHES
},
395 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
396 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
397 { {"reduce-memory-overheads", no_argument
, NULL
,
398 OPTION_REDUCE_MEMORY_OVERHEADS
},
399 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
401 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
402 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
403 { {"retain-symbols-file", required_argument
, NULL
,
404 OPTION_RETAIN_SYMBOLS_FILE
},
405 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
406 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
407 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
408 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
409 '\0', N_("PATH"), N_("Set link time shared library search path"),
411 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
412 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
413 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
414 '\0', NULL
, NULL
, ONE_DASH
},
415 { {"pie", no_argument
, NULL
, OPTION_PIE
},
416 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
417 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
418 '\0', NULL
, NULL
, TWO_DASHES
},
419 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
420 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
421 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
422 '\0', NULL
, NULL
, NO_HELP
},
423 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
424 '\0', N_("name|alignment"),
425 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
426 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
427 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
429 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
430 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
432 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
433 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
435 { {"stats", no_argument
, NULL
, OPTION_STATS
},
436 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
437 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
438 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
439 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
440 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
441 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
442 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
443 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
444 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
446 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
447 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
448 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
449 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
450 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
451 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
452 { {"unresolved-symbols=<method>", required_argument
, NULL
,
453 OPTION_UNRESOLVED_SYMBOLS
},
454 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
455 "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
456 "\t\t\t\tignore-in-shared-libs"), TWO_DASHES
},
457 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
458 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
459 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
460 '\0', NULL
, NULL
, NO_HELP
},
461 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
462 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
463 { {"version-exports-section", required_argument
, NULL
,
464 OPTION_VERSION_EXPORTS_SECTION
},
465 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
466 "\t\t\t\tSYMBOL as the version."), TWO_DASHES
},
467 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
468 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
469 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
470 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
472 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
473 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
474 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
475 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
476 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
477 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
479 { {"warn-unresolved-symbols", no_argument
, NULL
,
480 OPTION_WARN_UNRESOLVED_SYMBOLS
},
481 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
482 { {"error-unresolved-symbols", no_argument
, NULL
,
483 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
484 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
485 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
486 '\0', NULL
, N_("Treat warnings as errors"),
488 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
489 '\0', NULL
, N_("Include all objects from following archives"),
491 { {"add-needed", no_argument
, NULL
, OPTION_ADD_NEEDED
},
492 '\0', NULL
, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
493 "\t\t\t\tfollowing dynamic libs"), TWO_DASHES
},
494 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_NEEDED
},
495 '\0', NULL
, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
496 "\t\t\t\tin following dynamic libs"), TWO_DASHES
},
497 { {"as-needed", no_argument
, NULL
, OPTION_AS_NEEDED
},
498 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
500 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_AS_NEEDED
},
501 '\0', NULL
, N_("Always set DT_NEEDED for following dynamic libs"),
503 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
504 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
507 #define OPTION_COUNT ARRAY_SIZE (ld_options)
510 parse_args (unsigned argc
, char **argv
)
515 char *default_dirlist
= NULL
;
517 struct option
*longopts
;
518 struct option
*really_longopts
;
520 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
522 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
523 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
524 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
526 /* Starting the short option string with '-' is for programs that
527 expect options and other ARGV-elements in any order and that care about
528 the ordering of the two. We describe each non-option ARGV-element
529 as if it were the argument of an option with character code 1. */
534 for (i
= 0; i
< OPTION_COUNT
; i
++)
536 if (ld_options
[i
].shortopt
!= '\0')
538 shortopts
[is
] = ld_options
[i
].shortopt
;
540 if (ld_options
[i
].opt
.has_arg
== required_argument
541 || ld_options
[i
].opt
.has_arg
== optional_argument
)
545 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
552 if (ld_options
[i
].opt
.name
!= NULL
)
554 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
556 really_longopts
[irl
] = ld_options
[i
].opt
;
561 longopts
[il
] = ld_options
[i
].opt
;
566 shortopts
[is
] = '\0';
567 longopts
[il
].name
= NULL
;
568 really_longopts
[irl
].name
= NULL
;
570 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
572 /* The -G option is ambiguous on different platforms. Sometimes it
573 specifies the largest data size to put into the small data
574 section. Sometimes it is equivalent to --shared. Unfortunately,
575 the first form takes an argument, while the second does not.
577 We need to permit the --shared form because on some platforms,
578 such as Solaris, gcc -shared will pass -G to the linker.
580 To permit either usage, we look through the argument list. If we
581 find -G not followed by a number, we change it into --shared.
582 This will work for most normal cases. */
583 for (i
= 1; i
< argc
; i
++)
584 if (strcmp (argv
[i
], "-G") == 0
586 || ! ISDIGIT (argv
[i
+ 1][0])))
587 argv
[i
] = (char *) "--shared";
589 /* Because we permit long options to start with a single dash, and
590 we have a --library option, and the -l option is conventionally
591 used with an immediately following argument, we can have bad
592 results if somebody tries to use -l with a library whose name
593 happens to start with "ibrary", as in -li. We avoid problems by
594 simply turning -l into --library. This means that users will
595 have to use two dashes in order to use --library, which is OK
596 since that's how it is documented.
598 FIXME: It's possible that this problem can arise for other short
599 options as well, although the user does always have the recourse
600 of adding a space between the option and the argument. */
601 for (i
= 1; i
< argc
; i
++)
603 if (argv
[i
][0] == '-'
605 && argv
[i
][2] != '\0')
609 n
= xmalloc (strlen (argv
[i
]) + 20);
610 sprintf (n
, "--library=%s", argv
[i
] + 2);
621 /* Using last_optind lets us avoid calling ldemul_parse_args
622 multiple times on a single option, which would lead to
623 confusion in the internal static variables maintained by
624 getopt. This could otherwise happen for an argument like
625 -nx, in which the -n is parsed as a single option, and we
626 loop around to pick up the -x. */
627 if (optind
!= last_optind
)
628 if (ldemul_parse_args (argc
, argv
))
631 /* getopt_long_only is like getopt_long, but '-' as well as '--'
632 can indicate a long option. */
634 last_optind
= optind
;
635 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
638 optind
= last_optind
;
639 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
642 if (ldemul_handle_option (optc
))
651 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
653 einfo (_("%P%F: use the --help option for usage information\n"));
655 case 1: /* File name. */
656 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
662 /* For HP/UX compatibility. Actually -a shared should mean
663 ``use only shared libraries'' but, then, we don't
664 currently support shared libraries on HP/UX anyhow. */
665 if (strcmp (optarg
, "archive") == 0)
666 config
.dynamic_link
= FALSE
;
667 else if (strcmp (optarg
, "shared") == 0
668 || strcmp (optarg
, "default") == 0)
669 config
.dynamic_link
= TRUE
;
671 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
674 /* FIXME: We just ignore these, but we should handle them. */
675 if (strcmp (optarg
, "definitions") == 0)
677 else if (strcmp (optarg
, "nodefinitions") == 0)
679 else if (strcmp (optarg
, "nosymbolic") == 0)
681 else if (strcmp (optarg
, "pure-text") == 0)
684 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
687 ldfile_add_arch (optarg
);
690 lang_add_target (optarg
);
693 ldfile_open_command_file (optarg
);
694 parser_input
= input_mri_script
;
697 case OPTION_CALL_SHARED
:
698 config
.dynamic_link
= TRUE
;
700 case OPTION_NON_SHARED
:
701 config
.dynamic_link
= FALSE
;
704 command_line
.cref
= TRUE
;
705 link_info
.notice_all
= TRUE
;
708 command_line
.force_common_definition
= TRUE
;
712 lex_redirect (optarg
);
713 parser_input
= input_defsym
;
719 case OPTION_DEMANGLE
:
723 enum demangling_styles style
;
725 style
= cplus_demangle_name_to_style (optarg
);
726 if (style
== unknown_demangling
)
727 einfo (_("%F%P: unknown demangling style `%s'"),
730 cplus_demangle_set_style (style
);
733 case 'I': /* Used on Solaris. */
734 case OPTION_DYNAMIC_LINKER
:
735 command_line
.interpreter
= optarg
;
738 command_line
.endian
= ENDIAN_BIG
;
741 command_line
.endian
= ENDIAN_LITTLE
;
743 case OPTION_EMBEDDED_RELOCS
:
744 command_line
.embedded_relocs
= TRUE
;
746 case OPTION_EXPORT_DYNAMIC
:
747 case 'E': /* HP/UX compatibility. */
748 link_info
.export_dynamic
= TRUE
;
751 lang_add_entry (optarg
, TRUE
);
754 if (command_line
.auxiliary_filters
== NULL
)
756 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
757 command_line
.auxiliary_filters
[0] = optarg
;
758 command_line
.auxiliary_filters
[1] = NULL
;
766 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
768 command_line
.auxiliary_filters
769 = xrealloc (command_line
.auxiliary_filters
,
770 (c
+ 2) * sizeof (char *));
771 command_line
.auxiliary_filters
[c
] = optarg
;
772 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
776 command_line
.filter_shlib
= optarg
;
778 case OPTION_FORCE_EXE_SUFFIX
:
779 command_line
.force_exe_suffix
= TRUE
;
784 g_switch_value
= strtoul (optarg
, &end
, 0);
786 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
792 case OPTION_GC_SECTIONS
:
793 command_line
.gc_sections
= TRUE
;
800 ldfile_add_library_path (optarg
, TRUE
);
803 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
806 config
.map_filename
= "-";
809 /* Ignore. Was handled in a pre-parse. */
812 config
.map_filename
= optarg
;
815 config
.text_read_only
= FALSE
;
816 config
.magic_demand_paged
= FALSE
;
817 config
.dynamic_link
= FALSE
;
819 case OPTION_NO_OMAGIC
:
820 config
.text_read_only
= TRUE
;
821 config
.magic_demand_paged
= TRUE
;
822 /* NB/ Does not set dynamic_link to TRUE.
823 Use --call-shared or -Bdynamic for this. */
826 config
.magic_demand_paged
= FALSE
;
827 config
.dynamic_link
= FALSE
;
829 case OPTION_NO_DEFINE_COMMON
:
830 command_line
.inhibit_common_definition
= TRUE
;
832 case OPTION_NO_DEMANGLE
:
835 case OPTION_NO_GC_SECTIONS
:
836 command_line
.gc_sections
= FALSE
;
838 case OPTION_NO_KEEP_MEMORY
:
839 link_info
.keep_memory
= FALSE
;
841 case OPTION_NO_UNDEFINED
:
842 link_info
.unresolved_syms_in_objects
843 = how_to_report_unresolved_symbols
;
845 case OPTION_ALLOW_SHLIB_UNDEFINED
:
846 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
848 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
849 link_info
.unresolved_syms_in_shared_libs
850 = how_to_report_unresolved_symbols
;
852 case OPTION_UNRESOLVED_SYMBOLS
:
853 if (strcmp (optarg
, "ignore-all") == 0)
855 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
856 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
858 else if (strcmp (optarg
, "report-all") == 0)
860 link_info
.unresolved_syms_in_objects
861 = how_to_report_unresolved_symbols
;
862 link_info
.unresolved_syms_in_shared_libs
863 = how_to_report_unresolved_symbols
;
865 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
867 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
868 link_info
.unresolved_syms_in_shared_libs
869 = how_to_report_unresolved_symbols
;
871 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
873 link_info
.unresolved_syms_in_objects
874 = how_to_report_unresolved_symbols
;
875 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
878 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
880 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
881 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
882 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
883 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
884 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
885 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
888 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
889 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
890 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
891 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
892 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
893 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
895 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
896 link_info
.allow_multiple_definition
= TRUE
;
898 case OPTION_NO_UNDEFINED_VERSION
:
899 link_info
.allow_undefined_version
= FALSE
;
901 case OPTION_NO_WARN_MISMATCH
:
902 command_line
.warn_mismatch
= FALSE
;
904 case OPTION_NOINHIBIT_EXEC
:
905 force_make_executable
= TRUE
;
907 case OPTION_NOSTDLIB
:
908 config
.only_cmd_line_lib_dirs
= TRUE
;
910 case OPTION_NO_WHOLE_ARCHIVE
:
911 whole_archive
= FALSE
;
914 /* FIXME "-O<non-digits> <value>" used to set the address of
915 section <non-digits>. Was this for compatibility with
916 something, or can we create a new option to do that
917 (with a syntax similar to -defsym)?
918 getopt can't handle two args to an option without kludges. */
920 /* Enable optimizations of output files. */
921 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
924 lang_add_output (optarg
, 0);
927 lang_add_output_format (optarg
, NULL
, NULL
, 0);
930 link_info
.emitrelocations
= TRUE
;
934 if (optind
== last_optind
)
935 /* This can happen if the user put "-rpath,a" on the command
936 line. (Or something similar. The comma is important).
937 Getopt becomes confused and thinks that this is a -r option
938 but it cannot parse the text after the -r so it refuses to
939 increment the optind counter. Detect this case and issue
940 an error message here. We cannot just make this a warning,
941 increment optind, and continue because getopt is too confused
942 and will seg-fault the next time around. */
943 einfo(_("%P%F: bad -rpath option\n"));
945 link_info
.relocatable
= TRUE
;
946 config
.build_constructors
= FALSE
;
947 config
.magic_demand_paged
= FALSE
;
948 config
.text_read_only
= FALSE
;
949 config
.dynamic_link
= FALSE
;
952 /* The GNU linker traditionally uses -R to mean to include
953 only the symbols from a file. The Solaris linker uses -R
954 to set the path used by the runtime linker to find
955 libraries. This is the GNU linker -rpath argument. We
956 try to support both simultaneously by checking the file
957 named. If it is a directory, rather than a regular file,
958 we assume -rpath was meant. */
962 if (stat (optarg
, &s
) >= 0
963 && ! S_ISDIR (s
.st_mode
))
965 lang_add_input_file (optarg
,
966 lang_input_file_is_symbols_only_enum
,
973 if (command_line
.rpath
== NULL
)
974 command_line
.rpath
= xstrdup (optarg
);
977 size_t rpath_len
= strlen (command_line
.rpath
);
978 size_t optarg_len
= strlen (optarg
);
980 char *cp
= command_line
.rpath
;
982 /* First see whether OPTARG is already in the path. */
987 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
989 if (optarg
[idx
] == '\0'
990 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
995 cp
= strchr (cp
, ':');
1003 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
1004 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
1005 free (command_line
.rpath
);
1006 command_line
.rpath
= buf
;
1010 case OPTION_RPATH_LINK
:
1011 if (command_line
.rpath_link
== NULL
)
1012 command_line
.rpath_link
= xstrdup (optarg
);
1017 buf
= xmalloc (strlen (command_line
.rpath_link
)
1020 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
1021 free (command_line
.rpath_link
);
1022 command_line
.rpath_link
= buf
;
1026 command_line
.relax
= TRUE
;
1028 case OPTION_RETAIN_SYMBOLS_FILE
:
1029 add_keepsyms_file (optarg
);
1032 link_info
.strip
= strip_debugger
;
1035 link_info
.strip
= strip_all
;
1037 case OPTION_STRIP_DISCARDED
:
1038 link_info
.strip_discarded
= TRUE
;
1040 case OPTION_NO_STRIP_DISCARDED
:
1041 link_info
.strip_discarded
= FALSE
;
1044 if (config
.has_shared
)
1046 link_info
.shared
= TRUE
;
1047 /* When creating a shared library, the default
1048 behaviour is to ignore any unresolved references. */
1049 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1050 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1051 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1052 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1055 einfo (_("%P%F: -shared not supported\n"));
1058 if (config
.has_shared
)
1060 link_info
.shared
= TRUE
;
1061 link_info
.pie
= TRUE
;
1064 einfo (_("%P%F: -pie not supported\n"));
1066 case 'h': /* Used on Solaris. */
1068 command_line
.soname
= optarg
;
1070 case OPTION_SORT_COMMON
:
1071 config
.sort_common
= TRUE
;
1073 case OPTION_SORT_SECTION
:
1074 if (strcmp (optarg
, N_("name")) == 0)
1075 sort_section
= by_name
;
1076 else if (strcmp (optarg
, N_("alignment")) == 0)
1077 sort_section
= by_alignment
;
1079 einfo (_("%P%F: invalid section sorting option: %s\n"),
1083 config
.stats
= TRUE
;
1085 case OPTION_SYMBOLIC
:
1086 link_info
.symbolic
= TRUE
;
1092 ldfile_open_command_file (optarg
);
1093 parser_input
= input_script
;
1096 case OPTION_SECTION_START
:
1102 /* Check for <something>=<somthing>... */
1103 optarg2
= strchr (optarg
, '=');
1104 if (optarg2
== NULL
)
1105 einfo (_("%P%F: invalid argument to option"
1106 " \"--section-start\"\n"));
1110 /* So far so good. Are all the args present? */
1111 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1112 einfo (_("%P%F: missing argument(s) to option"
1113 " \"--section-start\"\n"));
1115 /* We must copy the section name as set_section_start
1116 doesn't do it for us. */
1117 len
= optarg2
- optarg
;
1118 sec_name
= xmalloc (len
);
1119 memcpy (sec_name
, optarg
, len
- 1);
1120 sec_name
[len
- 1] = 0;
1122 /* Then set it... */
1123 set_section_start (sec_name
, optarg2
);
1126 case OPTION_TARGET_HELP
:
1127 /* Mention any target specific options. */
1128 ldemul_list_emulation_options (stdout
);
1131 set_section_start (".bss", optarg
);
1134 set_section_start (".data", optarg
);
1137 set_section_start (".text", optarg
);
1139 case OPTION_TRADITIONAL_FORMAT
:
1140 link_info
.traditional_format
= TRUE
;
1142 case OPTION_TASK_LINK
:
1143 link_info
.task_link
= TRUE
;
1144 /* Fall through - do an implied -r option. */
1146 link_info
.relocatable
= TRUE
;
1147 config
.build_constructors
= TRUE
;
1148 config
.magic_demand_paged
= FALSE
;
1149 config
.text_read_only
= FALSE
;
1150 config
.dynamic_link
= FALSE
;
1153 ldlang_add_undef (optarg
);
1157 lang_add_unique (optarg
);
1159 config
.unique_orphan_sections
= TRUE
;
1161 case OPTION_VERBOSE
:
1163 version_printed
= TRUE
;
1164 trace_file_tries
= TRUE
;
1165 overflow_cutoff_limit
= -2;
1169 version_printed
= TRUE
;
1173 version_printed
= TRUE
;
1175 case OPTION_VERSION
:
1179 case OPTION_VERSION_SCRIPT
:
1180 /* This option indicates a small script that only specifies
1181 version information. Read it, but don't assume that
1182 we've seen a linker script. */
1184 FILE *hold_script_handle
;
1186 hold_script_handle
= saved_script_handle
;
1187 ldfile_open_command_file (optarg
);
1188 saved_script_handle
= hold_script_handle
;
1189 parser_input
= input_version_script
;
1193 case OPTION_VERSION_EXPORTS_SECTION
:
1194 /* This option records a version symbol to be applied to the
1195 symbols listed for export to be found in the object files
1196 .exports sections. */
1197 command_line
.version_exports_section
= optarg
;
1199 case OPTION_WARN_COMMON
:
1200 config
.warn_common
= TRUE
;
1202 case OPTION_WARN_CONSTRUCTORS
:
1203 config
.warn_constructors
= TRUE
;
1205 case OPTION_WARN_FATAL
:
1206 config
.fatal_warnings
= TRUE
;
1208 case OPTION_WARN_MULTIPLE_GP
:
1209 config
.warn_multiple_gp
= TRUE
;
1211 case OPTION_WARN_ONCE
:
1212 config
.warn_once
= TRUE
;
1214 case OPTION_WARN_SECTION_ALIGN
:
1215 config
.warn_section_align
= TRUE
;
1217 case OPTION_WHOLE_ARCHIVE
:
1218 whole_archive
= TRUE
;
1220 case OPTION_ADD_NEEDED
:
1223 case OPTION_NO_ADD_NEEDED
:
1226 case OPTION_AS_NEEDED
:
1229 case OPTION_NO_AS_NEEDED
:
1235 case OPTION_DISCARD_NONE
:
1236 link_info
.discard
= discard_none
;
1239 link_info
.discard
= discard_l
;
1242 link_info
.discard
= discard_all
;
1245 if (strncmp (optarg
, "P,", 2) == 0)
1247 if (default_dirlist
!= NULL
)
1248 free (default_dirlist
);
1249 default_dirlist
= xstrdup (optarg
);
1254 case OPTION_SPARE_DYNAMIC_TAGS
:
1255 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1257 case OPTION_SPLIT_BY_RELOC
:
1259 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1261 config
.split_by_reloc
= 32768;
1263 case OPTION_SPLIT_BY_FILE
:
1265 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1267 config
.split_by_file
= 1;
1269 case OPTION_CHECK_SECTIONS
:
1270 command_line
.check_section_addresses
= TRUE
;
1272 case OPTION_NO_CHECK_SECTIONS
:
1273 command_line
.check_section_addresses
= FALSE
;
1275 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1276 command_line
.accept_unknown_input_arch
= TRUE
;
1278 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1279 command_line
.accept_unknown_input_arch
= FALSE
;
1283 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1285 lang_enter_group ();
1290 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1292 lang_leave_group ();
1297 link_info
.init_function
= optarg
;
1301 link_info
.fini_function
= optarg
;
1304 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1305 command_line
.reduce_memory_overheads
= TRUE
;
1306 if (config
.hash_table_size
== 0)
1307 config
.hash_table_size
= 1021;
1310 case OPTION_HASH_SIZE
:
1312 bfd_size_type new_size
;
1314 new_size
= strtoul (optarg
, NULL
, 0);
1316 config
.hash_table_size
= new_size
;
1318 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1325 lang_leave_group ();
1327 if (default_dirlist
!= NULL
)
1329 set_default_dirlist (default_dirlist
);
1330 free (default_dirlist
);
1333 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1334 /* FIXME: Should we allow emulations a chance to set this ? */
1335 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1337 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1338 /* FIXME: Should we allow emulations a chance to set this ? */
1339 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1342 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1343 library search path. */
1346 set_default_dirlist (char *dirlist_ptr
)
1352 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1355 if (*dirlist_ptr
!= '\0')
1356 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1359 dirlist_ptr
= p
+ 1;
1364 set_section_start (char *sect
, char *valstr
)
1367 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1369 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1370 lang_section_start (sect
, exp_intop (val
));
1373 /* Print help messages for the options. */
1379 const char **targets
, **pp
;
1381 printf (_("Usage: %s [options] file...\n"), program_name
);
1383 printf (_("Options:\n"));
1384 for (i
= 0; i
< OPTION_COUNT
; i
++)
1386 if (ld_options
[i
].doc
!= NULL
)
1400 if (ld_options
[j
].shortopt
!= '\0'
1401 && ld_options
[j
].control
!= NO_HELP
)
1403 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1404 len
+= (comma
? 2 : 0) + 2;
1405 if (ld_options
[j
].arg
!= NULL
)
1407 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1412 printf ("%s", _(ld_options
[j
].arg
));
1413 len
+= strlen (_(ld_options
[j
].arg
));
1419 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1424 if (ld_options
[j
].opt
.name
!= NULL
1425 && ld_options
[j
].control
!= NO_HELP
)
1428 (ld_options
[j
].control
== TWO_DASHES
1429 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1433 two_dashes
? "-" : "",
1434 ld_options
[j
].opt
.name
);
1435 len
+= ((comma
? 2 : 0)
1437 + (two_dashes
? 1 : 0)
1438 + strlen (ld_options
[j
].opt
.name
));
1439 if (ld_options
[j
].arg
!= NULL
)
1441 printf (" %s", _(ld_options
[j
].arg
));
1442 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1448 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1456 for (; len
< 30; len
++)
1459 printf ("%s\n", _(ld_options
[i
].doc
));
1463 /* Note: Various tools (such as libtool) depend upon the
1464 format of the listings below - do not change them. */
1465 /* xgettext:c-format */
1466 printf (_("%s: supported targets:"), program_name
);
1467 targets
= bfd_target_list ();
1468 for (pp
= targets
; *pp
!= NULL
; pp
++)
1469 printf (" %s", *pp
);
1473 /* xgettext:c-format */
1474 printf (_("%s: supported emulations: "), program_name
);
1475 ldemul_list_emulations (stdout
);
1478 /* xgettext:c-format */
1479 printf (_("%s: emulation specific options:\n"), program_name
);
1480 ldemul_list_emulation_options (stdout
);
1483 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);