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
,
76 OPTION_EMBEDDED_RELOCS
,
77 OPTION_EXPORT_DYNAMIC
,
82 OPTION_NO_KEEP_MEMORY
,
83 OPTION_NO_WARN_MISMATCH
,
84 OPTION_NOINHIBIT_EXEC
,
86 OPTION_NO_WHOLE_ARCHIVE
,
89 OPTION_RETAIN_SYMBOLS_FILE
,
102 OPTION_TRADITIONAL_FORMAT
,
106 OPTION_VERSION_SCRIPT
,
107 OPTION_VERSION_EXPORTS_SECTION
,
109 OPTION_WARN_CONSTRUCTORS
,
111 OPTION_WARN_MULTIPLE_GP
,
113 OPTION_WARN_SECTION_ALIGN
,
114 OPTION_SPLIT_BY_RELOC
,
115 OPTION_SPLIT_BY_FILE
,
116 OPTION_WHOLE_ARCHIVE
,
118 OPTION_NO_ADD_NEEDED
,
122 OPTION_FORCE_EXE_SUFFIX
,
124 OPTION_NO_GC_SECTIONS
,
126 OPTION_CHECK_SECTIONS
,
127 OPTION_NO_CHECK_SECTIONS
,
131 OPTION_SECTION_START
,
134 OPTION_ALLOW_SHLIB_UNDEFINED
,
135 OPTION_NO_ALLOW_SHLIB_UNDEFINED
,
136 OPTION_ALLOW_MULTIPLE_DEFINITION
,
137 OPTION_NO_UNDEFINED_VERSION
,
138 OPTION_DEFAULT_SYMVER
,
140 OPTION_SPARE_DYNAMIC_TAGS
,
141 OPTION_NO_DEFINE_COMMON
,
144 OPTION_STRIP_DISCARDED
,
145 OPTION_NO_STRIP_DISCARDED
,
146 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
,
147 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
,
149 OPTION_UNRESOLVED_SYMBOLS
,
150 OPTION_WARN_UNRESOLVED_SYMBOLS
,
151 OPTION_ERROR_UNRESOLVED_SYMBOLS
,
152 OPTION_WARN_SHARED_TEXTREL
,
153 OPTION_REDUCE_MEMORY_OVERHEADS
156 /* The long options. This structure is used for both the option
157 parsing and the help text. */
161 /* The long option information. */
163 /* The short option with the same meaning ('\0' if none). */
165 /* The name of the argument (NULL if none). */
167 /* The documentation string. If this is NULL, this is a synonym for
168 the previous option. */
171 /* Use one dash before long option name. */
173 /* Use two dashes before long option name. */
175 /* Only accept two dashes before the long option name.
176 This is an overloading of the use of this enum, since originally it
177 was only intended to tell the --help display function how to display
178 the long option name. This feature was added in order to resolve
179 the confusion about the -omagic command line switch. Is it setting
180 the output file name to "magic" or is it setting the NMAGIC flag on
181 the output ? It has been decided that it is setting the output file
182 name, and that if you want to set the NMAGIC flag you should use -N
185 /* Don't mention this option in --help output. */
190 static const struct ld_option ld_options
[] =
192 { {NULL
, required_argument
, NULL
, '\0'},
193 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
195 { {"architecture", required_argument
, NULL
, 'A'},
196 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
197 { {"format", required_argument
, NULL
, 'b'},
198 'b', N_("TARGET"), N_("Specify target for following input files"),
200 { {"mri-script", required_argument
, NULL
, 'c'},
201 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
202 { {"dc", no_argument
, NULL
, 'd'},
203 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
204 { {"dp", no_argument
, NULL
, 'd'},
205 '\0', NULL
, NULL
, ONE_DASH
},
206 { {"entry", required_argument
, NULL
, 'e'},
207 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
208 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
209 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
210 { {"EB", no_argument
, NULL
, OPTION_EB
},
211 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
212 { {"EL", no_argument
, NULL
, OPTION_EL
},
213 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
214 { {"auxiliary", required_argument
, NULL
, 'f'},
215 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
217 { {"filter", required_argument
, NULL
, 'F'},
218 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
220 { {NULL
, no_argument
, NULL
, '\0'},
221 'g', NULL
, N_("Ignored"), ONE_DASH
},
222 { {"gpsize", required_argument
, NULL
, 'G'},
223 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
225 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
226 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
227 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
228 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
230 { {"library", required_argument
, NULL
, 'l'},
231 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
232 { {"library-path", required_argument
, NULL
, 'L'},
233 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
235 { {NULL
, required_argument
, NULL
, '\0'},
236 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
237 { {"print-map", no_argument
, NULL
, 'M'},
238 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
239 { {"nmagic", no_argument
, NULL
, 'n'},
240 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
241 { {"omagic", no_argument
, NULL
, 'N'},
242 'N', NULL
, N_("Do not page align data, do not make text readonly"),
243 EXACTLY_TWO_DASHES
},
244 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
245 '\0', NULL
, N_("Page align data, make text readonly"),
246 EXACTLY_TWO_DASHES
},
247 { {"output", required_argument
, NULL
, 'o'},
248 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
249 { {NULL
, required_argument
, NULL
, '\0'},
250 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
251 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
252 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
253 { {"emit-relocs", no_argument
, NULL
, 'q'},
254 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
255 { {"relocatable", no_argument
, NULL
, 'r'},
256 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
257 { {NULL
, no_argument
, NULL
, '\0'},
258 'i', NULL
, NULL
, ONE_DASH
},
259 { {"just-symbols", required_argument
, NULL
, 'R'},
260 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
262 { {"strip-all", no_argument
, NULL
, 's'},
263 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
264 { {"strip-debug", no_argument
, NULL
, 'S'},
265 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
266 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
267 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
268 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
269 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
270 { {"trace", no_argument
, NULL
, 't'},
271 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
272 { {"script", required_argument
, NULL
, 'T'},
273 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
274 { {"undefined", required_argument
, NULL
, 'u'},
275 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
277 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
278 '\0', N_("[=SECTION]"),
279 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
280 { {"Ur", no_argument
, NULL
, OPTION_UR
},
281 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
282 { {"version", no_argument
, NULL
, OPTION_VERSION
},
283 'v', NULL
, N_("Print version information"), TWO_DASHES
},
284 { {NULL
, no_argument
, NULL
, '\0'},
285 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
286 { {"discard-all", no_argument
, NULL
, 'x'},
287 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
288 { {"discard-locals", no_argument
, NULL
, 'X'},
289 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
290 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
291 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
292 { {"trace-symbol", required_argument
, NULL
, 'y'},
293 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
294 { {NULL
, required_argument
, NULL
, '\0'},
295 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
297 { {"start-group", no_argument
, NULL
, '('},
298 '(', NULL
, N_("Start a group"), TWO_DASHES
},
299 { {"end-group", no_argument
, NULL
, ')'},
300 ')', NULL
, N_("End a group"), TWO_DASHES
},
301 { {"accept-unknown-input-arch", no_argument
, NULL
,
302 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
304 N_("Accept input files whose architecture cannot be determined"),
306 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
307 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
308 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
310 { {"add-needed", no_argument
, NULL
, OPTION_ADD_NEEDED
},
311 '\0', NULL
, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
312 "\t\t\t\tfollowing dynamic libs"), TWO_DASHES
},
313 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_NEEDED
},
314 '\0', NULL
, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
315 "\t\t\t\tin following dynamic libs"), TWO_DASHES
},
316 { {"as-needed", no_argument
, NULL
, OPTION_AS_NEEDED
},
317 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
319 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_AS_NEEDED
},
320 '\0', NULL
, N_("Always set DT_NEEDED for following dynamic libs"),
322 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
323 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
324 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
325 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
326 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
327 '\0', NULL
, NULL
, ONE_DASH
},
328 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
329 '\0', NULL
, NULL
, ONE_DASH
},
330 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
331 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
332 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
333 '\0', NULL
, NULL
, ONE_DASH
},
334 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
335 '\0', NULL
, NULL
, ONE_DASH
},
336 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
337 '\0', NULL
, NULL
, ONE_DASH
},
338 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
339 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
340 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
341 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
343 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
344 '\0', NULL
, N_("Do not check section addresses for overlaps"),
346 { {"cref", no_argument
, NULL
, OPTION_CREF
},
347 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
348 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
349 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
350 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
351 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
353 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
354 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
355 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
356 '\0', NULL
, N_("Treat warnings as errors"),
358 { {"fini", required_argument
, NULL
, OPTION_FINI
},
359 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
360 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
361 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
362 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
363 '\0', NULL
, N_("Remove unused sections (on some targets)"),
365 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
366 '\0', NULL
, N_("Don't remove unused sections (default)"),
368 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
369 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
371 { {"help", no_argument
, NULL
, OPTION_HELP
},
372 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
373 { {"init", required_argument
, NULL
, OPTION_INIT
},
374 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
375 { {"Map", required_argument
, NULL
, OPTION_MAP
},
376 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
377 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
378 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
379 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
380 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
381 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
382 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
383 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
384 '\0', NULL
, N_("Do not allow unresolved references in object files"),
386 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
387 '\0', NULL
, N_("Allow unresolved references in shared libaries"),
389 { {"no-allow-shlib-undefined", no_argument
, NULL
,
390 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
391 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
393 { {"allow-multiple-definition", no_argument
, NULL
,
394 OPTION_ALLOW_MULTIPLE_DEFINITION
},
395 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
396 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
397 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
398 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
399 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
400 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
401 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
402 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
403 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
404 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
405 '\0', NULL
, N_("Create an output file even if errors occur"),
407 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
408 '\0', NULL
, NULL
, NO_HELP
},
409 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
410 '\0', NULL
, N_("Only use library directories specified on\n"
411 "\t\t\t\tthe command line"), ONE_DASH
},
412 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
413 '\0', N_("TARGET"), N_("Specify target of output file"),
414 EXACTLY_TWO_DASHES
},
415 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
416 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
417 { {"reduce-memory-overheads", no_argument
, NULL
,
418 OPTION_REDUCE_MEMORY_OVERHEADS
},
419 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
421 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
422 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
423 { {"retain-symbols-file", required_argument
, NULL
,
424 OPTION_RETAIN_SYMBOLS_FILE
},
425 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
426 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
427 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
428 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
429 '\0', N_("PATH"), N_("Set link time shared library search path"),
431 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
432 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
433 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
434 '\0', NULL
, NULL
, ONE_DASH
},
435 { {"pie", no_argument
, NULL
, OPTION_PIE
},
436 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
437 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
438 '\0', NULL
, NULL
, TWO_DASHES
},
439 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
440 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
441 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
442 '\0', NULL
, NULL
, NO_HELP
},
443 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
444 '\0', N_("name|alignment"),
445 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
446 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
447 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
449 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
450 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
452 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
453 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
455 { {"stats", no_argument
, NULL
, OPTION_STATS
},
456 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
457 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
458 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
459 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
460 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
461 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
462 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
463 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
464 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
466 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
467 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
468 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
469 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
470 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
471 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
472 { {"unresolved-symbols=<method>", required_argument
, NULL
,
473 OPTION_UNRESOLVED_SYMBOLS
},
474 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
475 "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
476 "\t\t\t\tignore-in-shared-libs"), TWO_DASHES
},
477 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
478 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
479 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
480 '\0', NULL
, NULL
, NO_HELP
},
481 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
482 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
483 { {"version-exports-section", required_argument
, NULL
,
484 OPTION_VERSION_EXPORTS_SECTION
},
485 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
486 "\t\t\t\tSYMBOL as the version."), TWO_DASHES
},
487 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
488 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
489 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
490 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
492 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
493 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
494 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
495 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
496 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
497 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
499 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_SHARED_TEXTREL
},
500 '\0', NULL
, N_("Warn if shared object has DT_TEXTREL"),
502 { {"warn-unresolved-symbols", no_argument
, NULL
,
503 OPTION_WARN_UNRESOLVED_SYMBOLS
},
504 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
505 { {"error-unresolved-symbols", no_argument
, NULL
,
506 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
507 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
508 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
509 '\0', NULL
, N_("Include all objects from following archives"),
511 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
512 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
515 #define OPTION_COUNT ARRAY_SIZE (ld_options)
518 parse_args (unsigned argc
, char **argv
)
523 char *default_dirlist
= NULL
;
525 struct option
*longopts
;
526 struct option
*really_longopts
;
528 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
530 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
531 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
532 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
534 /* Starting the short option string with '-' is for programs that
535 expect options and other ARGV-elements in any order and that care about
536 the ordering of the two. We describe each non-option ARGV-element
537 as if it were the argument of an option with character code 1. */
542 for (i
= 0; i
< OPTION_COUNT
; i
++)
544 if (ld_options
[i
].shortopt
!= '\0')
546 shortopts
[is
] = ld_options
[i
].shortopt
;
548 if (ld_options
[i
].opt
.has_arg
== required_argument
549 || ld_options
[i
].opt
.has_arg
== optional_argument
)
553 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
560 if (ld_options
[i
].opt
.name
!= NULL
)
562 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
564 really_longopts
[irl
] = ld_options
[i
].opt
;
569 longopts
[il
] = ld_options
[i
].opt
;
574 shortopts
[is
] = '\0';
575 longopts
[il
].name
= NULL
;
576 really_longopts
[irl
].name
= NULL
;
578 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
580 /* The -G option is ambiguous on different platforms. Sometimes it
581 specifies the largest data size to put into the small data
582 section. Sometimes it is equivalent to --shared. Unfortunately,
583 the first form takes an argument, while the second does not.
585 We need to permit the --shared form because on some platforms,
586 such as Solaris, gcc -shared will pass -G to the linker.
588 To permit either usage, we look through the argument list. If we
589 find -G not followed by a number, we change it into --shared.
590 This will work for most normal cases. */
591 for (i
= 1; i
< argc
; i
++)
592 if (strcmp (argv
[i
], "-G") == 0
594 || ! ISDIGIT (argv
[i
+ 1][0])))
595 argv
[i
] = (char *) "--shared";
597 /* Because we permit long options to start with a single dash, and
598 we have a --library option, and the -l option is conventionally
599 used with an immediately following argument, we can have bad
600 results if somebody tries to use -l with a library whose name
601 happens to start with "ibrary", as in -li. We avoid problems by
602 simply turning -l into --library. This means that users will
603 have to use two dashes in order to use --library, which is OK
604 since that's how it is documented.
606 FIXME: It's possible that this problem can arise for other short
607 options as well, although the user does always have the recourse
608 of adding a space between the option and the argument. */
609 for (i
= 1; i
< argc
; i
++)
611 if (argv
[i
][0] == '-'
613 && argv
[i
][2] != '\0')
617 n
= xmalloc (strlen (argv
[i
]) + 20);
618 sprintf (n
, "--library=%s", argv
[i
] + 2);
629 /* Using last_optind lets us avoid calling ldemul_parse_args
630 multiple times on a single option, which would lead to
631 confusion in the internal static variables maintained by
632 getopt. This could otherwise happen for an argument like
633 -nx, in which the -n is parsed as a single option, and we
634 loop around to pick up the -x. */
635 if (optind
!= last_optind
)
636 if (ldemul_parse_args (argc
, argv
))
639 /* getopt_long_only is like getopt_long, but '-' as well as '--'
640 can indicate a long option. */
642 last_optind
= optind
;
643 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
646 optind
= last_optind
;
647 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
650 if (ldemul_handle_option (optc
))
659 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
661 einfo (_("%P%F: use the --help option for usage information\n"));
663 case 1: /* File name. */
664 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
670 /* For HP/UX compatibility. Actually -a shared should mean
671 ``use only shared libraries'' but, then, we don't
672 currently support shared libraries on HP/UX anyhow. */
673 if (strcmp (optarg
, "archive") == 0)
674 config
.dynamic_link
= FALSE
;
675 else if (strcmp (optarg
, "shared") == 0
676 || strcmp (optarg
, "default") == 0)
677 config
.dynamic_link
= TRUE
;
679 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
682 /* FIXME: We just ignore these, but we should handle them. */
683 if (strcmp (optarg
, "definitions") == 0)
685 else if (strcmp (optarg
, "nodefinitions") == 0)
687 else if (strcmp (optarg
, "nosymbolic") == 0)
689 else if (strcmp (optarg
, "pure-text") == 0)
692 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
695 ldfile_add_arch (optarg
);
698 lang_add_target (optarg
);
701 ldfile_open_command_file (optarg
);
702 parser_input
= input_mri_script
;
705 case OPTION_CALL_SHARED
:
706 config
.dynamic_link
= TRUE
;
708 case OPTION_NON_SHARED
:
709 config
.dynamic_link
= FALSE
;
712 command_line
.cref
= TRUE
;
713 link_info
.notice_all
= TRUE
;
716 command_line
.force_common_definition
= TRUE
;
720 lex_redirect (optarg
);
721 parser_input
= input_defsym
;
727 case OPTION_DEMANGLE
:
731 enum demangling_styles style
;
733 style
= cplus_demangle_name_to_style (optarg
);
734 if (style
== unknown_demangling
)
735 einfo (_("%F%P: unknown demangling style `%s'"),
738 cplus_demangle_set_style (style
);
741 case 'I': /* Used on Solaris. */
742 case OPTION_DYNAMIC_LINKER
:
743 command_line
.interpreter
= optarg
;
746 command_line
.endian
= ENDIAN_BIG
;
749 command_line
.endian
= ENDIAN_LITTLE
;
751 case OPTION_EMBEDDED_RELOCS
:
752 command_line
.embedded_relocs
= TRUE
;
754 case OPTION_EXPORT_DYNAMIC
:
755 case 'E': /* HP/UX compatibility. */
756 link_info
.export_dynamic
= TRUE
;
759 lang_add_entry (optarg
, TRUE
);
762 if (command_line
.auxiliary_filters
== NULL
)
764 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
765 command_line
.auxiliary_filters
[0] = optarg
;
766 command_line
.auxiliary_filters
[1] = NULL
;
774 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
776 command_line
.auxiliary_filters
777 = xrealloc (command_line
.auxiliary_filters
,
778 (c
+ 2) * sizeof (char *));
779 command_line
.auxiliary_filters
[c
] = optarg
;
780 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
784 command_line
.filter_shlib
= optarg
;
786 case OPTION_FORCE_EXE_SUFFIX
:
787 command_line
.force_exe_suffix
= TRUE
;
792 g_switch_value
= strtoul (optarg
, &end
, 0);
794 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
800 case OPTION_GC_SECTIONS
:
801 command_line
.gc_sections
= TRUE
;
808 ldfile_add_library_path (optarg
, TRUE
);
811 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
814 config
.map_filename
= "-";
817 /* Ignore. Was handled in a pre-parse. */
820 config
.map_filename
= optarg
;
823 config
.text_read_only
= FALSE
;
824 config
.magic_demand_paged
= FALSE
;
825 config
.dynamic_link
= FALSE
;
827 case OPTION_NO_OMAGIC
:
828 config
.text_read_only
= TRUE
;
829 config
.magic_demand_paged
= TRUE
;
830 /* NB/ Does not set dynamic_link to TRUE.
831 Use --call-shared or -Bdynamic for this. */
834 config
.magic_demand_paged
= FALSE
;
835 config
.dynamic_link
= FALSE
;
837 case OPTION_NO_DEFINE_COMMON
:
838 command_line
.inhibit_common_definition
= TRUE
;
840 case OPTION_NO_DEMANGLE
:
843 case OPTION_NO_GC_SECTIONS
:
844 command_line
.gc_sections
= FALSE
;
846 case OPTION_NO_KEEP_MEMORY
:
847 link_info
.keep_memory
= FALSE
;
849 case OPTION_NO_UNDEFINED
:
850 link_info
.unresolved_syms_in_objects
851 = how_to_report_unresolved_symbols
;
853 case OPTION_ALLOW_SHLIB_UNDEFINED
:
854 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
856 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
857 link_info
.unresolved_syms_in_shared_libs
858 = how_to_report_unresolved_symbols
;
860 case OPTION_UNRESOLVED_SYMBOLS
:
861 if (strcmp (optarg
, "ignore-all") == 0)
863 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
864 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
866 else if (strcmp (optarg
, "report-all") == 0)
868 link_info
.unresolved_syms_in_objects
869 = how_to_report_unresolved_symbols
;
870 link_info
.unresolved_syms_in_shared_libs
871 = how_to_report_unresolved_symbols
;
873 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
875 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
876 link_info
.unresolved_syms_in_shared_libs
877 = how_to_report_unresolved_symbols
;
879 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
881 link_info
.unresolved_syms_in_objects
882 = how_to_report_unresolved_symbols
;
883 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
886 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
888 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
889 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
890 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
891 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
892 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
893 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
896 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
897 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
898 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
899 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
900 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
901 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
903 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
904 link_info
.allow_multiple_definition
= TRUE
;
906 case OPTION_NO_UNDEFINED_VERSION
:
907 link_info
.allow_undefined_version
= FALSE
;
909 case OPTION_DEFAULT_SYMVER
:
910 link_info
.create_default_symver
= TRUE
;
912 case OPTION_NO_WARN_MISMATCH
:
913 command_line
.warn_mismatch
= FALSE
;
915 case OPTION_NOINHIBIT_EXEC
:
916 force_make_executable
= TRUE
;
918 case OPTION_NOSTDLIB
:
919 config
.only_cmd_line_lib_dirs
= TRUE
;
921 case OPTION_NO_WHOLE_ARCHIVE
:
922 whole_archive
= FALSE
;
925 /* FIXME "-O<non-digits> <value>" used to set the address of
926 section <non-digits>. Was this for compatibility with
927 something, or can we create a new option to do that
928 (with a syntax similar to -defsym)?
929 getopt can't handle two args to an option without kludges. */
931 /* Enable optimizations of output files. */
932 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
935 lang_add_output (optarg
, 0);
938 lang_add_output_format (optarg
, NULL
, NULL
, 0);
941 link_info
.emitrelocations
= TRUE
;
945 if (optind
== last_optind
)
946 /* This can happen if the user put "-rpath,a" on the command
947 line. (Or something similar. The comma is important).
948 Getopt becomes confused and thinks that this is a -r option
949 but it cannot parse the text after the -r so it refuses to
950 increment the optind counter. Detect this case and issue
951 an error message here. We cannot just make this a warning,
952 increment optind, and continue because getopt is too confused
953 and will seg-fault the next time around. */
954 einfo(_("%P%F: bad -rpath option\n"));
956 link_info
.relocatable
= TRUE
;
957 config
.build_constructors
= FALSE
;
958 config
.magic_demand_paged
= FALSE
;
959 config
.text_read_only
= FALSE
;
960 config
.dynamic_link
= FALSE
;
963 /* The GNU linker traditionally uses -R to mean to include
964 only the symbols from a file. The Solaris linker uses -R
965 to set the path used by the runtime linker to find
966 libraries. This is the GNU linker -rpath argument. We
967 try to support both simultaneously by checking the file
968 named. If it is a directory, rather than a regular file,
969 we assume -rpath was meant. */
973 if (stat (optarg
, &s
) >= 0
974 && ! S_ISDIR (s
.st_mode
))
976 lang_add_input_file (optarg
,
977 lang_input_file_is_symbols_only_enum
,
984 if (command_line
.rpath
== NULL
)
985 command_line
.rpath
= xstrdup (optarg
);
988 size_t rpath_len
= strlen (command_line
.rpath
);
989 size_t optarg_len
= strlen (optarg
);
991 char *cp
= command_line
.rpath
;
993 /* First see whether OPTARG is already in the path. */
998 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
1000 if (optarg
[idx
] == '\0'
1001 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
1005 /* Not yet found. */
1006 cp
= strchr (cp
, ':');
1014 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
1015 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
1016 free (command_line
.rpath
);
1017 command_line
.rpath
= buf
;
1021 case OPTION_RPATH_LINK
:
1022 if (command_line
.rpath_link
== NULL
)
1023 command_line
.rpath_link
= xstrdup (optarg
);
1028 buf
= xmalloc (strlen (command_line
.rpath_link
)
1031 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
1032 free (command_line
.rpath_link
);
1033 command_line
.rpath_link
= buf
;
1037 command_line
.relax
= TRUE
;
1039 case OPTION_RETAIN_SYMBOLS_FILE
:
1040 add_keepsyms_file (optarg
);
1043 link_info
.strip
= strip_debugger
;
1046 link_info
.strip
= strip_all
;
1048 case OPTION_STRIP_DISCARDED
:
1049 link_info
.strip_discarded
= TRUE
;
1051 case OPTION_NO_STRIP_DISCARDED
:
1052 link_info
.strip_discarded
= FALSE
;
1055 if (config
.has_shared
)
1057 link_info
.shared
= TRUE
;
1058 /* When creating a shared library, the default
1059 behaviour is to ignore any unresolved references. */
1060 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1061 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1062 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1063 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1066 einfo (_("%P%F: -shared not supported\n"));
1069 if (config
.has_shared
)
1071 link_info
.shared
= TRUE
;
1072 link_info
.pie
= TRUE
;
1075 einfo (_("%P%F: -pie not supported\n"));
1077 case 'h': /* Used on Solaris. */
1079 command_line
.soname
= optarg
;
1081 case OPTION_SORT_COMMON
:
1082 config
.sort_common
= TRUE
;
1084 case OPTION_SORT_SECTION
:
1085 if (strcmp (optarg
, N_("name")) == 0)
1086 sort_section
= by_name
;
1087 else if (strcmp (optarg
, N_("alignment")) == 0)
1088 sort_section
= by_alignment
;
1090 einfo (_("%P%F: invalid section sorting option: %s\n"),
1094 config
.stats
= TRUE
;
1096 case OPTION_SYMBOLIC
:
1097 link_info
.symbolic
= TRUE
;
1103 ldfile_open_command_file (optarg
);
1104 parser_input
= input_script
;
1107 case OPTION_SECTION_START
:
1113 /* Check for <something>=<somthing>... */
1114 optarg2
= strchr (optarg
, '=');
1115 if (optarg2
== NULL
)
1116 einfo (_("%P%F: invalid argument to option"
1117 " \"--section-start\"\n"));
1121 /* So far so good. Are all the args present? */
1122 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1123 einfo (_("%P%F: missing argument(s) to option"
1124 " \"--section-start\"\n"));
1126 /* We must copy the section name as set_section_start
1127 doesn't do it for us. */
1128 len
= optarg2
- optarg
;
1129 sec_name
= xmalloc (len
);
1130 memcpy (sec_name
, optarg
, len
- 1);
1131 sec_name
[len
- 1] = 0;
1133 /* Then set it... */
1134 set_section_start (sec_name
, optarg2
);
1137 case OPTION_TARGET_HELP
:
1138 /* Mention any target specific options. */
1139 ldemul_list_emulation_options (stdout
);
1142 set_segment_start (".bss", optarg
);
1145 set_segment_start (".data", optarg
);
1148 set_segment_start (".text", optarg
);
1150 case OPTION_TRADITIONAL_FORMAT
:
1151 link_info
.traditional_format
= TRUE
;
1153 case OPTION_TASK_LINK
:
1154 link_info
.task_link
= TRUE
;
1155 /* Fall through - do an implied -r option. */
1157 link_info
.relocatable
= TRUE
;
1158 config
.build_constructors
= TRUE
;
1159 config
.magic_demand_paged
= FALSE
;
1160 config
.text_read_only
= FALSE
;
1161 config
.dynamic_link
= FALSE
;
1164 ldlang_add_undef (optarg
);
1168 lang_add_unique (optarg
);
1170 config
.unique_orphan_sections
= TRUE
;
1172 case OPTION_VERBOSE
:
1174 version_printed
= TRUE
;
1175 trace_file_tries
= TRUE
;
1176 overflow_cutoff_limit
= -2;
1180 version_printed
= TRUE
;
1184 version_printed
= TRUE
;
1186 case OPTION_VERSION
:
1190 case OPTION_VERSION_SCRIPT
:
1191 /* This option indicates a small script that only specifies
1192 version information. Read it, but don't assume that
1193 we've seen a linker script. */
1195 FILE *hold_script_handle
;
1197 hold_script_handle
= saved_script_handle
;
1198 ldfile_open_command_file (optarg
);
1199 saved_script_handle
= hold_script_handle
;
1200 parser_input
= input_version_script
;
1204 case OPTION_VERSION_EXPORTS_SECTION
:
1205 /* This option records a version symbol to be applied to the
1206 symbols listed for export to be found in the object files
1207 .exports sections. */
1208 command_line
.version_exports_section
= optarg
;
1210 case OPTION_WARN_COMMON
:
1211 config
.warn_common
= TRUE
;
1213 case OPTION_WARN_CONSTRUCTORS
:
1214 config
.warn_constructors
= TRUE
;
1216 case OPTION_WARN_FATAL
:
1217 config
.fatal_warnings
= TRUE
;
1219 case OPTION_WARN_MULTIPLE_GP
:
1220 config
.warn_multiple_gp
= TRUE
;
1222 case OPTION_WARN_ONCE
:
1223 config
.warn_once
= TRUE
;
1225 case OPTION_WARN_SECTION_ALIGN
:
1226 config
.warn_section_align
= TRUE
;
1228 case OPTION_WARN_SHARED_TEXTREL
:
1229 link_info
.warn_shared_textrel
= TRUE
;
1231 case OPTION_WHOLE_ARCHIVE
:
1232 whole_archive
= TRUE
;
1234 case OPTION_ADD_NEEDED
:
1237 case OPTION_NO_ADD_NEEDED
:
1240 case OPTION_AS_NEEDED
:
1243 case OPTION_NO_AS_NEEDED
:
1249 case OPTION_DISCARD_NONE
:
1250 link_info
.discard
= discard_none
;
1253 link_info
.discard
= discard_l
;
1256 link_info
.discard
= discard_all
;
1259 if (strncmp (optarg
, "P,", 2) == 0)
1261 if (default_dirlist
!= NULL
)
1262 free (default_dirlist
);
1263 default_dirlist
= xstrdup (optarg
);
1268 case OPTION_SPARE_DYNAMIC_TAGS
:
1269 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1271 case OPTION_SPLIT_BY_RELOC
:
1273 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1275 config
.split_by_reloc
= 32768;
1277 case OPTION_SPLIT_BY_FILE
:
1279 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1281 config
.split_by_file
= 1;
1283 case OPTION_CHECK_SECTIONS
:
1284 command_line
.check_section_addresses
= TRUE
;
1286 case OPTION_NO_CHECK_SECTIONS
:
1287 command_line
.check_section_addresses
= FALSE
;
1289 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1290 command_line
.accept_unknown_input_arch
= TRUE
;
1292 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1293 command_line
.accept_unknown_input_arch
= FALSE
;
1297 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1299 lang_enter_group ();
1304 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1306 lang_leave_group ();
1311 link_info
.init_function
= optarg
;
1315 link_info
.fini_function
= optarg
;
1318 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1319 command_line
.reduce_memory_overheads
= TRUE
;
1320 if (config
.hash_table_size
== 0)
1321 config
.hash_table_size
= 1021;
1324 case OPTION_HASH_SIZE
:
1326 bfd_size_type new_size
;
1328 new_size
= strtoul (optarg
, NULL
, 0);
1330 config
.hash_table_size
= new_size
;
1332 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1339 lang_leave_group ();
1341 if (default_dirlist
!= NULL
)
1343 set_default_dirlist (default_dirlist
);
1344 free (default_dirlist
);
1347 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1348 /* FIXME: Should we allow emulations a chance to set this ? */
1349 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1351 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1352 /* FIXME: Should we allow emulations a chance to set this ? */
1353 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1356 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1357 library search path. */
1360 set_default_dirlist (char *dirlist_ptr
)
1366 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1369 if (*dirlist_ptr
!= '\0')
1370 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1373 dirlist_ptr
= p
+ 1;
1378 set_section_start (char *sect
, char *valstr
)
1381 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1383 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1384 lang_section_start (sect
, exp_intop (val
), NULL
);
1388 set_segment_start (const char *section
, char *valstr
)
1394 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1396 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1397 /* If we already have an entry for this segment, update the existing
1400 for (seg
= segments
; seg
; seg
= seg
->next
)
1401 if (strcmp (seg
->name
, name
) == 0)
1406 /* There was no existing value so we must create a new segment
1408 seg
= stat_alloc (sizeof (*seg
));
1412 /* Add it to the linked list of segments. */
1413 seg
->next
= segments
;
1415 /* Historically, -Ttext and friends set the base address of a
1416 particular section. For backwards compatibility, we still do
1417 that. If a SEGMENT_START directive is seen, the section address
1418 assignment will be disabled. */
1419 lang_section_start (section
, exp_intop (val
), seg
);
1423 /* Print help messages for the options. */
1429 const char **targets
, **pp
;
1431 printf (_("Usage: %s [options] file...\n"), program_name
);
1433 printf (_("Options:\n"));
1434 for (i
= 0; i
< OPTION_COUNT
; i
++)
1436 if (ld_options
[i
].doc
!= NULL
)
1450 if (ld_options
[j
].shortopt
!= '\0'
1451 && ld_options
[j
].control
!= NO_HELP
)
1453 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1454 len
+= (comma
? 2 : 0) + 2;
1455 if (ld_options
[j
].arg
!= NULL
)
1457 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1462 printf ("%s", _(ld_options
[j
].arg
));
1463 len
+= strlen (_(ld_options
[j
].arg
));
1469 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1474 if (ld_options
[j
].opt
.name
!= NULL
1475 && ld_options
[j
].control
!= NO_HELP
)
1478 (ld_options
[j
].control
== TWO_DASHES
1479 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1483 two_dashes
? "-" : "",
1484 ld_options
[j
].opt
.name
);
1485 len
+= ((comma
? 2 : 0)
1487 + (two_dashes
? 1 : 0)
1488 + strlen (ld_options
[j
].opt
.name
));
1489 if (ld_options
[j
].arg
!= NULL
)
1491 printf (" %s", _(ld_options
[j
].arg
));
1492 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1498 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1506 for (; len
< 30; len
++)
1509 printf ("%s\n", _(ld_options
[i
].doc
));
1513 /* Note: Various tools (such as libtool) depend upon the
1514 format of the listings below - do not change them. */
1515 /* xgettext:c-format */
1516 printf (_("%s: supported targets:"), program_name
);
1517 targets
= bfd_target_list ();
1518 for (pp
= targets
; *pp
!= NULL
; pp
++)
1519 printf (" %s", *pp
);
1523 /* xgettext:c-format */
1524 printf (_("%s: supported emulations: "), program_name
);
1525 ldemul_list_emulations (stdout
);
1528 /* xgettext:c-format */
1529 printf (_("%s: emulation specific options:\n"), program_name
);
1530 ldemul_list_emulation_options (stdout
);
1533 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);