1 /* Parse options for the GNU linker.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 Free Software Foundation, Inc.
6 This file is part of GLD, the Gnu Linker.
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include "libiberty.h"
28 #include "safe-ctype.h"
43 #ifndef PATH_SEPARATOR
44 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
45 #define PATH_SEPARATOR ';'
47 #define PATH_SEPARATOR ':'
51 /* Somewhere above, sys/stat.h got included . . . . */
52 #if !defined(S_ISDIR) && defined(S_IFDIR)
53 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
56 static void set_default_dirlist (char *);
57 static void set_section_start (char *, char *);
58 static void help (void);
60 /* Non-zero if we are processing a --defsym from the command line. */
61 int parsing_defsym
= 0;
63 /* Codes used for the long options with no short synonyms. 150 isn't
64 special; it's just an arbitrary non-ASCII char value. */
72 OPTION_DYNAMIC_LINKER
,
75 OPTION_EMBEDDED_RELOCS
,
76 OPTION_EXPORT_DYNAMIC
,
81 OPTION_NO_KEEP_MEMORY
,
82 OPTION_NO_WARN_MISMATCH
,
83 OPTION_NOINHIBIT_EXEC
,
85 OPTION_NO_WHOLE_ARCHIVE
,
88 OPTION_RETAIN_SYMBOLS_FILE
,
100 OPTION_TRADITIONAL_FORMAT
,
104 OPTION_VERSION_SCRIPT
,
105 OPTION_VERSION_EXPORTS_SECTION
,
107 OPTION_WARN_CONSTRUCTORS
,
109 OPTION_WARN_MULTIPLE_GP
,
111 OPTION_WARN_SECTION_ALIGN
,
112 OPTION_SPLIT_BY_RELOC
,
113 OPTION_SPLIT_BY_FILE
,
114 OPTION_WHOLE_ARCHIVE
,
118 OPTION_FORCE_EXE_SUFFIX
,
120 OPTION_NO_GC_SECTIONS
,
121 OPTION_CHECK_SECTIONS
,
122 OPTION_NO_CHECK_SECTIONS
,
126 OPTION_SECTION_START
,
129 OPTION_ALLOW_SHLIB_UNDEFINED
,
130 OPTION_NO_ALLOW_SHLIB_UNDEFINED
,
131 OPTION_ALLOW_MULTIPLE_DEFINITION
,
132 OPTION_NO_UNDEFINED_VERSION
,
134 OPTION_SPARE_DYNAMIC_TAGS
,
135 OPTION_NO_DEFINE_COMMON
,
138 OPTION_STRIP_DISCARDED
,
139 OPTION_NO_STRIP_DISCARDED
,
140 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
,
141 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
,
143 OPTION_UNRESOLVED_SYMBOLS
,
144 OPTION_WARN_UNRESOLVED_SYMBOLS
,
145 OPTION_ERROR_UNRESOLVED_SYMBOLS
,
146 OPTION_REDUCE_MEMORY_OVERHEADS
149 /* The long options. This structure is used for both the option
150 parsing and the help text. */
154 /* The long option information. */
156 /* The short option with the same meaning ('\0' if none). */
158 /* The name of the argument (NULL if none). */
160 /* The documentation string. If this is NULL, this is a synonym for
161 the previous option. */
164 /* Use one dash before long option name. */
166 /* Use two dashes before long option name. */
168 /* Only accept two dashes before the long option name.
169 This is an overloading of the use of this enum, since originally it
170 was only intended to tell the --help display function how to display
171 the long option name. This feature was added in order to resolve
172 the confusion about the -omagic command line switch. Is it setting
173 the output file name to "magic" or is it setting the NMAGIC flag on
174 the output ? It has been decided that it is setting the output file
175 name, and that if you want to set the NMAGIC flag you should use -N
178 /* Don't mention this option in --help output. */
183 static const struct ld_option ld_options
[] =
185 { {NULL
, required_argument
, NULL
, '\0'},
186 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
188 { {"architecture", required_argument
, NULL
, 'A'},
189 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
190 { {"format", required_argument
, NULL
, 'b'},
191 'b', N_("TARGET"), N_("Specify target for following input files"), TWO_DASHES
},
192 { {"mri-script", required_argument
, NULL
, 'c'},
193 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
194 { {"dc", no_argument
, NULL
, 'd'},
195 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
196 { {"dp", no_argument
, NULL
, 'd'},
197 '\0', NULL
, NULL
, ONE_DASH
},
198 { {"entry", required_argument
, NULL
, 'e'},
199 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
200 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
201 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
202 { {"EB", no_argument
, NULL
, OPTION_EB
},
203 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
204 { {"EL", no_argument
, NULL
, OPTION_EL
},
205 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
206 { {"auxiliary", required_argument
, NULL
, 'f'},
207 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
209 { {"filter", required_argument
, NULL
, 'F'},
210 'F', N_("SHLIB"), N_("Filter for shared object symbol table"), TWO_DASHES
},
211 { {NULL
, no_argument
, NULL
, '\0'},
212 'g', NULL
, N_("Ignored"), ONE_DASH
},
213 { {"gpsize", required_argument
, NULL
, 'G'},
214 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
216 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
217 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
218 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
219 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"), TWO_DASHES
},
220 { {"library", required_argument
, NULL
, 'l'},
221 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
222 { {"library-path", required_argument
, NULL
, 'L'},
223 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"), TWO_DASHES
},
224 { {NULL
, required_argument
, NULL
, '\0'},
225 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
226 { {"print-map", no_argument
, NULL
, 'M'},
227 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
228 { {"nmagic", no_argument
, NULL
, 'n'},
229 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
230 { {"omagic", no_argument
, NULL
, 'N'},
231 'N', NULL
, N_("Do not page align data, do not make text readonly"),
232 EXACTLY_TWO_DASHES
},
233 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
234 '\0', NULL
, N_("Page align data, make text readonly"), EXACTLY_TWO_DASHES
},
235 { {"output", required_argument
, NULL
, 'o'},
236 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
237 { {NULL
, required_argument
, NULL
, '\0'},
238 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
239 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
240 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
241 { {"emit-relocs", no_argument
, NULL
, 'q'},
242 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
243 { {"relocatable", no_argument
, NULL
, 'r'},
244 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
245 { {NULL
, no_argument
, NULL
, '\0'},
246 'i', NULL
, NULL
, ONE_DASH
},
247 { {"just-symbols", required_argument
, NULL
, 'R'},
248 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
250 { {"strip-all", no_argument
, NULL
, 's'},
251 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
252 { {"strip-debug", no_argument
, NULL
, 'S'},
253 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
254 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
255 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
256 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
257 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
258 { {"trace", no_argument
, NULL
, 't'},
259 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
260 { {"script", required_argument
, NULL
, 'T'},
261 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
262 { {"undefined", required_argument
, NULL
, 'u'},
263 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), TWO_DASHES
},
264 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
265 '\0', N_("[=SECTION]"), N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
266 { {"Ur", no_argument
, NULL
, OPTION_UR
},
267 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
268 { {"version", no_argument
, NULL
, OPTION_VERSION
},
269 'v', NULL
, N_("Print version information"), TWO_DASHES
},
270 { {NULL
, no_argument
, NULL
, '\0'},
271 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
272 { {"discard-all", no_argument
, NULL
, 'x'},
273 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
274 { {"discard-locals", no_argument
, NULL
, 'X'},
275 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
276 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
277 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
278 { {"trace-symbol", required_argument
, NULL
, 'y'},
279 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
280 { {NULL
, required_argument
, NULL
, '\0'},
281 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), ONE_DASH
},
282 { {"start-group", no_argument
, NULL
, '('},
283 '(', NULL
, N_("Start a group"), TWO_DASHES
},
284 { {"end-group", no_argument
, NULL
, ')'},
285 ')', NULL
, N_("End a group"), TWO_DASHES
},
286 { {"accept-unknown-input-arch", no_argument
, NULL
, OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
287 '\0', NULL
, N_("Accept input files whose architecture cannot be determined"), TWO_DASHES
},
288 { {"no-accept-unknown-input-arch", no_argument
, NULL
, OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
289 '\0', NULL
, N_("Reject input files whose architecture is unknown"), TWO_DASHES
},
290 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
291 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
292 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
293 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
294 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
295 '\0', NULL
, NULL
, ONE_DASH
},
296 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
297 '\0', NULL
, NULL
, ONE_DASH
},
298 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
299 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
300 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
301 '\0', NULL
, NULL
, ONE_DASH
},
302 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
303 '\0', NULL
, NULL
, ONE_DASH
},
304 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
305 '\0', NULL
, NULL
, ONE_DASH
},
306 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
307 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
308 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
309 '\0', NULL
, N_("Check section addresses for overlaps (default)"), TWO_DASHES
},
310 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
311 '\0', NULL
, N_("Do not check section addresses for overlaps"),
313 { {"cref", no_argument
, NULL
, OPTION_CREF
},
314 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
315 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
316 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
317 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
318 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), TWO_DASHES
},
319 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
320 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
321 { {"fini", required_argument
, NULL
, OPTION_FINI
},
322 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
323 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
324 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
325 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
326 '\0', NULL
, N_("Remove unused sections (on some targets)"),
328 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
329 '\0', NULL
, N_("Don't remove unused sections (default)"),
331 { {"help", no_argument
, NULL
, OPTION_HELP
},
332 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
333 { {"init", required_argument
, NULL
, OPTION_INIT
},
334 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
335 { {"Map", required_argument
, NULL
, OPTION_MAP
},
336 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
337 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
338 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
339 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
340 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
341 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
342 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
343 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
344 '\0', NULL
, N_("Do not allow unresolved references in object files"), TWO_DASHES
},
345 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
346 '\0', NULL
, N_("Allow unresolved references in shared libaries"), TWO_DASHES
},
347 { {"no-allow-shlib-undefined", no_argument
, NULL
, OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
348 '\0', NULL
, N_("Do not allow unresolved references in shared libs"), TWO_DASHES
},
349 { {"allow-multiple-definition", no_argument
, NULL
, OPTION_ALLOW_MULTIPLE_DEFINITION
},
350 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
351 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
352 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
353 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
354 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
355 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
356 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
357 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
358 '\0', NULL
, N_("Create an output file even if errors occur"), TWO_DASHES
},
359 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
360 '\0', NULL
, NULL
, NO_HELP
},
361 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
362 '\0', NULL
, N_("Only use library directories specified on\n\t\t\t\tthe command line"), ONE_DASH
},
363 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
364 '\0', N_("TARGET"), N_("Specify target of output file"), EXACTLY_TWO_DASHES
},
365 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
366 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
367 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
368 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
369 { {"retain-symbols-file", required_argument
, NULL
,
370 OPTION_RETAIN_SYMBOLS_FILE
},
371 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
372 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
373 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
374 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
375 '\0', N_("PATH"), N_("Set link time shared library search path"), ONE_DASH
},
376 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
377 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
378 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
379 '\0', NULL
, NULL
, ONE_DASH
},
380 { {"pie", no_argument
, NULL
, OPTION_PIE
},
381 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
382 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
383 '\0', NULL
, NULL
, TWO_DASHES
},
384 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
385 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
386 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
387 '\0', NULL
, NULL
, NO_HELP
},
388 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
389 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"), TWO_DASHES
},
390 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
391 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"), TWO_DASHES
},
392 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
393 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"), TWO_DASHES
},
394 { {"stats", no_argument
, NULL
, OPTION_STATS
},
395 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
396 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
397 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
398 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
399 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
400 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
401 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
402 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
403 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"), TWO_DASHES
},
404 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
405 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
406 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
407 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
408 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
409 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
410 { {"unresolved-symbols=<method>", required_argument
, NULL
, OPTION_UNRESOLVED_SYMBOLS
},
411 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n\t\t\t\tignore-all, report-all, ignore-in-object-files,\n\t\t\t\tignore-in-shared-libs"),
413 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
414 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
415 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
416 '\0', NULL
, NULL
, NO_HELP
},
417 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
418 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
419 { {"version-exports-section", required_argument
, NULL
,
420 OPTION_VERSION_EXPORTS_SECTION
},
421 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n\t\t\t\tSYMBOL as the version."),
423 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
424 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
425 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
426 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
428 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
429 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
430 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
431 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
432 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
433 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
435 { {"warn-unresolved-symbols", no_argument
, NULL
, OPTION_WARN_UNRESOLVED_SYMBOLS
},
436 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
437 { {"error-unresolved-symbols", no_argument
, NULL
, OPTION_ERROR_UNRESOLVED_SYMBOLS
},
438 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
439 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
440 '\0', NULL
, N_("Treat warnings as errors"),
442 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
443 '\0', NULL
, N_("Include all objects from following archives"), TWO_DASHES
},
444 { {"as-needed", no_argument
, NULL
, OPTION_AS_NEEDED
},
445 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"), TWO_DASHES
},
446 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_AS_NEEDED
},
447 '\0', NULL
, N_("Always set DT_NEEDED for following dynamic libs"), TWO_DASHES
},
448 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
449 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
450 { {"reduce-memory-overheads", no_argument
, NULL
, OPTION_REDUCE_MEMORY_OVERHEADS
},
451 '\0', NULL
, N_("reduce memory overheads, possibly taking much longer"), TWO_DASHES
},
454 #define OPTION_COUNT ARRAY_SIZE (ld_options)
457 parse_args (unsigned argc
, char **argv
)
462 char *default_dirlist
= NULL
;
464 struct option
*longopts
;
465 struct option
*really_longopts
;
467 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
469 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
470 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
471 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
473 /* Starting the short option string with '-' is for programs that
474 expect options and other ARGV-elements in any order and that care about
475 the ordering of the two. We describe each non-option ARGV-element
476 as if it were the argument of an option with character code 1. */
481 for (i
= 0; i
< OPTION_COUNT
; i
++)
483 if (ld_options
[i
].shortopt
!= '\0')
485 shortopts
[is
] = ld_options
[i
].shortopt
;
487 if (ld_options
[i
].opt
.has_arg
== required_argument
488 || ld_options
[i
].opt
.has_arg
== optional_argument
)
492 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
499 if (ld_options
[i
].opt
.name
!= NULL
)
501 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
503 really_longopts
[irl
] = ld_options
[i
].opt
;
508 longopts
[il
] = ld_options
[i
].opt
;
513 shortopts
[is
] = '\0';
514 longopts
[il
].name
= NULL
;
515 really_longopts
[irl
].name
= NULL
;
517 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
519 /* The -G option is ambiguous on different platforms. Sometimes it
520 specifies the largest data size to put into the small data
521 section. Sometimes it is equivalent to --shared. Unfortunately,
522 the first form takes an argument, while the second does not.
524 We need to permit the --shared form because on some platforms,
525 such as Solaris, gcc -shared will pass -G to the linker.
527 To permit either usage, we look through the argument list. If we
528 find -G not followed by a number, we change it into --shared.
529 This will work for most normal cases. */
530 for (i
= 1; i
< argc
; i
++)
531 if (strcmp (argv
[i
], "-G") == 0
533 || ! ISDIGIT (argv
[i
+ 1][0])))
534 argv
[i
] = (char *) "--shared";
536 /* Because we permit long options to start with a single dash, and
537 we have a --library option, and the -l option is conventionally
538 used with an immediately following argument, we can have bad
539 results if somebody tries to use -l with a library whose name
540 happens to start with "ibrary", as in -li. We avoid problems by
541 simply turning -l into --library. This means that users will
542 have to use two dashes in order to use --library, which is OK
543 since that's how it is documented.
545 FIXME: It's possible that this problem can arise for other short
546 options as well, although the user does always have the recourse
547 of adding a space between the option and the argument. */
548 for (i
= 1; i
< argc
; i
++)
550 if (argv
[i
][0] == '-'
552 && argv
[i
][2] != '\0')
556 n
= xmalloc (strlen (argv
[i
]) + 20);
557 sprintf (n
, "--library=%s", argv
[i
] + 2);
568 /* Using last_optind lets us avoid calling ldemul_parse_args
569 multiple times on a single option, which would lead to
570 confusion in the internal static variables maintained by
571 getopt. This could otherwise happen for an argument like
572 -nx, in which the -n is parsed as a single option, and we
573 loop around to pick up the -x. */
574 if (optind
!= last_optind
)
575 if (ldemul_parse_args (argc
, argv
))
578 /* getopt_long_only is like getopt_long, but '-' as well as '--'
579 can indicate a long option. */
581 last_optind
= optind
;
582 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
585 optind
= last_optind
;
586 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
589 if (ldemul_handle_option (optc
))
598 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
600 einfo (_("%P%F: use the --help option for usage information\n"));
602 case 1: /* File name. */
603 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
609 /* For HP/UX compatibility. Actually -a shared should mean
610 ``use only shared libraries'' but, then, we don't
611 currently support shared libraries on HP/UX anyhow. */
612 if (strcmp (optarg
, "archive") == 0)
613 config
.dynamic_link
= FALSE
;
614 else if (strcmp (optarg
, "shared") == 0
615 || strcmp (optarg
, "default") == 0)
616 config
.dynamic_link
= TRUE
;
618 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
621 /* FIXME: We just ignore these, but we should handle them. */
622 if (strcmp (optarg
, "definitions") == 0)
624 else if (strcmp (optarg
, "nodefinitions") == 0)
626 else if (strcmp (optarg
, "nosymbolic") == 0)
628 else if (strcmp (optarg
, "pure-text") == 0)
631 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
634 ldfile_add_arch (optarg
);
637 lang_add_target (optarg
);
640 ldfile_open_command_file (optarg
);
641 parser_input
= input_mri_script
;
644 case OPTION_CALL_SHARED
:
645 config
.dynamic_link
= TRUE
;
647 case OPTION_NON_SHARED
:
648 config
.dynamic_link
= FALSE
;
651 command_line
.cref
= TRUE
;
652 link_info
.notice_all
= TRUE
;
655 command_line
.force_common_definition
= TRUE
;
659 lex_redirect (optarg
);
660 parser_input
= input_defsym
;
666 case OPTION_DEMANGLE
:
670 enum demangling_styles style
;
672 style
= cplus_demangle_name_to_style (optarg
);
673 if (style
== unknown_demangling
)
674 einfo (_("%F%P: unknown demangling style `%s'"),
677 cplus_demangle_set_style (style
);
680 case 'I': /* Used on Solaris. */
681 case OPTION_DYNAMIC_LINKER
:
682 command_line
.interpreter
= optarg
;
685 command_line
.endian
= ENDIAN_BIG
;
688 command_line
.endian
= ENDIAN_LITTLE
;
690 case OPTION_EMBEDDED_RELOCS
:
691 command_line
.embedded_relocs
= TRUE
;
693 case OPTION_EXPORT_DYNAMIC
:
694 case 'E': /* HP/UX compatibility. */
695 link_info
.export_dynamic
= TRUE
;
698 lang_add_entry (optarg
, TRUE
);
701 if (command_line
.auxiliary_filters
== NULL
)
703 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
704 command_line
.auxiliary_filters
[0] = optarg
;
705 command_line
.auxiliary_filters
[1] = NULL
;
713 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
715 command_line
.auxiliary_filters
716 = xrealloc (command_line
.auxiliary_filters
,
717 (c
+ 2) * sizeof (char *));
718 command_line
.auxiliary_filters
[c
] = optarg
;
719 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
723 command_line
.filter_shlib
= optarg
;
725 case OPTION_FORCE_EXE_SUFFIX
:
726 command_line
.force_exe_suffix
= TRUE
;
731 g_switch_value
= strtoul (optarg
, &end
, 0);
733 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
739 case OPTION_GC_SECTIONS
:
740 command_line
.gc_sections
= TRUE
;
747 ldfile_add_library_path (optarg
, TRUE
);
750 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
753 config
.map_filename
= "-";
756 /* Ignore. Was handled in a pre-parse. */
759 config
.map_filename
= optarg
;
762 config
.text_read_only
= FALSE
;
763 config
.magic_demand_paged
= FALSE
;
764 config
.dynamic_link
= FALSE
;
766 case OPTION_NO_OMAGIC
:
767 config
.text_read_only
= TRUE
;
768 config
.magic_demand_paged
= TRUE
;
769 /* NB/ Does not set dynamic_link to TRUE.
770 Use --call-shared or -Bdynamic for this. */
773 config
.magic_demand_paged
= FALSE
;
774 config
.dynamic_link
= FALSE
;
776 case OPTION_NO_DEFINE_COMMON
:
777 command_line
.inhibit_common_definition
= TRUE
;
779 case OPTION_NO_DEMANGLE
:
782 case OPTION_NO_GC_SECTIONS
:
783 command_line
.gc_sections
= FALSE
;
785 case OPTION_NO_KEEP_MEMORY
:
786 link_info
.keep_memory
= FALSE
;
788 case OPTION_NO_UNDEFINED
:
789 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
791 case OPTION_ALLOW_SHLIB_UNDEFINED
:
792 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
794 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
795 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
797 case OPTION_UNRESOLVED_SYMBOLS
:
798 if (strcmp (optarg
, "ignore-all") == 0)
800 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
801 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
803 else if (strcmp (optarg
, "report-all") == 0)
805 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
806 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
808 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
810 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
811 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
813 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
815 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
816 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
819 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
821 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
822 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
823 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
824 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
825 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
826 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
829 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
830 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
831 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
832 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
833 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
834 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
836 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
837 link_info
.allow_multiple_definition
= TRUE
;
839 case OPTION_NO_UNDEFINED_VERSION
:
840 link_info
.allow_undefined_version
= FALSE
;
842 case OPTION_NO_WARN_MISMATCH
:
843 command_line
.warn_mismatch
= FALSE
;
845 case OPTION_NOINHIBIT_EXEC
:
846 force_make_executable
= TRUE
;
848 case OPTION_NOSTDLIB
:
849 config
.only_cmd_line_lib_dirs
= TRUE
;
851 case OPTION_NO_WHOLE_ARCHIVE
:
852 whole_archive
= FALSE
;
855 /* FIXME "-O<non-digits> <value>" used to set the address of
856 section <non-digits>. Was this for compatibility with
857 something, or can we create a new option to do that
858 (with a syntax similar to -defsym)?
859 getopt can't handle two args to an option without kludges. */
861 /* Enable optimizations of output files. */
862 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
865 lang_add_output (optarg
, 0);
868 lang_add_output_format (optarg
, NULL
, NULL
, 0);
871 link_info
.emitrelocations
= TRUE
;
875 if (optind
== last_optind
)
876 /* This can happen if the user put "-rpath,a" on the command
877 line. (Or something similar. The comma is important).
878 Getopt becomes confused and thinks that this is a -r option
879 but it cannot parse the text after the -r so it refuses to
880 increment the optind counter. Detect this case and issue
881 an error message here. We cannot just make this a warning,
882 increment optind, and continue because getopt is too confused
883 and will seg-fault the next time around. */
884 einfo(_("%P%F: bad -rpath option\n"));
886 link_info
.relocatable
= TRUE
;
887 config
.build_constructors
= FALSE
;
888 config
.magic_demand_paged
= FALSE
;
889 config
.text_read_only
= FALSE
;
890 config
.dynamic_link
= FALSE
;
893 /* The GNU linker traditionally uses -R to mean to include
894 only the symbols from a file. The Solaris linker uses -R
895 to set the path used by the runtime linker to find
896 libraries. This is the GNU linker -rpath argument. We
897 try to support both simultaneously by checking the file
898 named. If it is a directory, rather than a regular file,
899 we assume -rpath was meant. */
903 if (stat (optarg
, &s
) >= 0
904 && ! S_ISDIR (s
.st_mode
))
906 lang_add_input_file (optarg
,
907 lang_input_file_is_symbols_only_enum
,
914 if (command_line
.rpath
== NULL
)
915 command_line
.rpath
= xstrdup (optarg
);
918 size_t rpath_len
= strlen (command_line
.rpath
);
919 size_t optarg_len
= strlen (optarg
);
921 char *cp
= command_line
.rpath
;
923 /* First see whether OPTARG is already in the path. */
928 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
930 if (optarg
[idx
] == '\0'
931 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
936 cp
= strchr (cp
, ':');
944 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
945 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
946 free (command_line
.rpath
);
947 command_line
.rpath
= buf
;
951 case OPTION_RPATH_LINK
:
952 if (command_line
.rpath_link
== NULL
)
953 command_line
.rpath_link
= xstrdup (optarg
);
958 buf
= xmalloc (strlen (command_line
.rpath_link
)
961 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
962 free (command_line
.rpath_link
);
963 command_line
.rpath_link
= buf
;
967 command_line
.relax
= TRUE
;
969 case OPTION_RETAIN_SYMBOLS_FILE
:
970 add_keepsyms_file (optarg
);
973 link_info
.strip
= strip_debugger
;
976 link_info
.strip
= strip_all
;
978 case OPTION_STRIP_DISCARDED
:
979 link_info
.strip_discarded
= TRUE
;
981 case OPTION_NO_STRIP_DISCARDED
:
982 link_info
.strip_discarded
= FALSE
;
985 if (config
.has_shared
)
987 link_info
.shared
= TRUE
;
988 /* When creating a shared library, the default
989 behaviour is to ignore any unresolved references. */
990 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
991 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
992 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
993 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
996 einfo (_("%P%F: -shared not supported\n"));
999 if (config
.has_shared
)
1001 link_info
.shared
= TRUE
;
1002 link_info
.pie
= TRUE
;
1005 einfo (_("%P%F: -pie not supported\n"));
1007 case 'h': /* Used on Solaris. */
1009 command_line
.soname
= optarg
;
1011 case OPTION_SORT_COMMON
:
1012 config
.sort_common
= TRUE
;
1015 config
.stats
= TRUE
;
1017 case OPTION_SYMBOLIC
:
1018 link_info
.symbolic
= TRUE
;
1024 ldfile_open_command_file (optarg
);
1025 parser_input
= input_script
;
1028 case OPTION_SECTION_START
:
1034 /* Check for <something>=<somthing>... */
1035 optarg2
= strchr (optarg
, '=');
1036 if (optarg2
== NULL
)
1037 einfo (_("%P%F: invalid argument to option \"--section-start\"\n"));
1041 /* So far so good. Are all the args present? */
1042 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1043 einfo (_("%P%F: missing argument(s) to option \"--section-start\"\n"));
1045 /* We must copy the section name as set_section_start
1046 doesn't do it for us. */
1047 len
= optarg2
- optarg
;
1048 sec_name
= xmalloc (len
);
1049 memcpy (sec_name
, optarg
, len
- 1);
1050 sec_name
[len
- 1] = 0;
1052 /* Then set it... */
1053 set_section_start (sec_name
, optarg2
);
1056 case OPTION_TARGET_HELP
:
1057 /* Mention any target specific options. */
1058 ldemul_list_emulation_options (stdout
);
1061 set_section_start (".bss", optarg
);
1064 set_section_start (".data", optarg
);
1067 set_section_start (".text", optarg
);
1069 case OPTION_TRADITIONAL_FORMAT
:
1070 link_info
.traditional_format
= TRUE
;
1072 case OPTION_TASK_LINK
:
1073 link_info
.task_link
= TRUE
;
1074 /* Fall through - do an implied -r option. */
1076 link_info
.relocatable
= TRUE
;
1077 config
.build_constructors
= TRUE
;
1078 config
.magic_demand_paged
= FALSE
;
1079 config
.text_read_only
= FALSE
;
1080 config
.dynamic_link
= FALSE
;
1083 ldlang_add_undef (optarg
);
1087 lang_add_unique (optarg
);
1089 config
.unique_orphan_sections
= TRUE
;
1091 case OPTION_VERBOSE
:
1093 version_printed
= TRUE
;
1094 trace_file_tries
= TRUE
;
1095 overflow_cutoff_limit
= -2;
1099 version_printed
= TRUE
;
1103 version_printed
= TRUE
;
1105 case OPTION_VERSION
:
1109 case OPTION_VERSION_SCRIPT
:
1110 /* This option indicates a small script that only specifies
1111 version information. Read it, but don't assume that
1112 we've seen a linker script. */
1114 FILE *hold_script_handle
;
1116 hold_script_handle
= saved_script_handle
;
1117 ldfile_open_command_file (optarg
);
1118 saved_script_handle
= hold_script_handle
;
1119 parser_input
= input_version_script
;
1123 case OPTION_VERSION_EXPORTS_SECTION
:
1124 /* This option records a version symbol to be applied to the
1125 symbols listed for export to be found in the object files
1126 .exports sections. */
1127 command_line
.version_exports_section
= optarg
;
1129 case OPTION_WARN_COMMON
:
1130 config
.warn_common
= TRUE
;
1132 case OPTION_WARN_CONSTRUCTORS
:
1133 config
.warn_constructors
= TRUE
;
1135 case OPTION_WARN_FATAL
:
1136 config
.fatal_warnings
= TRUE
;
1138 case OPTION_WARN_MULTIPLE_GP
:
1139 config
.warn_multiple_gp
= TRUE
;
1141 case OPTION_WARN_ONCE
:
1142 config
.warn_once
= TRUE
;
1144 case OPTION_WARN_SECTION_ALIGN
:
1145 config
.warn_section_align
= TRUE
;
1147 case OPTION_WHOLE_ARCHIVE
:
1148 whole_archive
= TRUE
;
1150 case OPTION_AS_NEEDED
:
1153 case OPTION_NO_AS_NEEDED
:
1159 case OPTION_DISCARD_NONE
:
1160 link_info
.discard
= discard_none
;
1163 link_info
.discard
= discard_l
;
1166 link_info
.discard
= discard_all
;
1169 if (strncmp (optarg
, "P,", 2) == 0)
1171 if (default_dirlist
!= NULL
)
1172 free (default_dirlist
);
1173 default_dirlist
= xstrdup (optarg
);
1178 case OPTION_SPARE_DYNAMIC_TAGS
:
1179 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1181 case OPTION_SPLIT_BY_RELOC
:
1183 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1185 config
.split_by_reloc
= 32768;
1187 case OPTION_SPLIT_BY_FILE
:
1189 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1191 config
.split_by_file
= 1;
1193 case OPTION_CHECK_SECTIONS
:
1194 command_line
.check_section_addresses
= TRUE
;
1196 case OPTION_NO_CHECK_SECTIONS
:
1197 command_line
.check_section_addresses
= FALSE
;
1199 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1200 command_line
.accept_unknown_input_arch
= TRUE
;
1202 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1203 command_line
.accept_unknown_input_arch
= FALSE
;
1207 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1209 lang_enter_group ();
1214 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1216 lang_leave_group ();
1221 link_info
.init_function
= optarg
;
1225 link_info
.fini_function
= optarg
;
1227 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1228 command_line
.reduce_memory_overheads
= TRUE
;
1234 lang_leave_group ();
1236 if (default_dirlist
!= NULL
)
1238 set_default_dirlist (default_dirlist
);
1239 free (default_dirlist
);
1242 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1243 /* FIXME: Should we allow emulations a chance to set this ? */
1244 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1246 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1247 /* FIXME: Should we allow emulations a chance to set this ? */
1248 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1251 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1252 library search path. */
1255 set_default_dirlist (char *dirlist_ptr
)
1261 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1264 if (*dirlist_ptr
!= '\0')
1265 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1268 dirlist_ptr
= p
+ 1;
1273 set_section_start (char *sect
, char *valstr
)
1276 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1278 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1279 lang_section_start (sect
, exp_intop (val
));
1282 /* Print help messages for the options. */
1288 const char **targets
, **pp
;
1290 printf (_("Usage: %s [options] file...\n"), program_name
);
1292 printf (_("Options:\n"));
1293 for (i
= 0; i
< OPTION_COUNT
; i
++)
1295 if (ld_options
[i
].doc
!= NULL
)
1309 if (ld_options
[j
].shortopt
!= '\0'
1310 && ld_options
[j
].control
!= NO_HELP
)
1312 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1313 len
+= (comma
? 2 : 0) + 2;
1314 if (ld_options
[j
].arg
!= NULL
)
1316 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1321 printf ("%s", _(ld_options
[j
].arg
));
1322 len
+= strlen (_(ld_options
[j
].arg
));
1328 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1333 if (ld_options
[j
].opt
.name
!= NULL
1334 && ld_options
[j
].control
!= NO_HELP
)
1337 (ld_options
[j
].control
== TWO_DASHES
1338 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1342 two_dashes
? "-" : "",
1343 ld_options
[j
].opt
.name
);
1344 len
+= ((comma
? 2 : 0)
1346 + (two_dashes
? 1 : 0)
1347 + strlen (ld_options
[j
].opt
.name
));
1348 if (ld_options
[j
].arg
!= NULL
)
1350 printf (" %s", _(ld_options
[j
].arg
));
1351 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1357 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1365 for (; len
< 30; len
++)
1368 printf ("%s\n", _(ld_options
[i
].doc
));
1372 /* Note: Various tools (such as libtool) depend upon the
1373 format of the listings below - do not change them. */
1374 /* xgettext:c-format */
1375 printf (_("%s: supported targets:"), program_name
);
1376 targets
= bfd_target_list ();
1377 for (pp
= targets
; *pp
!= NULL
; pp
++)
1378 printf (" %s", *pp
);
1382 /* xgettext:c-format */
1383 printf (_("%s: supported emulations: "), program_name
);
1384 ldemul_list_emulations (stdout
);
1387 /* xgettext:c-format */
1388 printf (_("%s: emulation specific options:\n"), program_name
);
1389 ldemul_list_emulation_options (stdout
);
1392 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);