1 /* Parse options for the GNU linker.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005
4 Free Software Foundation, Inc.
6 This file is part of GLD, the Gnu Linker.
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 #include "libiberty.h"
29 #include "safe-ctype.h"
44 #ifndef PATH_SEPARATOR
45 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
46 #define PATH_SEPARATOR ';'
48 #define PATH_SEPARATOR ':'
52 /* Somewhere above, sys/stat.h got included . . . . */
53 #if !defined(S_ISDIR) && defined(S_IFDIR)
54 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
57 static void set_default_dirlist (char *);
58 static void set_section_start (char *, char *);
59 static void set_segment_start (const char *, char *);
60 static void help (void);
62 /* Non-zero if we are processing a --defsym from the command line. */
63 int parsing_defsym
= 0;
65 /* Codes used for the long options with no short synonyms. 150 isn't
66 special; it's just an arbitrary non-ASCII char value. */
74 OPTION_DYNAMIC_LINKER
,
78 OPTION_EMBEDDED_RELOCS
,
79 OPTION_EXPORT_DYNAMIC
,
84 OPTION_NO_KEEP_MEMORY
,
85 OPTION_NO_WARN_MISMATCH
,
86 OPTION_NOINHIBIT_EXEC
,
88 OPTION_NO_WHOLE_ARCHIVE
,
91 OPTION_RETAIN_SYMBOLS_FILE
,
104 OPTION_TRADITIONAL_FORMAT
,
108 OPTION_VERSION_SCRIPT
,
109 OPTION_VERSION_EXPORTS_SECTION
,
111 OPTION_WARN_CONSTRUCTORS
,
113 OPTION_WARN_MULTIPLE_GP
,
115 OPTION_WARN_SECTION_ALIGN
,
116 OPTION_SPLIT_BY_RELOC
,
117 OPTION_SPLIT_BY_FILE
,
118 OPTION_WHOLE_ARCHIVE
,
120 OPTION_NO_ADD_NEEDED
,
124 OPTION_FORCE_EXE_SUFFIX
,
126 OPTION_NO_GC_SECTIONS
,
128 OPTION_CHECK_SECTIONS
,
129 OPTION_NO_CHECK_SECTIONS
,
133 OPTION_SECTION_START
,
136 OPTION_ALLOW_SHLIB_UNDEFINED
,
137 OPTION_NO_ALLOW_SHLIB_UNDEFINED
,
138 OPTION_ALLOW_MULTIPLE_DEFINITION
,
139 OPTION_NO_UNDEFINED_VERSION
,
140 OPTION_DEFAULT_SYMVER
,
141 OPTION_DEFAULT_IMPORTED_SYMVER
,
143 OPTION_SPARE_DYNAMIC_TAGS
,
144 OPTION_NO_DEFINE_COMMON
,
147 OPTION_STRIP_DISCARDED
,
148 OPTION_NO_STRIP_DISCARDED
,
149 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
,
150 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
,
152 OPTION_UNRESOLVED_SYMBOLS
,
153 OPTION_WARN_UNRESOLVED_SYMBOLS
,
154 OPTION_ERROR_UNRESOLVED_SYMBOLS
,
155 OPTION_WARN_SHARED_TEXTREL
,
156 OPTION_REDUCE_MEMORY_OVERHEADS
159 /* The long options. This structure is used for both the option
160 parsing and the help text. */
164 /* The long option information. */
166 /* The short option with the same meaning ('\0' if none). */
168 /* The name of the argument (NULL if none). */
170 /* The documentation string. If this is NULL, this is a synonym for
171 the previous option. */
174 /* Use one dash before long option name. */
176 /* Use two dashes before long option name. */
178 /* Only accept two dashes before the long option name.
179 This is an overloading of the use of this enum, since originally it
180 was only intended to tell the --help display function how to display
181 the long option name. This feature was added in order to resolve
182 the confusion about the -omagic command line switch. Is it setting
183 the output file name to "magic" or is it setting the NMAGIC flag on
184 the output ? It has been decided that it is setting the output file
185 name, and that if you want to set the NMAGIC flag you should use -N
188 /* Don't mention this option in --help output. */
193 static const struct ld_option ld_options
[] =
195 { {NULL
, required_argument
, NULL
, '\0'},
196 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
198 { {"architecture", required_argument
, NULL
, 'A'},
199 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
200 { {"format", required_argument
, NULL
, 'b'},
201 'b', N_("TARGET"), N_("Specify target for following input files"),
203 { {"mri-script", required_argument
, NULL
, 'c'},
204 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
205 { {"dc", no_argument
, NULL
, 'd'},
206 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
207 { {"dp", no_argument
, NULL
, 'd'},
208 '\0', NULL
, NULL
, ONE_DASH
},
209 { {"entry", required_argument
, NULL
, 'e'},
210 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
211 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
212 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
213 { {"EB", no_argument
, NULL
, OPTION_EB
},
214 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
215 { {"EL", no_argument
, NULL
, OPTION_EL
},
216 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
217 { {"auxiliary", required_argument
, NULL
, 'f'},
218 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
220 { {"filter", required_argument
, NULL
, 'F'},
221 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
223 { {NULL
, no_argument
, NULL
, '\0'},
224 'g', NULL
, N_("Ignored"), ONE_DASH
},
225 { {"gpsize", required_argument
, NULL
, 'G'},
226 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
228 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
229 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
230 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
231 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
233 { {"library", required_argument
, NULL
, 'l'},
234 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
235 { {"library-path", required_argument
, NULL
, 'L'},
236 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
238 { {"sysroot=<DIRECTORY>", required_argument
, NULL
, OPTION_SYSROOT
},
239 '\0', NULL
, N_("Override the default sysroot location"), TWO_DASHES
},
240 { {NULL
, required_argument
, NULL
, '\0'},
241 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
242 { {"print-map", no_argument
, NULL
, 'M'},
243 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
244 { {"nmagic", no_argument
, NULL
, 'n'},
245 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
246 { {"omagic", no_argument
, NULL
, 'N'},
247 'N', NULL
, N_("Do not page align data, do not make text readonly"),
248 EXACTLY_TWO_DASHES
},
249 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
250 '\0', NULL
, N_("Page align data, make text readonly"),
251 EXACTLY_TWO_DASHES
},
252 { {"output", required_argument
, NULL
, 'o'},
253 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
254 { {NULL
, required_argument
, NULL
, '\0'},
255 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
256 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
257 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
258 { {"emit-relocs", no_argument
, NULL
, 'q'},
259 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
260 { {"relocatable", no_argument
, NULL
, 'r'},
261 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
262 { {NULL
, no_argument
, NULL
, '\0'},
263 'i', NULL
, NULL
, ONE_DASH
},
264 { {"just-symbols", required_argument
, NULL
, 'R'},
265 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
267 { {"strip-all", no_argument
, NULL
, 's'},
268 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
269 { {"strip-debug", no_argument
, NULL
, 'S'},
270 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
271 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
272 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
273 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
274 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
275 { {"trace", no_argument
, NULL
, 't'},
276 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
277 { {"script", required_argument
, NULL
, 'T'},
278 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
279 { {"undefined", required_argument
, NULL
, 'u'},
280 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
282 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
283 '\0', N_("[=SECTION]"),
284 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
285 { {"Ur", no_argument
, NULL
, OPTION_UR
},
286 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
287 { {"version", no_argument
, NULL
, OPTION_VERSION
},
288 'v', NULL
, N_("Print version information"), TWO_DASHES
},
289 { {NULL
, no_argument
, NULL
, '\0'},
290 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
291 { {"discard-all", no_argument
, NULL
, 'x'},
292 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
293 { {"discard-locals", no_argument
, NULL
, 'X'},
294 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
295 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
296 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
297 { {"trace-symbol", required_argument
, NULL
, 'y'},
298 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
299 { {NULL
, required_argument
, NULL
, '\0'},
300 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
302 { {"start-group", no_argument
, NULL
, '('},
303 '(', NULL
, N_("Start a group"), TWO_DASHES
},
304 { {"end-group", no_argument
, NULL
, ')'},
305 ')', NULL
, N_("End a group"), TWO_DASHES
},
306 { {"accept-unknown-input-arch", no_argument
, NULL
,
307 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
309 N_("Accept input files whose architecture cannot be determined"),
311 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
312 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
313 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
315 { {"add-needed", no_argument
, NULL
, OPTION_ADD_NEEDED
},
316 '\0', NULL
, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
317 "\t\t\t\tfollowing dynamic libs"), TWO_DASHES
},
318 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_NEEDED
},
319 '\0', NULL
, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
320 "\t\t\t\tin following dynamic libs"), TWO_DASHES
},
321 { {"as-needed", no_argument
, NULL
, OPTION_AS_NEEDED
},
322 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
324 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_AS_NEEDED
},
325 '\0', NULL
, N_("Always set DT_NEEDED for following dynamic libs"),
327 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
328 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
329 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
330 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
331 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
332 '\0', NULL
, NULL
, ONE_DASH
},
333 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
334 '\0', NULL
, NULL
, ONE_DASH
},
335 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
336 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
337 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
338 '\0', NULL
, NULL
, ONE_DASH
},
339 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
340 '\0', NULL
, NULL
, ONE_DASH
},
341 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
342 '\0', NULL
, NULL
, ONE_DASH
},
343 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
344 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
345 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
346 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
348 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
349 '\0', NULL
, N_("Do not check section addresses for overlaps"),
351 { {"cref", no_argument
, NULL
, OPTION_CREF
},
352 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
353 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
354 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
355 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
356 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
358 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
359 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
360 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
361 '\0', NULL
, N_("Treat warnings as errors"),
363 { {"fini", required_argument
, NULL
, OPTION_FINI
},
364 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
365 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
366 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
367 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
368 '\0', NULL
, N_("Remove unused sections (on some targets)"),
370 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
371 '\0', NULL
, N_("Don't remove unused sections (default)"),
373 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
374 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
376 { {"help", no_argument
, NULL
, OPTION_HELP
},
377 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
378 { {"init", required_argument
, NULL
, OPTION_INIT
},
379 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
380 { {"Map", required_argument
, NULL
, OPTION_MAP
},
381 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
382 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
383 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
384 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
385 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
386 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
387 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
388 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
389 '\0', NULL
, N_("Do not allow unresolved references in object files"),
391 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
392 '\0', NULL
, N_("Allow unresolved references in shared libaries"),
394 { {"no-allow-shlib-undefined", no_argument
, NULL
,
395 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
396 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
398 { {"allow-multiple-definition", no_argument
, NULL
,
399 OPTION_ALLOW_MULTIPLE_DEFINITION
},
400 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
401 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
402 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
403 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
404 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
405 { {"default-imported-symver", no_argument
, NULL
,
406 OPTION_DEFAULT_IMPORTED_SYMVER
},
407 '\0', NULL
, N_("Create default symbol version for imported symbols"),
409 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
410 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
411 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
412 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
413 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
414 '\0', NULL
, N_("Create an output file even if errors occur"),
416 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
417 '\0', NULL
, NULL
, NO_HELP
},
418 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
419 '\0', NULL
, N_("Only use library directories specified on\n"
420 "\t\t\t\tthe command line"), ONE_DASH
},
421 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
422 '\0', N_("TARGET"), N_("Specify target of output file"),
423 EXACTLY_TWO_DASHES
},
424 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
425 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
426 { {"reduce-memory-overheads", no_argument
, NULL
,
427 OPTION_REDUCE_MEMORY_OVERHEADS
},
428 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
430 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
431 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
432 { {"retain-symbols-file", required_argument
, NULL
,
433 OPTION_RETAIN_SYMBOLS_FILE
},
434 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
435 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
436 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
437 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
438 '\0', N_("PATH"), N_("Set link time shared library search path"),
440 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
441 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
442 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
443 '\0', NULL
, NULL
, ONE_DASH
},
444 { {"pie", no_argument
, NULL
, OPTION_PIE
},
445 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
446 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
447 '\0', NULL
, NULL
, TWO_DASHES
},
448 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
449 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
450 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
451 '\0', NULL
, NULL
, NO_HELP
},
452 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
453 '\0', N_("name|alignment"),
454 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
455 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
456 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
458 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
459 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
461 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
462 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
464 { {"stats", no_argument
, NULL
, OPTION_STATS
},
465 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
466 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
467 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
468 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
469 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
470 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
471 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
472 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
473 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
475 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
476 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
477 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
478 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
479 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
480 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
481 { {"unresolved-symbols=<method>", required_argument
, NULL
,
482 OPTION_UNRESOLVED_SYMBOLS
},
483 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
484 "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
485 "\t\t\t\tignore-in-shared-libs"), TWO_DASHES
},
486 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
487 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
488 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
489 '\0', NULL
, NULL
, NO_HELP
},
490 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
491 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
492 { {"version-exports-section", required_argument
, NULL
,
493 OPTION_VERSION_EXPORTS_SECTION
},
494 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
495 "\t\t\t\tSYMBOL as the version."), TWO_DASHES
},
496 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
497 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
498 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
499 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
501 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
502 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
503 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
504 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
505 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
506 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
508 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_SHARED_TEXTREL
},
509 '\0', NULL
, N_("Warn if shared object has DT_TEXTREL"),
511 { {"warn-unresolved-symbols", no_argument
, NULL
,
512 OPTION_WARN_UNRESOLVED_SYMBOLS
},
513 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
514 { {"error-unresolved-symbols", no_argument
, NULL
,
515 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
516 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
517 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
518 '\0', NULL
, N_("Include all objects from following archives"),
520 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
521 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
524 #define OPTION_COUNT ARRAY_SIZE (ld_options)
527 parse_args (unsigned argc
, char **argv
)
532 char *default_dirlist
= NULL
;
534 struct option
*longopts
;
535 struct option
*really_longopts
;
537 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
539 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
540 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
541 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
543 /* Starting the short option string with '-' is for programs that
544 expect options and other ARGV-elements in any order and that care about
545 the ordering of the two. We describe each non-option ARGV-element
546 as if it were the argument of an option with character code 1. */
551 for (i
= 0; i
< OPTION_COUNT
; i
++)
553 if (ld_options
[i
].shortopt
!= '\0')
555 shortopts
[is
] = ld_options
[i
].shortopt
;
557 if (ld_options
[i
].opt
.has_arg
== required_argument
558 || ld_options
[i
].opt
.has_arg
== optional_argument
)
562 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
569 if (ld_options
[i
].opt
.name
!= NULL
)
571 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
573 really_longopts
[irl
] = ld_options
[i
].opt
;
578 longopts
[il
] = ld_options
[i
].opt
;
583 shortopts
[is
] = '\0';
584 longopts
[il
].name
= NULL
;
585 really_longopts
[irl
].name
= NULL
;
587 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
589 /* The -G option is ambiguous on different platforms. Sometimes it
590 specifies the largest data size to put into the small data
591 section. Sometimes it is equivalent to --shared. Unfortunately,
592 the first form takes an argument, while the second does not.
594 We need to permit the --shared form because on some platforms,
595 such as Solaris, gcc -shared will pass -G to the linker.
597 To permit either usage, we look through the argument list. If we
598 find -G not followed by a number, we change it into --shared.
599 This will work for most normal cases. */
600 for (i
= 1; i
< argc
; i
++)
601 if (strcmp (argv
[i
], "-G") == 0
603 || ! ISDIGIT (argv
[i
+ 1][0])))
604 argv
[i
] = (char *) "--shared";
606 /* Because we permit long options to start with a single dash, and
607 we have a --library option, and the -l option is conventionally
608 used with an immediately following argument, we can have bad
609 results if somebody tries to use -l with a library whose name
610 happens to start with "ibrary", as in -li. We avoid problems by
611 simply turning -l into --library. This means that users will
612 have to use two dashes in order to use --library, which is OK
613 since that's how it is documented.
615 FIXME: It's possible that this problem can arise for other short
616 options as well, although the user does always have the recourse
617 of adding a space between the option and the argument. */
618 for (i
= 1; i
< argc
; i
++)
620 if (argv
[i
][0] == '-'
622 && argv
[i
][2] != '\0')
626 n
= xmalloc (strlen (argv
[i
]) + 20);
627 sprintf (n
, "--library=%s", argv
[i
] + 2);
638 /* Using last_optind lets us avoid calling ldemul_parse_args
639 multiple times on a single option, which would lead to
640 confusion in the internal static variables maintained by
641 getopt. This could otherwise happen for an argument like
642 -nx, in which the -n is parsed as a single option, and we
643 loop around to pick up the -x. */
644 if (optind
!= last_optind
)
645 if (ldemul_parse_args (argc
, argv
))
648 /* getopt_long_only is like getopt_long, but '-' as well as '--'
649 can indicate a long option. */
651 last_optind
= optind
;
652 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
655 optind
= last_optind
;
656 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
659 if (ldemul_handle_option (optc
))
668 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
670 einfo (_("%P%F: use the --help option for usage information\n"));
672 case 1: /* File name. */
673 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
679 /* For HP/UX compatibility. Actually -a shared should mean
680 ``use only shared libraries'' but, then, we don't
681 currently support shared libraries on HP/UX anyhow. */
682 if (strcmp (optarg
, "archive") == 0)
683 config
.dynamic_link
= FALSE
;
684 else if (strcmp (optarg
, "shared") == 0
685 || strcmp (optarg
, "default") == 0)
686 config
.dynamic_link
= TRUE
;
688 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
691 /* FIXME: We just ignore these, but we should handle them. */
692 if (strcmp (optarg
, "definitions") == 0)
694 else if (strcmp (optarg
, "nodefinitions") == 0)
696 else if (strcmp (optarg
, "nosymbolic") == 0)
698 else if (strcmp (optarg
, "pure-text") == 0)
701 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
704 ldfile_add_arch (optarg
);
707 lang_add_target (optarg
);
710 ldfile_open_command_file (optarg
);
711 parser_input
= input_mri_script
;
714 case OPTION_CALL_SHARED
:
715 config
.dynamic_link
= TRUE
;
717 case OPTION_NON_SHARED
:
718 config
.dynamic_link
= FALSE
;
721 command_line
.cref
= TRUE
;
722 link_info
.notice_all
= TRUE
;
725 command_line
.force_common_definition
= TRUE
;
729 lex_redirect (optarg
);
730 parser_input
= input_defsym
;
736 case OPTION_DEMANGLE
:
740 enum demangling_styles style
;
742 style
= cplus_demangle_name_to_style (optarg
);
743 if (style
== unknown_demangling
)
744 einfo (_("%F%P: unknown demangling style `%s'"),
747 cplus_demangle_set_style (style
);
750 case 'I': /* Used on Solaris. */
751 case OPTION_DYNAMIC_LINKER
:
752 command_line
.interpreter
= optarg
;
755 /* Already handled in ldmain.c. */
758 command_line
.endian
= ENDIAN_BIG
;
761 command_line
.endian
= ENDIAN_LITTLE
;
763 case OPTION_EMBEDDED_RELOCS
:
764 command_line
.embedded_relocs
= TRUE
;
766 case OPTION_EXPORT_DYNAMIC
:
767 case 'E': /* HP/UX compatibility. */
768 link_info
.export_dynamic
= TRUE
;
771 lang_add_entry (optarg
, TRUE
);
774 if (command_line
.auxiliary_filters
== NULL
)
776 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
777 command_line
.auxiliary_filters
[0] = optarg
;
778 command_line
.auxiliary_filters
[1] = NULL
;
786 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
788 command_line
.auxiliary_filters
789 = xrealloc (command_line
.auxiliary_filters
,
790 (c
+ 2) * sizeof (char *));
791 command_line
.auxiliary_filters
[c
] = optarg
;
792 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
796 command_line
.filter_shlib
= optarg
;
798 case OPTION_FORCE_EXE_SUFFIX
:
799 command_line
.force_exe_suffix
= TRUE
;
804 g_switch_value
= strtoul (optarg
, &end
, 0);
806 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
812 case OPTION_GC_SECTIONS
:
813 link_info
.gc_sections
= TRUE
;
820 ldfile_add_library_path (optarg
, TRUE
);
823 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
826 config
.map_filename
= "-";
829 /* Ignore. Was handled in a pre-parse. */
832 config
.map_filename
= optarg
;
835 config
.text_read_only
= FALSE
;
836 config
.magic_demand_paged
= FALSE
;
837 config
.dynamic_link
= FALSE
;
839 case OPTION_NO_OMAGIC
:
840 config
.text_read_only
= TRUE
;
841 config
.magic_demand_paged
= TRUE
;
842 /* NB/ Does not set dynamic_link to TRUE.
843 Use --call-shared or -Bdynamic for this. */
846 config
.magic_demand_paged
= FALSE
;
847 config
.dynamic_link
= FALSE
;
849 case OPTION_NO_DEFINE_COMMON
:
850 command_line
.inhibit_common_definition
= TRUE
;
852 case OPTION_NO_DEMANGLE
:
855 case OPTION_NO_GC_SECTIONS
:
856 link_info
.gc_sections
= FALSE
;
858 case OPTION_NO_KEEP_MEMORY
:
859 link_info
.keep_memory
= FALSE
;
861 case OPTION_NO_UNDEFINED
:
862 link_info
.unresolved_syms_in_objects
863 = how_to_report_unresolved_symbols
;
865 case OPTION_ALLOW_SHLIB_UNDEFINED
:
866 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
868 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
869 link_info
.unresolved_syms_in_shared_libs
870 = how_to_report_unresolved_symbols
;
872 case OPTION_UNRESOLVED_SYMBOLS
:
873 if (strcmp (optarg
, "ignore-all") == 0)
875 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
876 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
878 else if (strcmp (optarg
, "report-all") == 0)
880 link_info
.unresolved_syms_in_objects
881 = how_to_report_unresolved_symbols
;
882 link_info
.unresolved_syms_in_shared_libs
883 = how_to_report_unresolved_symbols
;
885 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
887 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
888 link_info
.unresolved_syms_in_shared_libs
889 = how_to_report_unresolved_symbols
;
891 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
893 link_info
.unresolved_syms_in_objects
894 = how_to_report_unresolved_symbols
;
895 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
898 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
900 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
901 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
902 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
903 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
904 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
905 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
908 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
909 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
910 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
911 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
912 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
913 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
915 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
916 link_info
.allow_multiple_definition
= TRUE
;
918 case OPTION_NO_UNDEFINED_VERSION
:
919 link_info
.allow_undefined_version
= FALSE
;
921 case OPTION_DEFAULT_SYMVER
:
922 link_info
.create_default_symver
= TRUE
;
924 case OPTION_DEFAULT_IMPORTED_SYMVER
:
925 link_info
.default_imported_symver
= TRUE
;
927 case OPTION_NO_WARN_MISMATCH
:
928 command_line
.warn_mismatch
= FALSE
;
930 case OPTION_NOINHIBIT_EXEC
:
931 force_make_executable
= TRUE
;
933 case OPTION_NOSTDLIB
:
934 config
.only_cmd_line_lib_dirs
= TRUE
;
936 case OPTION_NO_WHOLE_ARCHIVE
:
937 whole_archive
= FALSE
;
940 /* FIXME "-O<non-digits> <value>" used to set the address of
941 section <non-digits>. Was this for compatibility with
942 something, or can we create a new option to do that
943 (with a syntax similar to -defsym)?
944 getopt can't handle two args to an option without kludges. */
946 /* Enable optimizations of output files. */
947 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
950 lang_add_output (optarg
, 0);
953 lang_add_output_format (optarg
, NULL
, NULL
, 0);
956 link_info
.emitrelocations
= TRUE
;
960 if (optind
== last_optind
)
961 /* This can happen if the user put "-rpath,a" on the command
962 line. (Or something similar. The comma is important).
963 Getopt becomes confused and thinks that this is a -r option
964 but it cannot parse the text after the -r so it refuses to
965 increment the optind counter. Detect this case and issue
966 an error message here. We cannot just make this a warning,
967 increment optind, and continue because getopt is too confused
968 and will seg-fault the next time around. */
969 einfo(_("%P%F: bad -rpath option\n"));
971 link_info
.relocatable
= TRUE
;
972 config
.build_constructors
= FALSE
;
973 config
.magic_demand_paged
= FALSE
;
974 config
.text_read_only
= FALSE
;
975 config
.dynamic_link
= FALSE
;
978 /* The GNU linker traditionally uses -R to mean to include
979 only the symbols from a file. The Solaris linker uses -R
980 to set the path used by the runtime linker to find
981 libraries. This is the GNU linker -rpath argument. We
982 try to support both simultaneously by checking the file
983 named. If it is a directory, rather than a regular file,
984 we assume -rpath was meant. */
988 if (stat (optarg
, &s
) >= 0
989 && ! S_ISDIR (s
.st_mode
))
991 lang_add_input_file (optarg
,
992 lang_input_file_is_symbols_only_enum
,
999 if (command_line
.rpath
== NULL
)
1000 command_line
.rpath
= xstrdup (optarg
);
1003 size_t rpath_len
= strlen (command_line
.rpath
);
1004 size_t optarg_len
= strlen (optarg
);
1006 char *cp
= command_line
.rpath
;
1008 /* First see whether OPTARG is already in the path. */
1013 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
1015 if (optarg
[idx
] == '\0'
1016 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
1020 /* Not yet found. */
1021 cp
= strchr (cp
, ':');
1029 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
1030 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
1031 free (command_line
.rpath
);
1032 command_line
.rpath
= buf
;
1036 case OPTION_RPATH_LINK
:
1037 if (command_line
.rpath_link
== NULL
)
1038 command_line
.rpath_link
= xstrdup (optarg
);
1043 buf
= xmalloc (strlen (command_line
.rpath_link
)
1046 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
1047 free (command_line
.rpath_link
);
1048 command_line
.rpath_link
= buf
;
1052 command_line
.relax
= TRUE
;
1054 case OPTION_RETAIN_SYMBOLS_FILE
:
1055 add_keepsyms_file (optarg
);
1058 link_info
.strip
= strip_debugger
;
1061 link_info
.strip
= strip_all
;
1063 case OPTION_STRIP_DISCARDED
:
1064 link_info
.strip_discarded
= TRUE
;
1066 case OPTION_NO_STRIP_DISCARDED
:
1067 link_info
.strip_discarded
= FALSE
;
1070 if (config
.has_shared
)
1072 link_info
.shared
= TRUE
;
1073 /* When creating a shared library, the default
1074 behaviour is to ignore any unresolved references. */
1075 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1076 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1077 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1078 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1081 einfo (_("%P%F: -shared not supported\n"));
1084 if (config
.has_shared
)
1086 link_info
.shared
= TRUE
;
1087 link_info
.pie
= TRUE
;
1090 einfo (_("%P%F: -pie not supported\n"));
1092 case 'h': /* Used on Solaris. */
1094 command_line
.soname
= optarg
;
1096 case OPTION_SORT_COMMON
:
1097 config
.sort_common
= TRUE
;
1099 case OPTION_SORT_SECTION
:
1100 if (strcmp (optarg
, N_("name")) == 0)
1101 sort_section
= by_name
;
1102 else if (strcmp (optarg
, N_("alignment")) == 0)
1103 sort_section
= by_alignment
;
1105 einfo (_("%P%F: invalid section sorting option: %s\n"),
1109 config
.stats
= TRUE
;
1111 case OPTION_SYMBOLIC
:
1112 link_info
.symbolic
= TRUE
;
1118 ldfile_open_command_file (optarg
);
1119 parser_input
= input_script
;
1122 case OPTION_SECTION_START
:
1128 /* Check for <something>=<somthing>... */
1129 optarg2
= strchr (optarg
, '=');
1130 if (optarg2
== NULL
)
1131 einfo (_("%P%F: invalid argument to option"
1132 " \"--section-start\"\n"));
1136 /* So far so good. Are all the args present? */
1137 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1138 einfo (_("%P%F: missing argument(s) to option"
1139 " \"--section-start\"\n"));
1141 /* We must copy the section name as set_section_start
1142 doesn't do it for us. */
1143 len
= optarg2
- optarg
;
1144 sec_name
= xmalloc (len
);
1145 memcpy (sec_name
, optarg
, len
- 1);
1146 sec_name
[len
- 1] = 0;
1148 /* Then set it... */
1149 set_section_start (sec_name
, optarg2
);
1152 case OPTION_TARGET_HELP
:
1153 /* Mention any target specific options. */
1154 ldemul_list_emulation_options (stdout
);
1157 set_segment_start (".bss", optarg
);
1160 set_segment_start (".data", optarg
);
1163 set_segment_start (".text", optarg
);
1165 case OPTION_TRADITIONAL_FORMAT
:
1166 link_info
.traditional_format
= TRUE
;
1168 case OPTION_TASK_LINK
:
1169 link_info
.task_link
= TRUE
;
1170 /* Fall through - do an implied -r option. */
1172 link_info
.relocatable
= TRUE
;
1173 config
.build_constructors
= TRUE
;
1174 config
.magic_demand_paged
= FALSE
;
1175 config
.text_read_only
= FALSE
;
1176 config
.dynamic_link
= FALSE
;
1179 ldlang_add_undef (optarg
);
1183 lang_add_unique (optarg
);
1185 config
.unique_orphan_sections
= TRUE
;
1187 case OPTION_VERBOSE
:
1189 version_printed
= TRUE
;
1190 trace_file_tries
= TRUE
;
1191 overflow_cutoff_limit
= -2;
1195 version_printed
= TRUE
;
1199 version_printed
= TRUE
;
1201 case OPTION_VERSION
:
1205 case OPTION_VERSION_SCRIPT
:
1206 /* This option indicates a small script that only specifies
1207 version information. Read it, but don't assume that
1208 we've seen a linker script. */
1210 FILE *hold_script_handle
;
1212 hold_script_handle
= saved_script_handle
;
1213 ldfile_open_command_file (optarg
);
1214 saved_script_handle
= hold_script_handle
;
1215 parser_input
= input_version_script
;
1219 case OPTION_VERSION_EXPORTS_SECTION
:
1220 /* This option records a version symbol to be applied to the
1221 symbols listed for export to be found in the object files
1222 .exports sections. */
1223 command_line
.version_exports_section
= optarg
;
1225 case OPTION_WARN_COMMON
:
1226 config
.warn_common
= TRUE
;
1228 case OPTION_WARN_CONSTRUCTORS
:
1229 config
.warn_constructors
= TRUE
;
1231 case OPTION_WARN_FATAL
:
1232 config
.fatal_warnings
= TRUE
;
1234 case OPTION_WARN_MULTIPLE_GP
:
1235 config
.warn_multiple_gp
= TRUE
;
1237 case OPTION_WARN_ONCE
:
1238 config
.warn_once
= TRUE
;
1240 case OPTION_WARN_SECTION_ALIGN
:
1241 config
.warn_section_align
= TRUE
;
1243 case OPTION_WARN_SHARED_TEXTREL
:
1244 link_info
.warn_shared_textrel
= TRUE
;
1246 case OPTION_WHOLE_ARCHIVE
:
1247 whole_archive
= TRUE
;
1249 case OPTION_ADD_NEEDED
:
1252 case OPTION_NO_ADD_NEEDED
:
1255 case OPTION_AS_NEEDED
:
1258 case OPTION_NO_AS_NEEDED
:
1264 case OPTION_DISCARD_NONE
:
1265 link_info
.discard
= discard_none
;
1268 link_info
.discard
= discard_l
;
1271 link_info
.discard
= discard_all
;
1274 if (strncmp (optarg
, "P,", 2) == 0)
1276 if (default_dirlist
!= NULL
)
1277 free (default_dirlist
);
1278 default_dirlist
= xstrdup (optarg
);
1283 case OPTION_SPARE_DYNAMIC_TAGS
:
1284 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1286 case OPTION_SPLIT_BY_RELOC
:
1288 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1290 config
.split_by_reloc
= 32768;
1292 case OPTION_SPLIT_BY_FILE
:
1294 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1296 config
.split_by_file
= 1;
1298 case OPTION_CHECK_SECTIONS
:
1299 command_line
.check_section_addresses
= TRUE
;
1301 case OPTION_NO_CHECK_SECTIONS
:
1302 command_line
.check_section_addresses
= FALSE
;
1304 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1305 command_line
.accept_unknown_input_arch
= TRUE
;
1307 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1308 command_line
.accept_unknown_input_arch
= FALSE
;
1312 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1314 lang_enter_group ();
1319 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1321 lang_leave_group ();
1326 link_info
.init_function
= optarg
;
1330 link_info
.fini_function
= optarg
;
1333 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1334 command_line
.reduce_memory_overheads
= TRUE
;
1335 if (config
.hash_table_size
== 0)
1336 config
.hash_table_size
= 1021;
1339 case OPTION_HASH_SIZE
:
1341 bfd_size_type new_size
;
1343 new_size
= strtoul (optarg
, NULL
, 0);
1345 config
.hash_table_size
= new_size
;
1347 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1354 lang_leave_group ();
1356 if (default_dirlist
!= NULL
)
1358 set_default_dirlist (default_dirlist
);
1359 free (default_dirlist
);
1362 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1363 /* FIXME: Should we allow emulations a chance to set this ? */
1364 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1366 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1367 /* FIXME: Should we allow emulations a chance to set this ? */
1368 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1371 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1372 library search path. */
1375 set_default_dirlist (char *dirlist_ptr
)
1381 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1384 if (*dirlist_ptr
!= '\0')
1385 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1388 dirlist_ptr
= p
+ 1;
1393 set_section_start (char *sect
, char *valstr
)
1396 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1398 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1399 lang_section_start (sect
, exp_intop (val
), NULL
);
1403 set_segment_start (const char *section
, char *valstr
)
1409 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1411 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1412 /* If we already have an entry for this segment, update the existing
1415 for (seg
= segments
; seg
; seg
= seg
->next
)
1416 if (strcmp (seg
->name
, name
) == 0)
1421 /* There was no existing value so we must create a new segment
1423 seg
= stat_alloc (sizeof (*seg
));
1427 /* Add it to the linked list of segments. */
1428 seg
->next
= segments
;
1430 /* Historically, -Ttext and friends set the base address of a
1431 particular section. For backwards compatibility, we still do
1432 that. If a SEGMENT_START directive is seen, the section address
1433 assignment will be disabled. */
1434 lang_section_start (section
, exp_intop (val
), seg
);
1438 /* Print help messages for the options. */
1444 const char **targets
, **pp
;
1446 printf (_("Usage: %s [options] file...\n"), program_name
);
1448 printf (_("Options:\n"));
1449 for (i
= 0; i
< OPTION_COUNT
; i
++)
1451 if (ld_options
[i
].doc
!= NULL
)
1465 if (ld_options
[j
].shortopt
!= '\0'
1466 && ld_options
[j
].control
!= NO_HELP
)
1468 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1469 len
+= (comma
? 2 : 0) + 2;
1470 if (ld_options
[j
].arg
!= NULL
)
1472 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1477 printf ("%s", _(ld_options
[j
].arg
));
1478 len
+= strlen (_(ld_options
[j
].arg
));
1484 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1489 if (ld_options
[j
].opt
.name
!= NULL
1490 && ld_options
[j
].control
!= NO_HELP
)
1493 (ld_options
[j
].control
== TWO_DASHES
1494 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1498 two_dashes
? "-" : "",
1499 ld_options
[j
].opt
.name
);
1500 len
+= ((comma
? 2 : 0)
1502 + (two_dashes
? 1 : 0)
1503 + strlen (ld_options
[j
].opt
.name
));
1504 if (ld_options
[j
].arg
!= NULL
)
1506 printf (" %s", _(ld_options
[j
].arg
));
1507 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1513 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1521 for (; len
< 30; len
++)
1524 printf ("%s\n", _(ld_options
[i
].doc
));
1528 /* Note: Various tools (such as libtool) depend upon the
1529 format of the listings below - do not change them. */
1530 /* xgettext:c-format */
1531 printf (_("%s: supported targets:"), program_name
);
1532 targets
= bfd_target_list ();
1533 for (pp
= targets
; *pp
!= NULL
; pp
++)
1534 printf (" %s", *pp
);
1538 /* xgettext:c-format */
1539 printf (_("%s: supported emulations: "), program_name
);
1540 ldemul_list_emulations (stdout
);
1543 /* xgettext:c-format */
1544 printf (_("%s: emulation specific options:\n"), program_name
);
1545 ldemul_list_emulation_options (stdout
);
1548 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);