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 set_segment_start (const char *, char *);
59 static void help (void);
61 /* Non-zero if we are processing a --defsym from the command line. */
62 int parsing_defsym
= 0;
64 /* Codes used for the long options with no short synonyms. 150 isn't
65 special; it's just an arbitrary non-ASCII char value. */
73 OPTION_DYNAMIC_LINKER
,
77 OPTION_EMBEDDED_RELOCS
,
78 OPTION_EXPORT_DYNAMIC
,
83 OPTION_NO_KEEP_MEMORY
,
84 OPTION_NO_WARN_MISMATCH
,
85 OPTION_NOINHIBIT_EXEC
,
87 OPTION_NO_WHOLE_ARCHIVE
,
90 OPTION_RETAIN_SYMBOLS_FILE
,
103 OPTION_TRADITIONAL_FORMAT
,
107 OPTION_VERSION_SCRIPT
,
108 OPTION_VERSION_EXPORTS_SECTION
,
110 OPTION_WARN_CONSTRUCTORS
,
112 OPTION_WARN_MULTIPLE_GP
,
114 OPTION_WARN_SECTION_ALIGN
,
115 OPTION_SPLIT_BY_RELOC
,
116 OPTION_SPLIT_BY_FILE
,
117 OPTION_WHOLE_ARCHIVE
,
119 OPTION_NO_ADD_NEEDED
,
123 OPTION_FORCE_EXE_SUFFIX
,
125 OPTION_NO_GC_SECTIONS
,
127 OPTION_CHECK_SECTIONS
,
128 OPTION_NO_CHECK_SECTIONS
,
132 OPTION_SECTION_START
,
135 OPTION_ALLOW_SHLIB_UNDEFINED
,
136 OPTION_NO_ALLOW_SHLIB_UNDEFINED
,
137 OPTION_ALLOW_MULTIPLE_DEFINITION
,
138 OPTION_NO_UNDEFINED_VERSION
,
139 OPTION_DEFAULT_SYMVER
,
140 OPTION_DEFAULT_IMPORTED_SYMVER
,
142 OPTION_SPARE_DYNAMIC_TAGS
,
143 OPTION_NO_DEFINE_COMMON
,
146 OPTION_STRIP_DISCARDED
,
147 OPTION_NO_STRIP_DISCARDED
,
148 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
,
149 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
,
151 OPTION_UNRESOLVED_SYMBOLS
,
152 OPTION_WARN_UNRESOLVED_SYMBOLS
,
153 OPTION_ERROR_UNRESOLVED_SYMBOLS
,
154 OPTION_WARN_SHARED_TEXTREL
,
155 OPTION_REDUCE_MEMORY_OVERHEADS
158 /* The long options. This structure is used for both the option
159 parsing and the help text. */
163 /* The long option information. */
165 /* The short option with the same meaning ('\0' if none). */
167 /* The name of the argument (NULL if none). */
169 /* The documentation string. If this is NULL, this is a synonym for
170 the previous option. */
173 /* Use one dash before long option name. */
175 /* Use two dashes before long option name. */
177 /* Only accept two dashes before the long option name.
178 This is an overloading of the use of this enum, since originally it
179 was only intended to tell the --help display function how to display
180 the long option name. This feature was added in order to resolve
181 the confusion about the -omagic command line switch. Is it setting
182 the output file name to "magic" or is it setting the NMAGIC flag on
183 the output ? It has been decided that it is setting the output file
184 name, and that if you want to set the NMAGIC flag you should use -N
187 /* Don't mention this option in --help output. */
192 static const struct ld_option ld_options
[] =
194 { {NULL
, required_argument
, NULL
, '\0'},
195 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
197 { {"architecture", required_argument
, NULL
, 'A'},
198 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
199 { {"format", required_argument
, NULL
, 'b'},
200 'b', N_("TARGET"), N_("Specify target for following input files"),
202 { {"mri-script", required_argument
, NULL
, 'c'},
203 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
204 { {"dc", no_argument
, NULL
, 'd'},
205 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
206 { {"dp", no_argument
, NULL
, 'd'},
207 '\0', NULL
, NULL
, ONE_DASH
},
208 { {"entry", required_argument
, NULL
, 'e'},
209 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
210 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
211 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
212 { {"EB", no_argument
, NULL
, OPTION_EB
},
213 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
214 { {"EL", no_argument
, NULL
, OPTION_EL
},
215 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
216 { {"auxiliary", required_argument
, NULL
, 'f'},
217 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
219 { {"filter", required_argument
, NULL
, 'F'},
220 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
222 { {NULL
, no_argument
, NULL
, '\0'},
223 'g', NULL
, N_("Ignored"), ONE_DASH
},
224 { {"gpsize", required_argument
, NULL
, 'G'},
225 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
227 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
228 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
229 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
230 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
232 { {"library", required_argument
, NULL
, 'l'},
233 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
234 { {"library-path", required_argument
, NULL
, 'L'},
235 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
237 { {"sysroot=<DIRECTORY>", required_argument
, NULL
, OPTION_SYSROOT
},
238 '\0', NULL
, N_("Override the default sysroot location"), TWO_DASHES
},
239 { {NULL
, required_argument
, NULL
, '\0'},
240 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
241 { {"print-map", no_argument
, NULL
, 'M'},
242 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
243 { {"nmagic", no_argument
, NULL
, 'n'},
244 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
245 { {"omagic", no_argument
, NULL
, 'N'},
246 'N', NULL
, N_("Do not page align data, do not make text readonly"),
247 EXACTLY_TWO_DASHES
},
248 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
249 '\0', NULL
, N_("Page align data, make text readonly"),
250 EXACTLY_TWO_DASHES
},
251 { {"output", required_argument
, NULL
, 'o'},
252 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
253 { {NULL
, required_argument
, NULL
, '\0'},
254 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
255 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
256 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
257 { {"emit-relocs", no_argument
, NULL
, 'q'},
258 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
259 { {"relocatable", no_argument
, NULL
, 'r'},
260 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
261 { {NULL
, no_argument
, NULL
, '\0'},
262 'i', NULL
, NULL
, ONE_DASH
},
263 { {"just-symbols", required_argument
, NULL
, 'R'},
264 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
266 { {"strip-all", no_argument
, NULL
, 's'},
267 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
268 { {"strip-debug", no_argument
, NULL
, 'S'},
269 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
270 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
271 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
272 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
273 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
274 { {"trace", no_argument
, NULL
, 't'},
275 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
276 { {"script", required_argument
, NULL
, 'T'},
277 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
278 { {"undefined", required_argument
, NULL
, 'u'},
279 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
281 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
282 '\0', N_("[=SECTION]"),
283 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
284 { {"Ur", no_argument
, NULL
, OPTION_UR
},
285 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
286 { {"version", no_argument
, NULL
, OPTION_VERSION
},
287 'v', NULL
, N_("Print version information"), TWO_DASHES
},
288 { {NULL
, no_argument
, NULL
, '\0'},
289 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
290 { {"discard-all", no_argument
, NULL
, 'x'},
291 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
292 { {"discard-locals", no_argument
, NULL
, 'X'},
293 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
294 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
295 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
296 { {"trace-symbol", required_argument
, NULL
, 'y'},
297 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
298 { {NULL
, required_argument
, NULL
, '\0'},
299 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
301 { {"start-group", no_argument
, NULL
, '('},
302 '(', NULL
, N_("Start a group"), TWO_DASHES
},
303 { {"end-group", no_argument
, NULL
, ')'},
304 ')', NULL
, N_("End a group"), TWO_DASHES
},
305 { {"accept-unknown-input-arch", no_argument
, NULL
,
306 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
308 N_("Accept input files whose architecture cannot be determined"),
310 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
311 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
312 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
314 { {"add-needed", no_argument
, NULL
, OPTION_ADD_NEEDED
},
315 '\0', NULL
, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
316 "\t\t\t\tfollowing dynamic libs"), TWO_DASHES
},
317 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_NEEDED
},
318 '\0', NULL
, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
319 "\t\t\t\tin following dynamic libs"), TWO_DASHES
},
320 { {"as-needed", no_argument
, NULL
, OPTION_AS_NEEDED
},
321 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
323 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_AS_NEEDED
},
324 '\0', NULL
, N_("Always set DT_NEEDED for following dynamic libs"),
326 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
327 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
328 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
329 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
330 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
331 '\0', NULL
, NULL
, ONE_DASH
},
332 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
333 '\0', NULL
, NULL
, ONE_DASH
},
334 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
335 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
336 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
337 '\0', NULL
, NULL
, ONE_DASH
},
338 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
339 '\0', NULL
, NULL
, ONE_DASH
},
340 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
341 '\0', NULL
, NULL
, ONE_DASH
},
342 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
343 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
344 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
345 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
347 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
348 '\0', NULL
, N_("Do not check section addresses for overlaps"),
350 { {"cref", no_argument
, NULL
, OPTION_CREF
},
351 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
352 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
353 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
354 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
355 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
357 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
358 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
359 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
360 '\0', NULL
, N_("Treat warnings as errors"),
362 { {"fini", required_argument
, NULL
, OPTION_FINI
},
363 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
364 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
365 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
366 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
367 '\0', NULL
, N_("Remove unused sections (on some targets)"),
369 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
370 '\0', NULL
, N_("Don't remove unused sections (default)"),
372 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
373 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
375 { {"help", no_argument
, NULL
, OPTION_HELP
},
376 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
377 { {"init", required_argument
, NULL
, OPTION_INIT
},
378 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
379 { {"Map", required_argument
, NULL
, OPTION_MAP
},
380 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
381 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
382 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
383 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
384 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
385 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
386 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
387 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
388 '\0', NULL
, N_("Do not allow unresolved references in object files"),
390 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
391 '\0', NULL
, N_("Allow unresolved references in shared libaries"),
393 { {"no-allow-shlib-undefined", no_argument
, NULL
,
394 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
395 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
397 { {"allow-multiple-definition", no_argument
, NULL
,
398 OPTION_ALLOW_MULTIPLE_DEFINITION
},
399 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
400 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
401 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
402 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
403 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
404 { {"default-imported-symver", no_argument
, NULL
,
405 OPTION_DEFAULT_IMPORTED_SYMVER
},
406 '\0', NULL
, N_("Create default symbol version for imported symbols"),
408 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
409 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
410 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
411 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
412 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
413 '\0', NULL
, N_("Create an output file even if errors occur"),
415 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
416 '\0', NULL
, NULL
, NO_HELP
},
417 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
418 '\0', NULL
, N_("Only use library directories specified on\n"
419 "\t\t\t\tthe command line"), ONE_DASH
},
420 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
421 '\0', N_("TARGET"), N_("Specify target of output file"),
422 EXACTLY_TWO_DASHES
},
423 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
424 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
425 { {"reduce-memory-overheads", no_argument
, NULL
,
426 OPTION_REDUCE_MEMORY_OVERHEADS
},
427 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
429 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
430 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
431 { {"retain-symbols-file", required_argument
, NULL
,
432 OPTION_RETAIN_SYMBOLS_FILE
},
433 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
434 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
435 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
436 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
437 '\0', N_("PATH"), N_("Set link time shared library search path"),
439 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
440 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
441 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
442 '\0', NULL
, NULL
, ONE_DASH
},
443 { {"pie", no_argument
, NULL
, OPTION_PIE
},
444 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
445 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
446 '\0', NULL
, NULL
, TWO_DASHES
},
447 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
448 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
449 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
450 '\0', NULL
, NULL
, NO_HELP
},
451 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
452 '\0', N_("name|alignment"),
453 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
454 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
455 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
457 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
458 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
460 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
461 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
463 { {"stats", no_argument
, NULL
, OPTION_STATS
},
464 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
465 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
466 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
467 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
468 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
469 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
470 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
471 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
472 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
474 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
475 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
476 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
477 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
478 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
479 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
480 { {"unresolved-symbols=<method>", required_argument
, NULL
,
481 OPTION_UNRESOLVED_SYMBOLS
},
482 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
483 "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
484 "\t\t\t\tignore-in-shared-libs"), TWO_DASHES
},
485 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
486 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
487 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
488 '\0', NULL
, NULL
, NO_HELP
},
489 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
490 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
491 { {"version-exports-section", required_argument
, NULL
,
492 OPTION_VERSION_EXPORTS_SECTION
},
493 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
494 "\t\t\t\tSYMBOL as the version."), TWO_DASHES
},
495 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
496 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
497 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
498 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
500 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
501 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
502 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
503 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
504 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
505 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
507 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_SHARED_TEXTREL
},
508 '\0', NULL
, N_("Warn if shared object has DT_TEXTREL"),
510 { {"warn-unresolved-symbols", no_argument
, NULL
,
511 OPTION_WARN_UNRESOLVED_SYMBOLS
},
512 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
513 { {"error-unresolved-symbols", no_argument
, NULL
,
514 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
515 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
516 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
517 '\0', NULL
, N_("Include all objects from following archives"),
519 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
520 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
523 #define OPTION_COUNT ARRAY_SIZE (ld_options)
526 parse_args (unsigned argc
, char **argv
)
531 char *default_dirlist
= NULL
;
533 struct option
*longopts
;
534 struct option
*really_longopts
;
536 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
538 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
539 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
540 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
542 /* Starting the short option string with '-' is for programs that
543 expect options and other ARGV-elements in any order and that care about
544 the ordering of the two. We describe each non-option ARGV-element
545 as if it were the argument of an option with character code 1. */
550 for (i
= 0; i
< OPTION_COUNT
; i
++)
552 if (ld_options
[i
].shortopt
!= '\0')
554 shortopts
[is
] = ld_options
[i
].shortopt
;
556 if (ld_options
[i
].opt
.has_arg
== required_argument
557 || ld_options
[i
].opt
.has_arg
== optional_argument
)
561 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
568 if (ld_options
[i
].opt
.name
!= NULL
)
570 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
572 really_longopts
[irl
] = ld_options
[i
].opt
;
577 longopts
[il
] = ld_options
[i
].opt
;
582 shortopts
[is
] = '\0';
583 longopts
[il
].name
= NULL
;
584 really_longopts
[irl
].name
= NULL
;
586 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
588 /* The -G option is ambiguous on different platforms. Sometimes it
589 specifies the largest data size to put into the small data
590 section. Sometimes it is equivalent to --shared. Unfortunately,
591 the first form takes an argument, while the second does not.
593 We need to permit the --shared form because on some platforms,
594 such as Solaris, gcc -shared will pass -G to the linker.
596 To permit either usage, we look through the argument list. If we
597 find -G not followed by a number, we change it into --shared.
598 This will work for most normal cases. */
599 for (i
= 1; i
< argc
; i
++)
600 if (strcmp (argv
[i
], "-G") == 0
602 || ! ISDIGIT (argv
[i
+ 1][0])))
603 argv
[i
] = (char *) "--shared";
605 /* Because we permit long options to start with a single dash, and
606 we have a --library option, and the -l option is conventionally
607 used with an immediately following argument, we can have bad
608 results if somebody tries to use -l with a library whose name
609 happens to start with "ibrary", as in -li. We avoid problems by
610 simply turning -l into --library. This means that users will
611 have to use two dashes in order to use --library, which is OK
612 since that's how it is documented.
614 FIXME: It's possible that this problem can arise for other short
615 options as well, although the user does always have the recourse
616 of adding a space between the option and the argument. */
617 for (i
= 1; i
< argc
; i
++)
619 if (argv
[i
][0] == '-'
621 && argv
[i
][2] != '\0')
625 n
= xmalloc (strlen (argv
[i
]) + 20);
626 sprintf (n
, "--library=%s", argv
[i
] + 2);
637 /* Using last_optind lets us avoid calling ldemul_parse_args
638 multiple times on a single option, which would lead to
639 confusion in the internal static variables maintained by
640 getopt. This could otherwise happen for an argument like
641 -nx, in which the -n is parsed as a single option, and we
642 loop around to pick up the -x. */
643 if (optind
!= last_optind
)
644 if (ldemul_parse_args (argc
, argv
))
647 /* getopt_long_only is like getopt_long, but '-' as well as '--'
648 can indicate a long option. */
650 last_optind
= optind
;
651 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
654 optind
= last_optind
;
655 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
658 if (ldemul_handle_option (optc
))
667 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
669 einfo (_("%P%F: use the --help option for usage information\n"));
671 case 1: /* File name. */
672 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
678 /* For HP/UX compatibility. Actually -a shared should mean
679 ``use only shared libraries'' but, then, we don't
680 currently support shared libraries on HP/UX anyhow. */
681 if (strcmp (optarg
, "archive") == 0)
682 config
.dynamic_link
= FALSE
;
683 else if (strcmp (optarg
, "shared") == 0
684 || strcmp (optarg
, "default") == 0)
685 config
.dynamic_link
= TRUE
;
687 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
690 /* FIXME: We just ignore these, but we should handle them. */
691 if (strcmp (optarg
, "definitions") == 0)
693 else if (strcmp (optarg
, "nodefinitions") == 0)
695 else if (strcmp (optarg
, "nosymbolic") == 0)
697 else if (strcmp (optarg
, "pure-text") == 0)
700 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
703 ldfile_add_arch (optarg
);
706 lang_add_target (optarg
);
709 ldfile_open_command_file (optarg
);
710 parser_input
= input_mri_script
;
713 case OPTION_CALL_SHARED
:
714 config
.dynamic_link
= TRUE
;
716 case OPTION_NON_SHARED
:
717 config
.dynamic_link
= FALSE
;
720 command_line
.cref
= TRUE
;
721 link_info
.notice_all
= TRUE
;
724 command_line
.force_common_definition
= TRUE
;
728 lex_redirect (optarg
);
729 parser_input
= input_defsym
;
735 case OPTION_DEMANGLE
:
739 enum demangling_styles style
;
741 style
= cplus_demangle_name_to_style (optarg
);
742 if (style
== unknown_demangling
)
743 einfo (_("%F%P: unknown demangling style `%s'"),
746 cplus_demangle_set_style (style
);
749 case 'I': /* Used on Solaris. */
750 case OPTION_DYNAMIC_LINKER
:
751 command_line
.interpreter
= optarg
;
754 /* Already handled in ldmain.c. */
757 command_line
.endian
= ENDIAN_BIG
;
760 command_line
.endian
= ENDIAN_LITTLE
;
762 case OPTION_EMBEDDED_RELOCS
:
763 command_line
.embedded_relocs
= TRUE
;
765 case OPTION_EXPORT_DYNAMIC
:
766 case 'E': /* HP/UX compatibility. */
767 link_info
.export_dynamic
= TRUE
;
770 lang_add_entry (optarg
, TRUE
);
773 if (command_line
.auxiliary_filters
== NULL
)
775 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
776 command_line
.auxiliary_filters
[0] = optarg
;
777 command_line
.auxiliary_filters
[1] = NULL
;
785 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
787 command_line
.auxiliary_filters
788 = xrealloc (command_line
.auxiliary_filters
,
789 (c
+ 2) * sizeof (char *));
790 command_line
.auxiliary_filters
[c
] = optarg
;
791 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
795 command_line
.filter_shlib
= optarg
;
797 case OPTION_FORCE_EXE_SUFFIX
:
798 command_line
.force_exe_suffix
= TRUE
;
803 g_switch_value
= strtoul (optarg
, &end
, 0);
805 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
811 case OPTION_GC_SECTIONS
:
812 command_line
.gc_sections
= TRUE
;
819 ldfile_add_library_path (optarg
, TRUE
);
822 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
825 config
.map_filename
= "-";
828 /* Ignore. Was handled in a pre-parse. */
831 config
.map_filename
= optarg
;
834 config
.text_read_only
= FALSE
;
835 config
.magic_demand_paged
= FALSE
;
836 config
.dynamic_link
= FALSE
;
838 case OPTION_NO_OMAGIC
:
839 config
.text_read_only
= TRUE
;
840 config
.magic_demand_paged
= TRUE
;
841 /* NB/ Does not set dynamic_link to TRUE.
842 Use --call-shared or -Bdynamic for this. */
845 config
.magic_demand_paged
= FALSE
;
846 config
.dynamic_link
= FALSE
;
848 case OPTION_NO_DEFINE_COMMON
:
849 command_line
.inhibit_common_definition
= TRUE
;
851 case OPTION_NO_DEMANGLE
:
854 case OPTION_NO_GC_SECTIONS
:
855 command_line
.gc_sections
= FALSE
;
857 case OPTION_NO_KEEP_MEMORY
:
858 link_info
.keep_memory
= FALSE
;
860 case OPTION_NO_UNDEFINED
:
861 link_info
.unresolved_syms_in_objects
862 = how_to_report_unresolved_symbols
;
864 case OPTION_ALLOW_SHLIB_UNDEFINED
:
865 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
867 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
868 link_info
.unresolved_syms_in_shared_libs
869 = how_to_report_unresolved_symbols
;
871 case OPTION_UNRESOLVED_SYMBOLS
:
872 if (strcmp (optarg
, "ignore-all") == 0)
874 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
875 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
877 else if (strcmp (optarg
, "report-all") == 0)
879 link_info
.unresolved_syms_in_objects
880 = how_to_report_unresolved_symbols
;
881 link_info
.unresolved_syms_in_shared_libs
882 = how_to_report_unresolved_symbols
;
884 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
886 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
887 link_info
.unresolved_syms_in_shared_libs
888 = how_to_report_unresolved_symbols
;
890 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
892 link_info
.unresolved_syms_in_objects
893 = how_to_report_unresolved_symbols
;
894 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
897 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
899 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
900 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
901 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
902 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
903 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
904 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
907 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
908 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
909 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
910 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
911 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
912 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
914 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
915 link_info
.allow_multiple_definition
= TRUE
;
917 case OPTION_NO_UNDEFINED_VERSION
:
918 link_info
.allow_undefined_version
= FALSE
;
920 case OPTION_DEFAULT_SYMVER
:
921 link_info
.create_default_symver
= TRUE
;
923 case OPTION_DEFAULT_IMPORTED_SYMVER
:
924 link_info
.default_imported_symver
= TRUE
;
926 case OPTION_NO_WARN_MISMATCH
:
927 command_line
.warn_mismatch
= FALSE
;
929 case OPTION_NOINHIBIT_EXEC
:
930 force_make_executable
= TRUE
;
932 case OPTION_NOSTDLIB
:
933 config
.only_cmd_line_lib_dirs
= TRUE
;
935 case OPTION_NO_WHOLE_ARCHIVE
:
936 whole_archive
= FALSE
;
939 /* FIXME "-O<non-digits> <value>" used to set the address of
940 section <non-digits>. Was this for compatibility with
941 something, or can we create a new option to do that
942 (with a syntax similar to -defsym)?
943 getopt can't handle two args to an option without kludges. */
945 /* Enable optimizations of output files. */
946 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
949 lang_add_output (optarg
, 0);
952 lang_add_output_format (optarg
, NULL
, NULL
, 0);
955 link_info
.emitrelocations
= TRUE
;
959 if (optind
== last_optind
)
960 /* This can happen if the user put "-rpath,a" on the command
961 line. (Or something similar. The comma is important).
962 Getopt becomes confused and thinks that this is a -r option
963 but it cannot parse the text after the -r so it refuses to
964 increment the optind counter. Detect this case and issue
965 an error message here. We cannot just make this a warning,
966 increment optind, and continue because getopt is too confused
967 and will seg-fault the next time around. */
968 einfo(_("%P%F: bad -rpath option\n"));
970 link_info
.relocatable
= TRUE
;
971 config
.build_constructors
= FALSE
;
972 config
.magic_demand_paged
= FALSE
;
973 config
.text_read_only
= FALSE
;
974 config
.dynamic_link
= FALSE
;
977 /* The GNU linker traditionally uses -R to mean to include
978 only the symbols from a file. The Solaris linker uses -R
979 to set the path used by the runtime linker to find
980 libraries. This is the GNU linker -rpath argument. We
981 try to support both simultaneously by checking the file
982 named. If it is a directory, rather than a regular file,
983 we assume -rpath was meant. */
987 if (stat (optarg
, &s
) >= 0
988 && ! S_ISDIR (s
.st_mode
))
990 lang_add_input_file (optarg
,
991 lang_input_file_is_symbols_only_enum
,
998 if (command_line
.rpath
== NULL
)
999 command_line
.rpath
= xstrdup (optarg
);
1002 size_t rpath_len
= strlen (command_line
.rpath
);
1003 size_t optarg_len
= strlen (optarg
);
1005 char *cp
= command_line
.rpath
;
1007 /* First see whether OPTARG is already in the path. */
1012 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
1014 if (optarg
[idx
] == '\0'
1015 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
1019 /* Not yet found. */
1020 cp
= strchr (cp
, ':');
1028 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
1029 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
1030 free (command_line
.rpath
);
1031 command_line
.rpath
= buf
;
1035 case OPTION_RPATH_LINK
:
1036 if (command_line
.rpath_link
== NULL
)
1037 command_line
.rpath_link
= xstrdup (optarg
);
1042 buf
= xmalloc (strlen (command_line
.rpath_link
)
1045 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
1046 free (command_line
.rpath_link
);
1047 command_line
.rpath_link
= buf
;
1051 command_line
.relax
= TRUE
;
1053 case OPTION_RETAIN_SYMBOLS_FILE
:
1054 add_keepsyms_file (optarg
);
1057 link_info
.strip
= strip_debugger
;
1060 link_info
.strip
= strip_all
;
1062 case OPTION_STRIP_DISCARDED
:
1063 link_info
.strip_discarded
= TRUE
;
1065 case OPTION_NO_STRIP_DISCARDED
:
1066 link_info
.strip_discarded
= FALSE
;
1069 if (config
.has_shared
)
1071 link_info
.shared
= TRUE
;
1072 /* When creating a shared library, the default
1073 behaviour is to ignore any unresolved references. */
1074 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1075 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1076 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1077 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1080 einfo (_("%P%F: -shared not supported\n"));
1083 if (config
.has_shared
)
1085 link_info
.shared
= TRUE
;
1086 link_info
.pie
= TRUE
;
1089 einfo (_("%P%F: -pie not supported\n"));
1091 case 'h': /* Used on Solaris. */
1093 command_line
.soname
= optarg
;
1095 case OPTION_SORT_COMMON
:
1096 config
.sort_common
= TRUE
;
1098 case OPTION_SORT_SECTION
:
1099 if (strcmp (optarg
, N_("name")) == 0)
1100 sort_section
= by_name
;
1101 else if (strcmp (optarg
, N_("alignment")) == 0)
1102 sort_section
= by_alignment
;
1104 einfo (_("%P%F: invalid section sorting option: %s\n"),
1108 config
.stats
= TRUE
;
1110 case OPTION_SYMBOLIC
:
1111 link_info
.symbolic
= TRUE
;
1117 ldfile_open_command_file (optarg
);
1118 parser_input
= input_script
;
1121 case OPTION_SECTION_START
:
1127 /* Check for <something>=<somthing>... */
1128 optarg2
= strchr (optarg
, '=');
1129 if (optarg2
== NULL
)
1130 einfo (_("%P%F: invalid argument to option"
1131 " \"--section-start\"\n"));
1135 /* So far so good. Are all the args present? */
1136 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1137 einfo (_("%P%F: missing argument(s) to option"
1138 " \"--section-start\"\n"));
1140 /* We must copy the section name as set_section_start
1141 doesn't do it for us. */
1142 len
= optarg2
- optarg
;
1143 sec_name
= xmalloc (len
);
1144 memcpy (sec_name
, optarg
, len
- 1);
1145 sec_name
[len
- 1] = 0;
1147 /* Then set it... */
1148 set_section_start (sec_name
, optarg2
);
1151 case OPTION_TARGET_HELP
:
1152 /* Mention any target specific options. */
1153 ldemul_list_emulation_options (stdout
);
1156 set_segment_start (".bss", optarg
);
1159 set_segment_start (".data", optarg
);
1162 set_segment_start (".text", optarg
);
1164 case OPTION_TRADITIONAL_FORMAT
:
1165 link_info
.traditional_format
= TRUE
;
1167 case OPTION_TASK_LINK
:
1168 link_info
.task_link
= TRUE
;
1169 /* Fall through - do an implied -r option. */
1171 link_info
.relocatable
= TRUE
;
1172 config
.build_constructors
= TRUE
;
1173 config
.magic_demand_paged
= FALSE
;
1174 config
.text_read_only
= FALSE
;
1175 config
.dynamic_link
= FALSE
;
1178 ldlang_add_undef (optarg
);
1182 lang_add_unique (optarg
);
1184 config
.unique_orphan_sections
= TRUE
;
1186 case OPTION_VERBOSE
:
1188 version_printed
= TRUE
;
1189 trace_file_tries
= TRUE
;
1190 overflow_cutoff_limit
= -2;
1194 version_printed
= TRUE
;
1198 version_printed
= TRUE
;
1200 case OPTION_VERSION
:
1204 case OPTION_VERSION_SCRIPT
:
1205 /* This option indicates a small script that only specifies
1206 version information. Read it, but don't assume that
1207 we've seen a linker script. */
1209 FILE *hold_script_handle
;
1211 hold_script_handle
= saved_script_handle
;
1212 ldfile_open_command_file (optarg
);
1213 saved_script_handle
= hold_script_handle
;
1214 parser_input
= input_version_script
;
1218 case OPTION_VERSION_EXPORTS_SECTION
:
1219 /* This option records a version symbol to be applied to the
1220 symbols listed for export to be found in the object files
1221 .exports sections. */
1222 command_line
.version_exports_section
= optarg
;
1224 case OPTION_WARN_COMMON
:
1225 config
.warn_common
= TRUE
;
1227 case OPTION_WARN_CONSTRUCTORS
:
1228 config
.warn_constructors
= TRUE
;
1230 case OPTION_WARN_FATAL
:
1231 config
.fatal_warnings
= TRUE
;
1233 case OPTION_WARN_MULTIPLE_GP
:
1234 config
.warn_multiple_gp
= TRUE
;
1236 case OPTION_WARN_ONCE
:
1237 config
.warn_once
= TRUE
;
1239 case OPTION_WARN_SECTION_ALIGN
:
1240 config
.warn_section_align
= TRUE
;
1242 case OPTION_WARN_SHARED_TEXTREL
:
1243 link_info
.warn_shared_textrel
= TRUE
;
1245 case OPTION_WHOLE_ARCHIVE
:
1246 whole_archive
= TRUE
;
1248 case OPTION_ADD_NEEDED
:
1251 case OPTION_NO_ADD_NEEDED
:
1254 case OPTION_AS_NEEDED
:
1257 case OPTION_NO_AS_NEEDED
:
1263 case OPTION_DISCARD_NONE
:
1264 link_info
.discard
= discard_none
;
1267 link_info
.discard
= discard_l
;
1270 link_info
.discard
= discard_all
;
1273 if (strncmp (optarg
, "P,", 2) == 0)
1275 if (default_dirlist
!= NULL
)
1276 free (default_dirlist
);
1277 default_dirlist
= xstrdup (optarg
);
1282 case OPTION_SPARE_DYNAMIC_TAGS
:
1283 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1285 case OPTION_SPLIT_BY_RELOC
:
1287 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1289 config
.split_by_reloc
= 32768;
1291 case OPTION_SPLIT_BY_FILE
:
1293 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1295 config
.split_by_file
= 1;
1297 case OPTION_CHECK_SECTIONS
:
1298 command_line
.check_section_addresses
= TRUE
;
1300 case OPTION_NO_CHECK_SECTIONS
:
1301 command_line
.check_section_addresses
= FALSE
;
1303 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1304 command_line
.accept_unknown_input_arch
= TRUE
;
1306 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1307 command_line
.accept_unknown_input_arch
= FALSE
;
1311 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1313 lang_enter_group ();
1318 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1320 lang_leave_group ();
1325 link_info
.init_function
= optarg
;
1329 link_info
.fini_function
= optarg
;
1332 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1333 command_line
.reduce_memory_overheads
= TRUE
;
1334 if (config
.hash_table_size
== 0)
1335 config
.hash_table_size
= 1021;
1338 case OPTION_HASH_SIZE
:
1340 bfd_size_type new_size
;
1342 new_size
= strtoul (optarg
, NULL
, 0);
1344 config
.hash_table_size
= new_size
;
1346 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1353 lang_leave_group ();
1355 if (default_dirlist
!= NULL
)
1357 set_default_dirlist (default_dirlist
);
1358 free (default_dirlist
);
1361 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1362 /* FIXME: Should we allow emulations a chance to set this ? */
1363 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1365 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1366 /* FIXME: Should we allow emulations a chance to set this ? */
1367 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1370 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1371 library search path. */
1374 set_default_dirlist (char *dirlist_ptr
)
1380 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1383 if (*dirlist_ptr
!= '\0')
1384 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1387 dirlist_ptr
= p
+ 1;
1392 set_section_start (char *sect
, char *valstr
)
1395 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1397 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1398 lang_section_start (sect
, exp_intop (val
), NULL
);
1402 set_segment_start (const char *section
, char *valstr
)
1408 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1410 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1411 /* If we already have an entry for this segment, update the existing
1414 for (seg
= segments
; seg
; seg
= seg
->next
)
1415 if (strcmp (seg
->name
, name
) == 0)
1420 /* There was no existing value so we must create a new segment
1422 seg
= stat_alloc (sizeof (*seg
));
1426 /* Add it to the linked list of segments. */
1427 seg
->next
= segments
;
1429 /* Historically, -Ttext and friends set the base address of a
1430 particular section. For backwards compatibility, we still do
1431 that. If a SEGMENT_START directive is seen, the section address
1432 assignment will be disabled. */
1433 lang_section_start (section
, exp_intop (val
), seg
);
1437 /* Print help messages for the options. */
1443 const char **targets
, **pp
;
1445 printf (_("Usage: %s [options] file...\n"), program_name
);
1447 printf (_("Options:\n"));
1448 for (i
= 0; i
< OPTION_COUNT
; i
++)
1450 if (ld_options
[i
].doc
!= NULL
)
1464 if (ld_options
[j
].shortopt
!= '\0'
1465 && ld_options
[j
].control
!= NO_HELP
)
1467 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1468 len
+= (comma
? 2 : 0) + 2;
1469 if (ld_options
[j
].arg
!= NULL
)
1471 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1476 printf ("%s", _(ld_options
[j
].arg
));
1477 len
+= strlen (_(ld_options
[j
].arg
));
1483 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1488 if (ld_options
[j
].opt
.name
!= NULL
1489 && ld_options
[j
].control
!= NO_HELP
)
1492 (ld_options
[j
].control
== TWO_DASHES
1493 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1497 two_dashes
? "-" : "",
1498 ld_options
[j
].opt
.name
);
1499 len
+= ((comma
? 2 : 0)
1501 + (two_dashes
? 1 : 0)
1502 + strlen (ld_options
[j
].opt
.name
));
1503 if (ld_options
[j
].arg
!= NULL
)
1505 printf (" %s", _(ld_options
[j
].arg
));
1506 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1512 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1520 for (; len
< 30; len
++)
1523 printf ("%s\n", _(ld_options
[i
].doc
));
1527 /* Note: Various tools (such as libtool) depend upon the
1528 format of the listings below - do not change them. */
1529 /* xgettext:c-format */
1530 printf (_("%s: supported targets:"), program_name
);
1531 targets
= bfd_target_list ();
1532 for (pp
= targets
; *pp
!= NULL
; pp
++)
1533 printf (" %s", *pp
);
1537 /* xgettext:c-format */
1538 printf (_("%s: supported emulations: "), program_name
);
1539 ldemul_list_emulations (stdout
);
1542 /* xgettext:c-format */
1543 printf (_("%s: emulation specific options:\n"), program_name
);
1544 ldemul_list_emulation_options (stdout
);
1547 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);