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
,
137 OPTION_DEFAULT_SYMVER
,
139 OPTION_SPARE_DYNAMIC_TAGS
,
140 OPTION_NO_DEFINE_COMMON
,
143 OPTION_STRIP_DISCARDED
,
144 OPTION_NO_STRIP_DISCARDED
,
145 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
,
146 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
,
148 OPTION_UNRESOLVED_SYMBOLS
,
149 OPTION_WARN_UNRESOLVED_SYMBOLS
,
150 OPTION_ERROR_UNRESOLVED_SYMBOLS
,
151 OPTION_WARN_SHARED_TEXTREL
,
152 OPTION_REDUCE_MEMORY_OVERHEADS
155 /* The long options. This structure is used for both the option
156 parsing and the help text. */
160 /* The long option information. */
162 /* The short option with the same meaning ('\0' if none). */
164 /* The name of the argument (NULL if none). */
166 /* The documentation string. If this is NULL, this is a synonym for
167 the previous option. */
170 /* Use one dash before long option name. */
172 /* Use two dashes before long option name. */
174 /* Only accept two dashes before the long option name.
175 This is an overloading of the use of this enum, since originally it
176 was only intended to tell the --help display function how to display
177 the long option name. This feature was added in order to resolve
178 the confusion about the -omagic command line switch. Is it setting
179 the output file name to "magic" or is it setting the NMAGIC flag on
180 the output ? It has been decided that it is setting the output file
181 name, and that if you want to set the NMAGIC flag you should use -N
184 /* Don't mention this option in --help output. */
189 static const struct ld_option ld_options
[] =
191 { {NULL
, required_argument
, NULL
, '\0'},
192 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
194 { {"architecture", required_argument
, NULL
, 'A'},
195 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
196 { {"format", required_argument
, NULL
, 'b'},
197 'b', N_("TARGET"), N_("Specify target for following input files"),
199 { {"mri-script", required_argument
, NULL
, 'c'},
200 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
201 { {"dc", no_argument
, NULL
, 'd'},
202 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
203 { {"dp", no_argument
, NULL
, 'd'},
204 '\0', NULL
, NULL
, ONE_DASH
},
205 { {"entry", required_argument
, NULL
, 'e'},
206 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
207 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
208 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
209 { {"EB", no_argument
, NULL
, OPTION_EB
},
210 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
211 { {"EL", no_argument
, NULL
, OPTION_EL
},
212 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
213 { {"auxiliary", required_argument
, NULL
, 'f'},
214 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
216 { {"filter", required_argument
, NULL
, 'F'},
217 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
219 { {NULL
, no_argument
, NULL
, '\0'},
220 'g', NULL
, N_("Ignored"), ONE_DASH
},
221 { {"gpsize", required_argument
, NULL
, 'G'},
222 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
224 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
225 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
226 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
227 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
229 { {"library", required_argument
, NULL
, 'l'},
230 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
231 { {"library-path", required_argument
, NULL
, 'L'},
232 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
234 { {NULL
, required_argument
, NULL
, '\0'},
235 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
236 { {"print-map", no_argument
, NULL
, 'M'},
237 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
238 { {"nmagic", no_argument
, NULL
, 'n'},
239 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
240 { {"omagic", no_argument
, NULL
, 'N'},
241 'N', NULL
, N_("Do not page align data, do not make text readonly"),
242 EXACTLY_TWO_DASHES
},
243 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
244 '\0', NULL
, N_("Page align data, make text readonly"),
245 EXACTLY_TWO_DASHES
},
246 { {"output", required_argument
, NULL
, 'o'},
247 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
248 { {NULL
, required_argument
, NULL
, '\0'},
249 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
250 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
251 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
252 { {"emit-relocs", no_argument
, NULL
, 'q'},
253 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
254 { {"relocatable", no_argument
, NULL
, 'r'},
255 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
256 { {NULL
, no_argument
, NULL
, '\0'},
257 'i', NULL
, NULL
, ONE_DASH
},
258 { {"just-symbols", required_argument
, NULL
, 'R'},
259 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
261 { {"strip-all", no_argument
, NULL
, 's'},
262 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
263 { {"strip-debug", no_argument
, NULL
, 'S'},
264 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
265 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
266 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
267 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
268 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
269 { {"trace", no_argument
, NULL
, 't'},
270 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
271 { {"script", required_argument
, NULL
, 'T'},
272 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
273 { {"undefined", required_argument
, NULL
, 'u'},
274 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
276 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
277 '\0', N_("[=SECTION]"),
278 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
279 { {"Ur", no_argument
, NULL
, OPTION_UR
},
280 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
281 { {"version", no_argument
, NULL
, OPTION_VERSION
},
282 'v', NULL
, N_("Print version information"), TWO_DASHES
},
283 { {NULL
, no_argument
, NULL
, '\0'},
284 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
285 { {"discard-all", no_argument
, NULL
, 'x'},
286 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
287 { {"discard-locals", no_argument
, NULL
, 'X'},
288 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
289 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
290 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
291 { {"trace-symbol", required_argument
, NULL
, 'y'},
292 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
293 { {NULL
, required_argument
, NULL
, '\0'},
294 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
296 { {"start-group", no_argument
, NULL
, '('},
297 '(', NULL
, N_("Start a group"), TWO_DASHES
},
298 { {"end-group", no_argument
, NULL
, ')'},
299 ')', NULL
, N_("End a group"), TWO_DASHES
},
300 { {"accept-unknown-input-arch", no_argument
, NULL
,
301 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
303 N_("Accept input files whose architecture cannot be determined"),
305 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
306 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
307 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
309 { {"add-needed", no_argument
, NULL
, OPTION_ADD_NEEDED
},
310 '\0', NULL
, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
311 "\t\t\t\tfollowing dynamic libs"), TWO_DASHES
},
312 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_NEEDED
},
313 '\0', NULL
, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
314 "\t\t\t\tin following dynamic libs"), TWO_DASHES
},
315 { {"as-needed", no_argument
, NULL
, OPTION_AS_NEEDED
},
316 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
318 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_AS_NEEDED
},
319 '\0', NULL
, N_("Always set DT_NEEDED for following dynamic libs"),
321 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
322 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
323 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
324 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
325 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
326 '\0', NULL
, NULL
, ONE_DASH
},
327 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
328 '\0', NULL
, NULL
, ONE_DASH
},
329 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
330 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
331 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
332 '\0', NULL
, NULL
, ONE_DASH
},
333 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
334 '\0', NULL
, NULL
, ONE_DASH
},
335 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
336 '\0', NULL
, NULL
, ONE_DASH
},
337 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
338 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
339 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
340 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
342 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
343 '\0', NULL
, N_("Do not check section addresses for overlaps"),
345 { {"cref", no_argument
, NULL
, OPTION_CREF
},
346 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
347 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
348 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
349 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
350 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
352 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
353 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
354 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
355 '\0', NULL
, N_("Treat warnings as errors"),
357 { {"fini", required_argument
, NULL
, OPTION_FINI
},
358 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
359 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
360 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
361 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
362 '\0', NULL
, N_("Remove unused sections (on some targets)"),
364 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
365 '\0', NULL
, N_("Don't remove unused sections (default)"),
367 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
368 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
370 { {"help", no_argument
, NULL
, OPTION_HELP
},
371 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
372 { {"init", required_argument
, NULL
, OPTION_INIT
},
373 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
374 { {"Map", required_argument
, NULL
, OPTION_MAP
},
375 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
376 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
377 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
378 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
379 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
380 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
381 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
382 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
383 '\0', NULL
, N_("Do not allow unresolved references in object files"),
385 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
386 '\0', NULL
, N_("Allow unresolved references in shared libaries"),
388 { {"no-allow-shlib-undefined", no_argument
, NULL
,
389 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
390 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
392 { {"allow-multiple-definition", no_argument
, NULL
,
393 OPTION_ALLOW_MULTIPLE_DEFINITION
},
394 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
395 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
396 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
397 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
398 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
399 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
400 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
401 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
402 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
403 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
404 '\0', NULL
, N_("Create an output file even if errors occur"),
406 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
407 '\0', NULL
, NULL
, NO_HELP
},
408 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
409 '\0', NULL
, N_("Only use library directories specified on\n"
410 "\t\t\t\tthe command line"), ONE_DASH
},
411 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
412 '\0', N_("TARGET"), N_("Specify target of output file"),
413 EXACTLY_TWO_DASHES
},
414 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
415 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
416 { {"reduce-memory-overheads", no_argument
, NULL
,
417 OPTION_REDUCE_MEMORY_OVERHEADS
},
418 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
420 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
421 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
422 { {"retain-symbols-file", required_argument
, NULL
,
423 OPTION_RETAIN_SYMBOLS_FILE
},
424 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
425 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
426 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
427 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
428 '\0', N_("PATH"), N_("Set link time shared library search path"),
430 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
431 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
432 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
433 '\0', NULL
, NULL
, ONE_DASH
},
434 { {"pie", no_argument
, NULL
, OPTION_PIE
},
435 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
436 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
437 '\0', NULL
, NULL
, TWO_DASHES
},
438 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
439 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
440 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
441 '\0', NULL
, NULL
, NO_HELP
},
442 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
443 '\0', N_("name|alignment"),
444 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
445 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
446 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
448 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
449 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
451 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
452 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
454 { {"stats", no_argument
, NULL
, OPTION_STATS
},
455 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
456 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
457 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
458 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
459 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
460 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
461 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
462 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
463 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
465 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
466 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
467 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
468 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
469 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
470 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
471 { {"unresolved-symbols=<method>", required_argument
, NULL
,
472 OPTION_UNRESOLVED_SYMBOLS
},
473 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
474 "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
475 "\t\t\t\tignore-in-shared-libs"), TWO_DASHES
},
476 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
477 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
478 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
479 '\0', NULL
, NULL
, NO_HELP
},
480 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
481 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
482 { {"version-exports-section", required_argument
, NULL
,
483 OPTION_VERSION_EXPORTS_SECTION
},
484 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
485 "\t\t\t\tSYMBOL as the version."), TWO_DASHES
},
486 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
487 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
488 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
489 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
491 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
492 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
493 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
494 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
495 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
496 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
498 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_SHARED_TEXTREL
},
499 '\0', NULL
, N_("Warn if shared object has DT_TEXTREL"),
501 { {"warn-unresolved-symbols", no_argument
, NULL
,
502 OPTION_WARN_UNRESOLVED_SYMBOLS
},
503 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
504 { {"error-unresolved-symbols", no_argument
, NULL
,
505 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
506 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
507 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
508 '\0', NULL
, N_("Include all objects from following archives"),
510 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
511 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
514 #define OPTION_COUNT ARRAY_SIZE (ld_options)
517 parse_args (unsigned argc
, char **argv
)
522 char *default_dirlist
= NULL
;
524 struct option
*longopts
;
525 struct option
*really_longopts
;
527 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
529 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
530 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
531 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
533 /* Starting the short option string with '-' is for programs that
534 expect options and other ARGV-elements in any order and that care about
535 the ordering of the two. We describe each non-option ARGV-element
536 as if it were the argument of an option with character code 1. */
541 for (i
= 0; i
< OPTION_COUNT
; i
++)
543 if (ld_options
[i
].shortopt
!= '\0')
545 shortopts
[is
] = ld_options
[i
].shortopt
;
547 if (ld_options
[i
].opt
.has_arg
== required_argument
548 || ld_options
[i
].opt
.has_arg
== optional_argument
)
552 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
559 if (ld_options
[i
].opt
.name
!= NULL
)
561 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
563 really_longopts
[irl
] = ld_options
[i
].opt
;
568 longopts
[il
] = ld_options
[i
].opt
;
573 shortopts
[is
] = '\0';
574 longopts
[il
].name
= NULL
;
575 really_longopts
[irl
].name
= NULL
;
577 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
579 /* The -G option is ambiguous on different platforms. Sometimes it
580 specifies the largest data size to put into the small data
581 section. Sometimes it is equivalent to --shared. Unfortunately,
582 the first form takes an argument, while the second does not.
584 We need to permit the --shared form because on some platforms,
585 such as Solaris, gcc -shared will pass -G to the linker.
587 To permit either usage, we look through the argument list. If we
588 find -G not followed by a number, we change it into --shared.
589 This will work for most normal cases. */
590 for (i
= 1; i
< argc
; i
++)
591 if (strcmp (argv
[i
], "-G") == 0
593 || ! ISDIGIT (argv
[i
+ 1][0])))
594 argv
[i
] = (char *) "--shared";
596 /* Because we permit long options to start with a single dash, and
597 we have a --library option, and the -l option is conventionally
598 used with an immediately following argument, we can have bad
599 results if somebody tries to use -l with a library whose name
600 happens to start with "ibrary", as in -li. We avoid problems by
601 simply turning -l into --library. This means that users will
602 have to use two dashes in order to use --library, which is OK
603 since that's how it is documented.
605 FIXME: It's possible that this problem can arise for other short
606 options as well, although the user does always have the recourse
607 of adding a space between the option and the argument. */
608 for (i
= 1; i
< argc
; i
++)
610 if (argv
[i
][0] == '-'
612 && argv
[i
][2] != '\0')
616 n
= xmalloc (strlen (argv
[i
]) + 20);
617 sprintf (n
, "--library=%s", argv
[i
] + 2);
628 /* Using last_optind lets us avoid calling ldemul_parse_args
629 multiple times on a single option, which would lead to
630 confusion in the internal static variables maintained by
631 getopt. This could otherwise happen for an argument like
632 -nx, in which the -n is parsed as a single option, and we
633 loop around to pick up the -x. */
634 if (optind
!= last_optind
)
635 if (ldemul_parse_args (argc
, argv
))
638 /* getopt_long_only is like getopt_long, but '-' as well as '--'
639 can indicate a long option. */
641 last_optind
= optind
;
642 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
645 optind
= last_optind
;
646 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
649 if (ldemul_handle_option (optc
))
658 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
660 einfo (_("%P%F: use the --help option for usage information\n"));
662 case 1: /* File name. */
663 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
669 /* For HP/UX compatibility. Actually -a shared should mean
670 ``use only shared libraries'' but, then, we don't
671 currently support shared libraries on HP/UX anyhow. */
672 if (strcmp (optarg
, "archive") == 0)
673 config
.dynamic_link
= FALSE
;
674 else if (strcmp (optarg
, "shared") == 0
675 || strcmp (optarg
, "default") == 0)
676 config
.dynamic_link
= TRUE
;
678 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
681 /* FIXME: We just ignore these, but we should handle them. */
682 if (strcmp (optarg
, "definitions") == 0)
684 else if (strcmp (optarg
, "nodefinitions") == 0)
686 else if (strcmp (optarg
, "nosymbolic") == 0)
688 else if (strcmp (optarg
, "pure-text") == 0)
691 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
694 ldfile_add_arch (optarg
);
697 lang_add_target (optarg
);
700 ldfile_open_command_file (optarg
);
701 parser_input
= input_mri_script
;
704 case OPTION_CALL_SHARED
:
705 config
.dynamic_link
= TRUE
;
707 case OPTION_NON_SHARED
:
708 config
.dynamic_link
= FALSE
;
711 command_line
.cref
= TRUE
;
712 link_info
.notice_all
= TRUE
;
715 command_line
.force_common_definition
= TRUE
;
719 lex_redirect (optarg
);
720 parser_input
= input_defsym
;
726 case OPTION_DEMANGLE
:
730 enum demangling_styles style
;
732 style
= cplus_demangle_name_to_style (optarg
);
733 if (style
== unknown_demangling
)
734 einfo (_("%F%P: unknown demangling style `%s'"),
737 cplus_demangle_set_style (style
);
740 case 'I': /* Used on Solaris. */
741 case OPTION_DYNAMIC_LINKER
:
742 command_line
.interpreter
= optarg
;
745 command_line
.endian
= ENDIAN_BIG
;
748 command_line
.endian
= ENDIAN_LITTLE
;
750 case OPTION_EMBEDDED_RELOCS
:
751 command_line
.embedded_relocs
= TRUE
;
753 case OPTION_EXPORT_DYNAMIC
:
754 case 'E': /* HP/UX compatibility. */
755 link_info
.export_dynamic
= TRUE
;
758 lang_add_entry (optarg
, TRUE
);
761 if (command_line
.auxiliary_filters
== NULL
)
763 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
764 command_line
.auxiliary_filters
[0] = optarg
;
765 command_line
.auxiliary_filters
[1] = NULL
;
773 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
775 command_line
.auxiliary_filters
776 = xrealloc (command_line
.auxiliary_filters
,
777 (c
+ 2) * sizeof (char *));
778 command_line
.auxiliary_filters
[c
] = optarg
;
779 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
783 command_line
.filter_shlib
= optarg
;
785 case OPTION_FORCE_EXE_SUFFIX
:
786 command_line
.force_exe_suffix
= TRUE
;
791 g_switch_value
= strtoul (optarg
, &end
, 0);
793 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
799 case OPTION_GC_SECTIONS
:
800 command_line
.gc_sections
= TRUE
;
807 ldfile_add_library_path (optarg
, TRUE
);
810 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
813 config
.map_filename
= "-";
816 /* Ignore. Was handled in a pre-parse. */
819 config
.map_filename
= optarg
;
822 config
.text_read_only
= FALSE
;
823 config
.magic_demand_paged
= FALSE
;
824 config
.dynamic_link
= FALSE
;
826 case OPTION_NO_OMAGIC
:
827 config
.text_read_only
= TRUE
;
828 config
.magic_demand_paged
= TRUE
;
829 /* NB/ Does not set dynamic_link to TRUE.
830 Use --call-shared or -Bdynamic for this. */
833 config
.magic_demand_paged
= FALSE
;
834 config
.dynamic_link
= FALSE
;
836 case OPTION_NO_DEFINE_COMMON
:
837 command_line
.inhibit_common_definition
= TRUE
;
839 case OPTION_NO_DEMANGLE
:
842 case OPTION_NO_GC_SECTIONS
:
843 command_line
.gc_sections
= FALSE
;
845 case OPTION_NO_KEEP_MEMORY
:
846 link_info
.keep_memory
= FALSE
;
848 case OPTION_NO_UNDEFINED
:
849 link_info
.unresolved_syms_in_objects
850 = how_to_report_unresolved_symbols
;
852 case OPTION_ALLOW_SHLIB_UNDEFINED
:
853 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
855 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
856 link_info
.unresolved_syms_in_shared_libs
857 = how_to_report_unresolved_symbols
;
859 case OPTION_UNRESOLVED_SYMBOLS
:
860 if (strcmp (optarg
, "ignore-all") == 0)
862 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
863 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
865 else if (strcmp (optarg
, "report-all") == 0)
867 link_info
.unresolved_syms_in_objects
868 = how_to_report_unresolved_symbols
;
869 link_info
.unresolved_syms_in_shared_libs
870 = how_to_report_unresolved_symbols
;
872 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
874 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
875 link_info
.unresolved_syms_in_shared_libs
876 = how_to_report_unresolved_symbols
;
878 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
880 link_info
.unresolved_syms_in_objects
881 = how_to_report_unresolved_symbols
;
882 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
885 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
887 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
888 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
889 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
890 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
891 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
892 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
895 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
896 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
897 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
898 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
899 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
900 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
902 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
903 link_info
.allow_multiple_definition
= TRUE
;
905 case OPTION_NO_UNDEFINED_VERSION
:
906 link_info
.allow_undefined_version
= FALSE
;
908 case OPTION_DEFAULT_SYMVER
:
909 link_info
.create_default_symver
= TRUE
;
911 case OPTION_NO_WARN_MISMATCH
:
912 command_line
.warn_mismatch
= FALSE
;
914 case OPTION_NOINHIBIT_EXEC
:
915 force_make_executable
= TRUE
;
917 case OPTION_NOSTDLIB
:
918 config
.only_cmd_line_lib_dirs
= TRUE
;
920 case OPTION_NO_WHOLE_ARCHIVE
:
921 whole_archive
= FALSE
;
924 /* FIXME "-O<non-digits> <value>" used to set the address of
925 section <non-digits>. Was this for compatibility with
926 something, or can we create a new option to do that
927 (with a syntax similar to -defsym)?
928 getopt can't handle two args to an option without kludges. */
930 /* Enable optimizations of output files. */
931 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
934 lang_add_output (optarg
, 0);
937 lang_add_output_format (optarg
, NULL
, NULL
, 0);
940 link_info
.emitrelocations
= TRUE
;
944 if (optind
== last_optind
)
945 /* This can happen if the user put "-rpath,a" on the command
946 line. (Or something similar. The comma is important).
947 Getopt becomes confused and thinks that this is a -r option
948 but it cannot parse the text after the -r so it refuses to
949 increment the optind counter. Detect this case and issue
950 an error message here. We cannot just make this a warning,
951 increment optind, and continue because getopt is too confused
952 and will seg-fault the next time around. */
953 einfo(_("%P%F: bad -rpath option\n"));
955 link_info
.relocatable
= TRUE
;
956 config
.build_constructors
= FALSE
;
957 config
.magic_demand_paged
= FALSE
;
958 config
.text_read_only
= FALSE
;
959 config
.dynamic_link
= FALSE
;
962 /* The GNU linker traditionally uses -R to mean to include
963 only the symbols from a file. The Solaris linker uses -R
964 to set the path used by the runtime linker to find
965 libraries. This is the GNU linker -rpath argument. We
966 try to support both simultaneously by checking the file
967 named. If it is a directory, rather than a regular file,
968 we assume -rpath was meant. */
972 if (stat (optarg
, &s
) >= 0
973 && ! S_ISDIR (s
.st_mode
))
975 lang_add_input_file (optarg
,
976 lang_input_file_is_symbols_only_enum
,
983 if (command_line
.rpath
== NULL
)
984 command_line
.rpath
= xstrdup (optarg
);
987 size_t rpath_len
= strlen (command_line
.rpath
);
988 size_t optarg_len
= strlen (optarg
);
990 char *cp
= command_line
.rpath
;
992 /* First see whether OPTARG is already in the path. */
997 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
999 if (optarg
[idx
] == '\0'
1000 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
1004 /* Not yet found. */
1005 cp
= strchr (cp
, ':');
1013 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
1014 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
1015 free (command_line
.rpath
);
1016 command_line
.rpath
= buf
;
1020 case OPTION_RPATH_LINK
:
1021 if (command_line
.rpath_link
== NULL
)
1022 command_line
.rpath_link
= xstrdup (optarg
);
1027 buf
= xmalloc (strlen (command_line
.rpath_link
)
1030 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
1031 free (command_line
.rpath_link
);
1032 command_line
.rpath_link
= buf
;
1036 command_line
.relax
= TRUE
;
1038 case OPTION_RETAIN_SYMBOLS_FILE
:
1039 add_keepsyms_file (optarg
);
1042 link_info
.strip
= strip_debugger
;
1045 link_info
.strip
= strip_all
;
1047 case OPTION_STRIP_DISCARDED
:
1048 link_info
.strip_discarded
= TRUE
;
1050 case OPTION_NO_STRIP_DISCARDED
:
1051 link_info
.strip_discarded
= FALSE
;
1054 if (config
.has_shared
)
1056 link_info
.shared
= TRUE
;
1057 /* When creating a shared library, the default
1058 behaviour is to ignore any unresolved references. */
1059 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1060 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1061 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1062 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1065 einfo (_("%P%F: -shared not supported\n"));
1068 if (config
.has_shared
)
1070 link_info
.shared
= TRUE
;
1071 link_info
.pie
= TRUE
;
1074 einfo (_("%P%F: -pie not supported\n"));
1076 case 'h': /* Used on Solaris. */
1078 command_line
.soname
= optarg
;
1080 case OPTION_SORT_COMMON
:
1081 config
.sort_common
= TRUE
;
1083 case OPTION_SORT_SECTION
:
1084 if (strcmp (optarg
, N_("name")) == 0)
1085 sort_section
= by_name
;
1086 else if (strcmp (optarg
, N_("alignment")) == 0)
1087 sort_section
= by_alignment
;
1089 einfo (_("%P%F: invalid section sorting option: %s\n"),
1093 config
.stats
= TRUE
;
1095 case OPTION_SYMBOLIC
:
1096 link_info
.symbolic
= TRUE
;
1102 ldfile_open_command_file (optarg
);
1103 parser_input
= input_script
;
1106 case OPTION_SECTION_START
:
1112 /* Check for <something>=<somthing>... */
1113 optarg2
= strchr (optarg
, '=');
1114 if (optarg2
== NULL
)
1115 einfo (_("%P%F: invalid argument to option"
1116 " \"--section-start\"\n"));
1120 /* So far so good. Are all the args present? */
1121 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1122 einfo (_("%P%F: missing argument(s) to option"
1123 " \"--section-start\"\n"));
1125 /* We must copy the section name as set_section_start
1126 doesn't do it for us. */
1127 len
= optarg2
- optarg
;
1128 sec_name
= xmalloc (len
);
1129 memcpy (sec_name
, optarg
, len
- 1);
1130 sec_name
[len
- 1] = 0;
1132 /* Then set it... */
1133 set_section_start (sec_name
, optarg2
);
1136 case OPTION_TARGET_HELP
:
1137 /* Mention any target specific options. */
1138 ldemul_list_emulation_options (stdout
);
1141 set_section_start (".bss", optarg
);
1144 set_section_start (".data", optarg
);
1147 set_section_start (".text", optarg
);
1149 case OPTION_TRADITIONAL_FORMAT
:
1150 link_info
.traditional_format
= TRUE
;
1152 case OPTION_TASK_LINK
:
1153 link_info
.task_link
= TRUE
;
1154 /* Fall through - do an implied -r option. */
1156 link_info
.relocatable
= TRUE
;
1157 config
.build_constructors
= TRUE
;
1158 config
.magic_demand_paged
= FALSE
;
1159 config
.text_read_only
= FALSE
;
1160 config
.dynamic_link
= FALSE
;
1163 ldlang_add_undef (optarg
);
1167 lang_add_unique (optarg
);
1169 config
.unique_orphan_sections
= TRUE
;
1171 case OPTION_VERBOSE
:
1173 version_printed
= TRUE
;
1174 trace_file_tries
= TRUE
;
1175 overflow_cutoff_limit
= -2;
1179 version_printed
= TRUE
;
1183 version_printed
= TRUE
;
1185 case OPTION_VERSION
:
1189 case OPTION_VERSION_SCRIPT
:
1190 /* This option indicates a small script that only specifies
1191 version information. Read it, but don't assume that
1192 we've seen a linker script. */
1194 FILE *hold_script_handle
;
1196 hold_script_handle
= saved_script_handle
;
1197 ldfile_open_command_file (optarg
);
1198 saved_script_handle
= hold_script_handle
;
1199 parser_input
= input_version_script
;
1203 case OPTION_VERSION_EXPORTS_SECTION
:
1204 /* This option records a version symbol to be applied to the
1205 symbols listed for export to be found in the object files
1206 .exports sections. */
1207 command_line
.version_exports_section
= optarg
;
1209 case OPTION_WARN_COMMON
:
1210 config
.warn_common
= TRUE
;
1212 case OPTION_WARN_CONSTRUCTORS
:
1213 config
.warn_constructors
= TRUE
;
1215 case OPTION_WARN_FATAL
:
1216 config
.fatal_warnings
= TRUE
;
1218 case OPTION_WARN_MULTIPLE_GP
:
1219 config
.warn_multiple_gp
= TRUE
;
1221 case OPTION_WARN_ONCE
:
1222 config
.warn_once
= TRUE
;
1224 case OPTION_WARN_SECTION_ALIGN
:
1225 config
.warn_section_align
= TRUE
;
1227 case OPTION_WARN_SHARED_TEXTREL
:
1228 link_info
.warn_shared_textrel
= TRUE
;
1230 case OPTION_WHOLE_ARCHIVE
:
1231 whole_archive
= TRUE
;
1233 case OPTION_ADD_NEEDED
:
1236 case OPTION_NO_ADD_NEEDED
:
1239 case OPTION_AS_NEEDED
:
1242 case OPTION_NO_AS_NEEDED
:
1248 case OPTION_DISCARD_NONE
:
1249 link_info
.discard
= discard_none
;
1252 link_info
.discard
= discard_l
;
1255 link_info
.discard
= discard_all
;
1258 if (strncmp (optarg
, "P,", 2) == 0)
1260 if (default_dirlist
!= NULL
)
1261 free (default_dirlist
);
1262 default_dirlist
= xstrdup (optarg
);
1267 case OPTION_SPARE_DYNAMIC_TAGS
:
1268 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1270 case OPTION_SPLIT_BY_RELOC
:
1272 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1274 config
.split_by_reloc
= 32768;
1276 case OPTION_SPLIT_BY_FILE
:
1278 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1280 config
.split_by_file
= 1;
1282 case OPTION_CHECK_SECTIONS
:
1283 command_line
.check_section_addresses
= TRUE
;
1285 case OPTION_NO_CHECK_SECTIONS
:
1286 command_line
.check_section_addresses
= FALSE
;
1288 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1289 command_line
.accept_unknown_input_arch
= TRUE
;
1291 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1292 command_line
.accept_unknown_input_arch
= FALSE
;
1296 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1298 lang_enter_group ();
1303 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1305 lang_leave_group ();
1310 link_info
.init_function
= optarg
;
1314 link_info
.fini_function
= optarg
;
1317 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1318 command_line
.reduce_memory_overheads
= TRUE
;
1319 if (config
.hash_table_size
== 0)
1320 config
.hash_table_size
= 1021;
1323 case OPTION_HASH_SIZE
:
1325 bfd_size_type new_size
;
1327 new_size
= strtoul (optarg
, NULL
, 0);
1329 config
.hash_table_size
= new_size
;
1331 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1338 lang_leave_group ();
1340 if (default_dirlist
!= NULL
)
1342 set_default_dirlist (default_dirlist
);
1343 free (default_dirlist
);
1346 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1347 /* FIXME: Should we allow emulations a chance to set this ? */
1348 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1350 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1351 /* FIXME: Should we allow emulations a chance to set this ? */
1352 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1355 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1356 library search path. */
1359 set_default_dirlist (char *dirlist_ptr
)
1365 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1368 if (*dirlist_ptr
!= '\0')
1369 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1372 dirlist_ptr
= p
+ 1;
1377 set_section_start (char *sect
, char *valstr
)
1380 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1382 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1383 lang_section_start (sect
, exp_intop (val
));
1386 /* Print help messages for the options. */
1392 const char **targets
, **pp
;
1394 printf (_("Usage: %s [options] file...\n"), program_name
);
1396 printf (_("Options:\n"));
1397 for (i
= 0; i
< OPTION_COUNT
; i
++)
1399 if (ld_options
[i
].doc
!= NULL
)
1413 if (ld_options
[j
].shortopt
!= '\0'
1414 && ld_options
[j
].control
!= NO_HELP
)
1416 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1417 len
+= (comma
? 2 : 0) + 2;
1418 if (ld_options
[j
].arg
!= NULL
)
1420 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1425 printf ("%s", _(ld_options
[j
].arg
));
1426 len
+= strlen (_(ld_options
[j
].arg
));
1432 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1437 if (ld_options
[j
].opt
.name
!= NULL
1438 && ld_options
[j
].control
!= NO_HELP
)
1441 (ld_options
[j
].control
== TWO_DASHES
1442 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1446 two_dashes
? "-" : "",
1447 ld_options
[j
].opt
.name
);
1448 len
+= ((comma
? 2 : 0)
1450 + (two_dashes
? 1 : 0)
1451 + strlen (ld_options
[j
].opt
.name
));
1452 if (ld_options
[j
].arg
!= NULL
)
1454 printf (" %s", _(ld_options
[j
].arg
));
1455 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1461 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1469 for (; len
< 30; len
++)
1472 printf ("%s\n", _(ld_options
[i
].doc
));
1476 /* Note: Various tools (such as libtool) depend upon the
1477 format of the listings below - do not change them. */
1478 /* xgettext:c-format */
1479 printf (_("%s: supported targets:"), program_name
);
1480 targets
= bfd_target_list ();
1481 for (pp
= targets
; *pp
!= NULL
; pp
++)
1482 printf (" %s", *pp
);
1486 /* xgettext:c-format */
1487 printf (_("%s: supported emulations: "), program_name
);
1488 ldemul_list_emulations (stdout
);
1491 /* xgettext:c-format */
1492 printf (_("%s: emulation specific options:\n"), program_name
);
1493 ldemul_list_emulation_options (stdout
);
1496 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);