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
148 /* The long options. This structure is used for both the option
149 parsing and the help text. */
153 /* The long option information. */
155 /* The short option with the same meaning ('\0' if none). */
157 /* The name of the argument (NULL if none). */
159 /* The documentation string. If this is NULL, this is a synonym for
160 the previous option. */
163 /* Use one dash before long option name. */
165 /* Use two dashes before long option name. */
167 /* Only accept two dashes before the long option name.
168 This is an overloading of the use of this enum, since originally it
169 was only intended to tell the --help display function how to display
170 the long option name. This feature was added in order to resolve
171 the confusion about the -omagic command line switch. Is it setting
172 the output file name to "magic" or is it setting the NMAGIC flag on
173 the output ? It has been decided that it is setting the output file
174 name, and that if you want to set the NMAGIC flag you should use -N
177 /* Don't mention this option in --help output. */
182 static const struct ld_option ld_options
[] =
184 { {NULL
, required_argument
, NULL
, '\0'},
185 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
187 { {"architecture", required_argument
, NULL
, 'A'},
188 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
189 { {"format", required_argument
, NULL
, 'b'},
190 'b', N_("TARGET"), N_("Specify target for following input files"), TWO_DASHES
},
191 { {"mri-script", required_argument
, NULL
, 'c'},
192 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
193 { {"dc", no_argument
, NULL
, 'd'},
194 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
195 { {"dp", no_argument
, NULL
, 'd'},
196 '\0', NULL
, NULL
, ONE_DASH
},
197 { {"entry", required_argument
, NULL
, 'e'},
198 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
199 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
200 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
201 { {"EB", no_argument
, NULL
, OPTION_EB
},
202 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
203 { {"EL", no_argument
, NULL
, OPTION_EL
},
204 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
205 { {"auxiliary", required_argument
, NULL
, 'f'},
206 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
208 { {"filter", required_argument
, NULL
, 'F'},
209 'F', N_("SHLIB"), N_("Filter for shared object symbol table"), TWO_DASHES
},
210 { {NULL
, no_argument
, NULL
, '\0'},
211 'g', NULL
, N_("Ignored"), ONE_DASH
},
212 { {"gpsize", required_argument
, NULL
, 'G'},
213 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
215 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
216 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
217 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
218 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"), TWO_DASHES
},
219 { {"library", required_argument
, NULL
, 'l'},
220 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
221 { {"library-path", required_argument
, NULL
, 'L'},
222 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"), TWO_DASHES
},
223 { {NULL
, required_argument
, NULL
, '\0'},
224 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
225 { {"print-map", no_argument
, NULL
, 'M'},
226 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
227 { {"nmagic", no_argument
, NULL
, 'n'},
228 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
229 { {"omagic", no_argument
, NULL
, 'N'},
230 'N', NULL
, N_("Do not page align data, do not make text readonly"),
231 EXACTLY_TWO_DASHES
},
232 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
233 '\0', NULL
, N_("Page align data, make text readonly"), EXACTLY_TWO_DASHES
},
234 { {"output", required_argument
, NULL
, 'o'},
235 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
236 { {NULL
, required_argument
, NULL
, '\0'},
237 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
238 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
239 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
240 { {"emit-relocs", no_argument
, NULL
, 'q'},
241 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
242 { {"relocatable", no_argument
, NULL
, 'r'},
243 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
244 { {NULL
, no_argument
, NULL
, '\0'},
245 'i', NULL
, NULL
, ONE_DASH
},
246 { {"just-symbols", required_argument
, NULL
, 'R'},
247 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
249 { {"strip-all", no_argument
, NULL
, 's'},
250 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
251 { {"strip-debug", no_argument
, NULL
, 'S'},
252 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
253 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
254 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
255 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
256 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
257 { {"trace", no_argument
, NULL
, 't'},
258 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
259 { {"script", required_argument
, NULL
, 'T'},
260 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
261 { {"undefined", required_argument
, NULL
, 'u'},
262 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), TWO_DASHES
},
263 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
264 '\0', N_("[=SECTION]"), N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
265 { {"Ur", no_argument
, NULL
, OPTION_UR
},
266 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
267 { {"version", no_argument
, NULL
, OPTION_VERSION
},
268 'v', NULL
, N_("Print version information"), TWO_DASHES
},
269 { {NULL
, no_argument
, NULL
, '\0'},
270 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
271 { {"discard-all", no_argument
, NULL
, 'x'},
272 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
273 { {"discard-locals", no_argument
, NULL
, 'X'},
274 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
275 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
276 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
277 { {"trace-symbol", required_argument
, NULL
, 'y'},
278 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
279 { {NULL
, required_argument
, NULL
, '\0'},
280 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), ONE_DASH
},
281 { {"start-group", no_argument
, NULL
, '('},
282 '(', NULL
, N_("Start a group"), TWO_DASHES
},
283 { {"end-group", no_argument
, NULL
, ')'},
284 ')', NULL
, N_("End a group"), TWO_DASHES
},
285 { {"accept-unknown-input-arch", no_argument
, NULL
, OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
286 '\0', NULL
, N_("Accept input files whose architecture cannot be determined"), TWO_DASHES
},
287 { {"no-accept-unknown-input-arch", no_argument
, NULL
, OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
288 '\0', NULL
, N_("Reject input files whose architecture is unknown"), TWO_DASHES
},
289 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
290 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
291 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
292 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
293 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
294 '\0', NULL
, NULL
, ONE_DASH
},
295 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
296 '\0', NULL
, NULL
, ONE_DASH
},
297 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
298 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
299 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
300 '\0', NULL
, NULL
, ONE_DASH
},
301 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
302 '\0', NULL
, NULL
, ONE_DASH
},
303 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
304 '\0', NULL
, NULL
, ONE_DASH
},
305 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
306 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
307 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
308 '\0', NULL
, N_("Check section addresses for overlaps (default)"), TWO_DASHES
},
309 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
310 '\0', NULL
, N_("Do not check section addresses for overlaps"),
312 { {"cref", no_argument
, NULL
, OPTION_CREF
},
313 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
314 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
315 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
316 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
317 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), TWO_DASHES
},
318 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
319 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
320 { {"fini", required_argument
, NULL
, OPTION_FINI
},
321 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
322 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
323 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
324 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
325 '\0', NULL
, N_("Remove unused sections (on some targets)"),
327 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
328 '\0', NULL
, N_("Don't remove unused sections (default)"),
330 { {"help", no_argument
, NULL
, OPTION_HELP
},
331 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
332 { {"init", required_argument
, NULL
, OPTION_INIT
},
333 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
334 { {"Map", required_argument
, NULL
, OPTION_MAP
},
335 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
336 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
337 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
338 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
339 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
340 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
341 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
342 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
343 '\0', NULL
, N_("Do not allow unresolved references in object files"), TWO_DASHES
},
344 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
345 '\0', NULL
, N_("Allow unresolved references in shared libaries"), TWO_DASHES
},
346 { {"no-allow-shlib-undefined", no_argument
, NULL
, OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
347 '\0', NULL
, N_("Do not allow unresolved references in shared libs"), TWO_DASHES
},
348 { {"allow-multiple-definition", no_argument
, NULL
, OPTION_ALLOW_MULTIPLE_DEFINITION
},
349 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
350 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
351 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
352 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
353 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
354 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
355 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
356 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
357 '\0', NULL
, N_("Create an output file even if errors occur"), TWO_DASHES
},
358 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
359 '\0', NULL
, NULL
, NO_HELP
},
360 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
361 '\0', NULL
, N_("Only use library directories specified on\n\t\t\t\tthe command line"), ONE_DASH
},
362 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
363 '\0', N_("TARGET"), N_("Specify target of output file"), EXACTLY_TWO_DASHES
},
364 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
365 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
366 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
367 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
368 { {"retain-symbols-file", required_argument
, NULL
,
369 OPTION_RETAIN_SYMBOLS_FILE
},
370 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
371 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
372 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
373 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
374 '\0', N_("PATH"), N_("Set link time shared library search path"), ONE_DASH
},
375 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
376 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
377 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
378 '\0', NULL
, NULL
, ONE_DASH
},
379 { {"pie", no_argument
, NULL
, OPTION_PIE
},
380 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
381 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
382 '\0', NULL
, NULL
, TWO_DASHES
},
383 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
384 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
385 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
386 '\0', NULL
, NULL
, NO_HELP
},
387 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
388 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"), TWO_DASHES
},
389 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
390 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"), TWO_DASHES
},
391 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
392 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"), TWO_DASHES
},
393 { {"stats", no_argument
, NULL
, OPTION_STATS
},
394 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
395 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
396 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
397 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
398 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
399 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
400 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
401 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
402 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"), TWO_DASHES
},
403 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
404 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
405 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
406 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
407 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
408 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
409 { {"unresolved-symbols=<method>", required_argument
, NULL
, OPTION_UNRESOLVED_SYMBOLS
},
410 '\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"),
412 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
413 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
414 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
415 '\0', NULL
, NULL
, NO_HELP
},
416 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
417 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
418 { {"version-exports-section", required_argument
, NULL
,
419 OPTION_VERSION_EXPORTS_SECTION
},
420 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n\t\t\t\tSYMBOL as the version."),
422 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
423 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
424 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
425 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
427 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
428 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
429 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
430 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
431 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
432 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
434 { {"warn-unresolved-symbols", no_argument
, NULL
, OPTION_WARN_UNRESOLVED_SYMBOLS
},
435 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
436 { {"error-unresolved-symbols", no_argument
, NULL
, OPTION_ERROR_UNRESOLVED_SYMBOLS
},
437 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
438 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
439 '\0', NULL
, N_("Treat warnings as errors"),
441 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
442 '\0', NULL
, N_("Include all objects from following archives"), TWO_DASHES
},
443 { {"as-needed", no_argument
, NULL
, OPTION_AS_NEEDED
},
444 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"), TWO_DASHES
},
445 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_AS_NEEDED
},
446 '\0', NULL
, N_("Always set DT_NEEDED for following dynamic libs"), TWO_DASHES
},
447 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
448 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
}
451 #define OPTION_COUNT ARRAY_SIZE (ld_options)
454 parse_args (unsigned argc
, char **argv
)
459 char *default_dirlist
= NULL
;
461 struct option
*longopts
;
462 struct option
*really_longopts
;
464 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
466 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
467 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
468 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
470 /* Starting the short option string with '-' is for programs that
471 expect options and other ARGV-elements in any order and that care about
472 the ordering of the two. We describe each non-option ARGV-element
473 as if it were the argument of an option with character code 1. */
478 for (i
= 0; i
< OPTION_COUNT
; i
++)
480 if (ld_options
[i
].shortopt
!= '\0')
482 shortopts
[is
] = ld_options
[i
].shortopt
;
484 if (ld_options
[i
].opt
.has_arg
== required_argument
485 || ld_options
[i
].opt
.has_arg
== optional_argument
)
489 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
496 if (ld_options
[i
].opt
.name
!= NULL
)
498 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
500 really_longopts
[irl
] = ld_options
[i
].opt
;
505 longopts
[il
] = ld_options
[i
].opt
;
510 shortopts
[is
] = '\0';
511 longopts
[il
].name
= NULL
;
512 really_longopts
[irl
].name
= NULL
;
514 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
516 /* The -G option is ambiguous on different platforms. Sometimes it
517 specifies the largest data size to put into the small data
518 section. Sometimes it is equivalent to --shared. Unfortunately,
519 the first form takes an argument, while the second does not.
521 We need to permit the --shared form because on some platforms,
522 such as Solaris, gcc -shared will pass -G to the linker.
524 To permit either usage, we look through the argument list. If we
525 find -G not followed by a number, we change it into --shared.
526 This will work for most normal cases. */
527 for (i
= 1; i
< argc
; i
++)
528 if (strcmp (argv
[i
], "-G") == 0
530 || ! ISDIGIT (argv
[i
+ 1][0])))
531 argv
[i
] = (char *) "--shared";
533 /* Because we permit long options to start with a single dash, and
534 we have a --library option, and the -l option is conventionally
535 used with an immediately following argument, we can have bad
536 results if somebody tries to use -l with a library whose name
537 happens to start with "ibrary", as in -li. We avoid problems by
538 simply turning -l into --library. This means that users will
539 have to use two dashes in order to use --library, which is OK
540 since that's how it is documented.
542 FIXME: It's possible that this problem can arise for other short
543 options as well, although the user does always have the recourse
544 of adding a space between the option and the argument. */
545 for (i
= 1; i
< argc
; i
++)
547 if (argv
[i
][0] == '-'
549 && argv
[i
][2] != '\0')
553 n
= xmalloc (strlen (argv
[i
]) + 20);
554 sprintf (n
, "--library=%s", argv
[i
] + 2);
565 /* Using last_optind lets us avoid calling ldemul_parse_args
566 multiple times on a single option, which would lead to
567 confusion in the internal static variables maintained by
568 getopt. This could otherwise happen for an argument like
569 -nx, in which the -n is parsed as a single option, and we
570 loop around to pick up the -x. */
571 if (optind
!= last_optind
)
572 if (ldemul_parse_args (argc
, argv
))
575 /* getopt_long_only is like getopt_long, but '-' as well as '--'
576 can indicate a long option. */
578 last_optind
= optind
;
579 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
582 optind
= last_optind
;
583 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
586 if (ldemul_handle_option (optc
))
595 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
597 einfo (_("%P%F: use the --help option for usage information\n"));
599 case 1: /* File name. */
600 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
606 /* For HP/UX compatibility. Actually -a shared should mean
607 ``use only shared libraries'' but, then, we don't
608 currently support shared libraries on HP/UX anyhow. */
609 if (strcmp (optarg
, "archive") == 0)
610 config
.dynamic_link
= FALSE
;
611 else if (strcmp (optarg
, "shared") == 0
612 || strcmp (optarg
, "default") == 0)
613 config
.dynamic_link
= TRUE
;
615 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
618 /* FIXME: We just ignore these, but we should handle them. */
619 if (strcmp (optarg
, "definitions") == 0)
621 else if (strcmp (optarg
, "nodefinitions") == 0)
623 else if (strcmp (optarg
, "nosymbolic") == 0)
625 else if (strcmp (optarg
, "pure-text") == 0)
628 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
631 ldfile_add_arch (optarg
);
634 lang_add_target (optarg
);
637 ldfile_open_command_file (optarg
);
638 parser_input
= input_mri_script
;
641 case OPTION_CALL_SHARED
:
642 config
.dynamic_link
= TRUE
;
644 case OPTION_NON_SHARED
:
645 config
.dynamic_link
= FALSE
;
648 command_line
.cref
= TRUE
;
649 link_info
.notice_all
= TRUE
;
652 command_line
.force_common_definition
= TRUE
;
656 lex_redirect (optarg
);
657 parser_input
= input_defsym
;
663 case OPTION_DEMANGLE
:
667 enum demangling_styles style
;
669 style
= cplus_demangle_name_to_style (optarg
);
670 if (style
== unknown_demangling
)
671 einfo (_("%F%P: unknown demangling style `%s'"),
674 cplus_demangle_set_style (style
);
677 case 'I': /* Used on Solaris. */
678 case OPTION_DYNAMIC_LINKER
:
679 command_line
.interpreter
= optarg
;
682 command_line
.endian
= ENDIAN_BIG
;
685 command_line
.endian
= ENDIAN_LITTLE
;
687 case OPTION_EMBEDDED_RELOCS
:
688 command_line
.embedded_relocs
= TRUE
;
690 case OPTION_EXPORT_DYNAMIC
:
691 case 'E': /* HP/UX compatibility. */
692 link_info
.export_dynamic
= TRUE
;
695 lang_add_entry (optarg
, TRUE
);
698 if (command_line
.auxiliary_filters
== NULL
)
700 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
701 command_line
.auxiliary_filters
[0] = optarg
;
702 command_line
.auxiliary_filters
[1] = NULL
;
710 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
712 command_line
.auxiliary_filters
713 = xrealloc (command_line
.auxiliary_filters
,
714 (c
+ 2) * sizeof (char *));
715 command_line
.auxiliary_filters
[c
] = optarg
;
716 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
720 command_line
.filter_shlib
= optarg
;
722 case OPTION_FORCE_EXE_SUFFIX
:
723 command_line
.force_exe_suffix
= TRUE
;
728 g_switch_value
= strtoul (optarg
, &end
, 0);
730 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
736 case OPTION_GC_SECTIONS
:
737 command_line
.gc_sections
= TRUE
;
744 ldfile_add_library_path (optarg
, TRUE
);
747 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
750 config
.map_filename
= "-";
753 /* Ignore. Was handled in a pre-parse. */
756 config
.map_filename
= optarg
;
759 config
.text_read_only
= FALSE
;
760 config
.magic_demand_paged
= FALSE
;
761 config
.dynamic_link
= FALSE
;
763 case OPTION_NO_OMAGIC
:
764 config
.text_read_only
= TRUE
;
765 config
.magic_demand_paged
= TRUE
;
766 /* NB/ Does not set dynamic_link to TRUE.
767 Use --call-shared or -Bdynamic for this. */
770 config
.magic_demand_paged
= FALSE
;
771 config
.dynamic_link
= FALSE
;
773 case OPTION_NO_DEFINE_COMMON
:
774 command_line
.inhibit_common_definition
= TRUE
;
776 case OPTION_NO_DEMANGLE
:
779 case OPTION_NO_GC_SECTIONS
:
780 command_line
.gc_sections
= FALSE
;
782 case OPTION_NO_KEEP_MEMORY
:
783 link_info
.keep_memory
= FALSE
;
785 case OPTION_NO_UNDEFINED
:
786 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
788 case OPTION_ALLOW_SHLIB_UNDEFINED
:
789 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
791 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
792 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
794 case OPTION_UNRESOLVED_SYMBOLS
:
795 if (strcmp (optarg
, "ignore-all") == 0)
797 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
798 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
800 else if (strcmp (optarg
, "report-all") == 0)
802 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
803 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
805 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
807 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
808 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
810 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
812 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
813 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
816 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
818 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
819 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
820 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
821 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
822 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
823 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
826 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
827 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
828 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
829 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
830 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
831 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
833 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
834 link_info
.allow_multiple_definition
= TRUE
;
836 case OPTION_NO_UNDEFINED_VERSION
:
837 link_info
.allow_undefined_version
= FALSE
;
839 case OPTION_NO_WARN_MISMATCH
:
840 command_line
.warn_mismatch
= FALSE
;
842 case OPTION_NOINHIBIT_EXEC
:
843 force_make_executable
= TRUE
;
845 case OPTION_NOSTDLIB
:
846 config
.only_cmd_line_lib_dirs
= TRUE
;
848 case OPTION_NO_WHOLE_ARCHIVE
:
849 whole_archive
= FALSE
;
852 /* FIXME "-O<non-digits> <value>" used to set the address of
853 section <non-digits>. Was this for compatibility with
854 something, or can we create a new option to do that
855 (with a syntax similar to -defsym)?
856 getopt can't handle two args to an option without kludges. */
858 /* Enable optimizations of output files. */
859 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
862 lang_add_output (optarg
, 0);
865 lang_add_output_format (optarg
, NULL
, NULL
, 0);
868 link_info
.emitrelocations
= TRUE
;
872 if (optind
== last_optind
)
873 /* This can happen if the user put "-rpath,a" on the command
874 line. (Or something similar. The comma is important).
875 Getopt becomes confused and thinks that this is a -r option
876 but it cannot parse the text after the -r so it refuses to
877 increment the optind counter. Detect this case and issue
878 an error message here. We cannot just make this a warning,
879 increment optind, and continue because getopt is too confused
880 and will seg-fault the next time around. */
881 einfo(_("%P%F: bad -rpath option\n"));
883 link_info
.relocatable
= TRUE
;
884 config
.build_constructors
= FALSE
;
885 config
.magic_demand_paged
= FALSE
;
886 config
.text_read_only
= FALSE
;
887 config
.dynamic_link
= FALSE
;
890 /* The GNU linker traditionally uses -R to mean to include
891 only the symbols from a file. The Solaris linker uses -R
892 to set the path used by the runtime linker to find
893 libraries. This is the GNU linker -rpath argument. We
894 try to support both simultaneously by checking the file
895 named. If it is a directory, rather than a regular file,
896 we assume -rpath was meant. */
900 if (stat (optarg
, &s
) >= 0
901 && ! S_ISDIR (s
.st_mode
))
903 lang_add_input_file (optarg
,
904 lang_input_file_is_symbols_only_enum
,
911 if (command_line
.rpath
== NULL
)
912 command_line
.rpath
= xstrdup (optarg
);
915 size_t rpath_len
= strlen (command_line
.rpath
);
916 size_t optarg_len
= strlen (optarg
);
918 char *cp
= command_line
.rpath
;
920 /* First see whether OPTARG is already in the path. */
925 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
927 if (optarg
[idx
] == '\0'
928 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
933 cp
= strchr (cp
, ':');
941 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
942 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
943 free (command_line
.rpath
);
944 command_line
.rpath
= buf
;
948 case OPTION_RPATH_LINK
:
949 if (command_line
.rpath_link
== NULL
)
950 command_line
.rpath_link
= xstrdup (optarg
);
955 buf
= xmalloc (strlen (command_line
.rpath_link
)
958 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
959 free (command_line
.rpath_link
);
960 command_line
.rpath_link
= buf
;
964 command_line
.relax
= TRUE
;
966 case OPTION_RETAIN_SYMBOLS_FILE
:
967 add_keepsyms_file (optarg
);
970 link_info
.strip
= strip_debugger
;
973 link_info
.strip
= strip_all
;
975 case OPTION_STRIP_DISCARDED
:
976 link_info
.strip_discarded
= TRUE
;
978 case OPTION_NO_STRIP_DISCARDED
:
979 link_info
.strip_discarded
= FALSE
;
982 if (config
.has_shared
)
984 link_info
.shared
= TRUE
;
985 /* When creating a shared library, the default
986 behaviour is to ignore any unresolved references. */
987 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
988 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
989 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
990 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
993 einfo (_("%P%F: -shared not supported\n"));
996 if (config
.has_shared
)
998 link_info
.shared
= TRUE
;
999 link_info
.pie
= TRUE
;
1002 einfo (_("%P%F: -pie not supported\n"));
1004 case 'h': /* Used on Solaris. */
1006 command_line
.soname
= optarg
;
1008 case OPTION_SORT_COMMON
:
1009 config
.sort_common
= TRUE
;
1012 config
.stats
= TRUE
;
1014 case OPTION_SYMBOLIC
:
1015 link_info
.symbolic
= TRUE
;
1021 ldfile_open_command_file (optarg
);
1022 parser_input
= input_script
;
1025 case OPTION_SECTION_START
:
1031 /* Check for <something>=<somthing>... */
1032 optarg2
= strchr (optarg
, '=');
1033 if (optarg2
== NULL
)
1034 einfo (_("%P%F: invalid argument to option \"--section-start\"\n"));
1038 /* So far so good. Are all the args present? */
1039 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1040 einfo (_("%P%F: missing argument(s) to option \"--section-start\"\n"));
1042 /* We must copy the section name as set_section_start
1043 doesn't do it for us. */
1044 len
= optarg2
- optarg
;
1045 sec_name
= xmalloc (len
);
1046 memcpy (sec_name
, optarg
, len
- 1);
1047 sec_name
[len
- 1] = 0;
1049 /* Then set it... */
1050 set_section_start (sec_name
, optarg2
);
1053 case OPTION_TARGET_HELP
:
1054 /* Mention any target specific options. */
1055 ldemul_list_emulation_options (stdout
);
1058 set_section_start (".bss", optarg
);
1061 set_section_start (".data", optarg
);
1064 set_section_start (".text", optarg
);
1066 case OPTION_TRADITIONAL_FORMAT
:
1067 link_info
.traditional_format
= TRUE
;
1069 case OPTION_TASK_LINK
:
1070 link_info
.task_link
= TRUE
;
1071 /* Fall through - do an implied -r option. */
1073 link_info
.relocatable
= TRUE
;
1074 config
.build_constructors
= TRUE
;
1075 config
.magic_demand_paged
= FALSE
;
1076 config
.text_read_only
= FALSE
;
1077 config
.dynamic_link
= FALSE
;
1080 ldlang_add_undef (optarg
);
1084 lang_add_unique (optarg
);
1086 config
.unique_orphan_sections
= TRUE
;
1088 case OPTION_VERBOSE
:
1090 version_printed
= TRUE
;
1091 trace_file_tries
= TRUE
;
1092 overflow_cutoff_limit
= -2;
1096 version_printed
= TRUE
;
1100 version_printed
= TRUE
;
1102 case OPTION_VERSION
:
1106 case OPTION_VERSION_SCRIPT
:
1107 /* This option indicates a small script that only specifies
1108 version information. Read it, but don't assume that
1109 we've seen a linker script. */
1111 FILE *hold_script_handle
;
1113 hold_script_handle
= saved_script_handle
;
1114 ldfile_open_command_file (optarg
);
1115 saved_script_handle
= hold_script_handle
;
1116 parser_input
= input_version_script
;
1120 case OPTION_VERSION_EXPORTS_SECTION
:
1121 /* This option records a version symbol to be applied to the
1122 symbols listed for export to be found in the object files
1123 .exports sections. */
1124 command_line
.version_exports_section
= optarg
;
1126 case OPTION_WARN_COMMON
:
1127 config
.warn_common
= TRUE
;
1129 case OPTION_WARN_CONSTRUCTORS
:
1130 config
.warn_constructors
= TRUE
;
1132 case OPTION_WARN_FATAL
:
1133 config
.fatal_warnings
= TRUE
;
1135 case OPTION_WARN_MULTIPLE_GP
:
1136 config
.warn_multiple_gp
= TRUE
;
1138 case OPTION_WARN_ONCE
:
1139 config
.warn_once
= TRUE
;
1141 case OPTION_WARN_SECTION_ALIGN
:
1142 config
.warn_section_align
= TRUE
;
1144 case OPTION_WHOLE_ARCHIVE
:
1145 whole_archive
= TRUE
;
1147 case OPTION_AS_NEEDED
:
1150 case OPTION_NO_AS_NEEDED
:
1156 case OPTION_DISCARD_NONE
:
1157 link_info
.discard
= discard_none
;
1160 link_info
.discard
= discard_l
;
1163 link_info
.discard
= discard_all
;
1166 if (strncmp (optarg
, "P,", 2) == 0)
1168 if (default_dirlist
!= NULL
)
1169 free (default_dirlist
);
1170 default_dirlist
= xstrdup (optarg
);
1175 case OPTION_SPARE_DYNAMIC_TAGS
:
1176 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1178 case OPTION_SPLIT_BY_RELOC
:
1180 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1182 config
.split_by_reloc
= 32768;
1184 case OPTION_SPLIT_BY_FILE
:
1186 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1188 config
.split_by_file
= 1;
1190 case OPTION_CHECK_SECTIONS
:
1191 command_line
.check_section_addresses
= TRUE
;
1193 case OPTION_NO_CHECK_SECTIONS
:
1194 command_line
.check_section_addresses
= FALSE
;
1196 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1197 command_line
.accept_unknown_input_arch
= TRUE
;
1199 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1200 command_line
.accept_unknown_input_arch
= FALSE
;
1204 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1206 lang_enter_group ();
1211 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1213 lang_leave_group ();
1218 link_info
.init_function
= optarg
;
1222 link_info
.fini_function
= optarg
;
1228 lang_leave_group ();
1230 if (default_dirlist
!= NULL
)
1232 set_default_dirlist (default_dirlist
);
1233 free (default_dirlist
);
1236 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1237 /* FIXME: Should we allow emulations a chance to set this ? */
1238 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1240 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1241 /* FIXME: Should we allow emulations a chance to set this ? */
1242 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1245 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1246 library search path. */
1249 set_default_dirlist (char *dirlist_ptr
)
1255 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1258 if (*dirlist_ptr
!= '\0')
1259 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1262 dirlist_ptr
= p
+ 1;
1267 set_section_start (char *sect
, char *valstr
)
1270 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1272 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1273 lang_section_start (sect
, exp_intop (val
));
1276 /* Print help messages for the options. */
1282 const char **targets
, **pp
;
1284 printf (_("Usage: %s [options] file...\n"), program_name
);
1286 printf (_("Options:\n"));
1287 for (i
= 0; i
< OPTION_COUNT
; i
++)
1289 if (ld_options
[i
].doc
!= NULL
)
1303 if (ld_options
[j
].shortopt
!= '\0'
1304 && ld_options
[j
].control
!= NO_HELP
)
1306 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1307 len
+= (comma
? 2 : 0) + 2;
1308 if (ld_options
[j
].arg
!= NULL
)
1310 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1315 printf ("%s", _(ld_options
[j
].arg
));
1316 len
+= strlen (_(ld_options
[j
].arg
));
1322 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1327 if (ld_options
[j
].opt
.name
!= NULL
1328 && ld_options
[j
].control
!= NO_HELP
)
1331 (ld_options
[j
].control
== TWO_DASHES
1332 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1336 two_dashes
? "-" : "",
1337 ld_options
[j
].opt
.name
);
1338 len
+= ((comma
? 2 : 0)
1340 + (two_dashes
? 1 : 0)
1341 + strlen (ld_options
[j
].opt
.name
));
1342 if (ld_options
[j
].arg
!= NULL
)
1344 printf (" %s", _(ld_options
[j
].arg
));
1345 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1351 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1359 for (; len
< 30; len
++)
1362 printf ("%s\n", _(ld_options
[i
].doc
));
1366 /* Note: Various tools (such as libtool) depend upon the
1367 format of the listings below - do not change them. */
1368 /* xgettext:c-format */
1369 printf (_("%s: supported targets:"), program_name
);
1370 targets
= bfd_target_list ();
1371 for (pp
= targets
; *pp
!= NULL
; pp
++)
1372 printf (" %s", *pp
);
1376 /* xgettext:c-format */
1377 printf (_("%s: supported emulations: "), program_name
);
1378 ldemul_list_emulations (stdout
);
1381 /* xgettext:c-format */
1382 printf (_("%s: emulation specific options:\n"), program_name
);
1383 ldemul_list_emulation_options (stdout
);
1386 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);