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
,
116 OPTION_FORCE_EXE_SUFFIX
,
118 OPTION_NO_GC_SECTIONS
,
119 OPTION_CHECK_SECTIONS
,
120 OPTION_NO_CHECK_SECTIONS
,
125 OPTION_SECTION_START
,
128 OPTION_ALLOW_SHLIB_UNDEFINED
,
129 OPTION_NO_ALLOW_SHLIB_UNDEFINED
,
130 OPTION_ALLOW_MULTIPLE_DEFINITION
,
131 OPTION_NO_UNDEFINED_VERSION
,
133 OPTION_SPARE_DYNAMIC_TAGS
,
134 OPTION_NO_DEFINE_COMMON
,
137 OPTION_STRIP_DISCARDED
,
138 OPTION_NO_STRIP_DISCARDED
,
139 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
,
140 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
,
142 OPTION_UNRESOLVED_SYMBOLS
,
143 OPTION_WARN_UNRESOLVED_SYMBOLS
,
144 OPTION_ERROR_UNRESOLVED_SYMBOLS
147 /* The long options. This structure is used for both the option
148 parsing and the help text. */
152 /* The long option information. */
154 /* The short option with the same meaning ('\0' if none). */
156 /* The name of the argument (NULL if none). */
158 /* The documentation string. If this is NULL, this is a synonym for
159 the previous option. */
162 /* Use one dash before long option name. */
164 /* Use two dashes before long option name. */
166 /* Only accept two dashes before the long option name.
167 This is an overloading of the use of this enum, since originally it
168 was only intended to tell the --help display function how to display
169 the long option name. This feature was added in order to resolve
170 the confusion about the -omagic command line switch. Is it setting
171 the output file name to "magic" or is it setting the NMAGIC flag on
172 the output ? It has been decided that it is setting the output file
173 name, and that if you want to set the NMAGIC flag you should use -N
176 /* Don't mention this option in --help output. */
181 static const struct ld_option ld_options
[] =
183 { {NULL
, required_argument
, NULL
, '\0'},
184 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
186 { {"architecture", required_argument
, NULL
, 'A'},
187 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
188 { {"format", required_argument
, NULL
, 'b'},
189 'b', N_("TARGET"), N_("Specify target for following input files"), TWO_DASHES
},
190 { {"mri-script", required_argument
, NULL
, 'c'},
191 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
192 { {"dc", no_argument
, NULL
, 'd'},
193 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
194 { {"dp", no_argument
, NULL
, 'd'},
195 '\0', NULL
, NULL
, ONE_DASH
},
196 { {"entry", required_argument
, NULL
, 'e'},
197 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
198 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
199 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
200 { {"EB", no_argument
, NULL
, OPTION_EB
},
201 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
202 { {"EL", no_argument
, NULL
, OPTION_EL
},
203 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
204 { {"auxiliary", required_argument
, NULL
, 'f'},
205 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
207 { {"filter", required_argument
, NULL
, 'F'},
208 'F', N_("SHLIB"), N_("Filter for shared object symbol table"), TWO_DASHES
},
209 { {NULL
, no_argument
, NULL
, '\0'},
210 'g', NULL
, N_("Ignored"), ONE_DASH
},
211 { {"gpsize", required_argument
, NULL
, 'G'},
212 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
214 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
215 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
216 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
217 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"), TWO_DASHES
},
218 { {"library", required_argument
, NULL
, 'l'},
219 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
220 { {"library-path", required_argument
, NULL
, 'L'},
221 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"), TWO_DASHES
},
222 { {NULL
, required_argument
, NULL
, '\0'},
223 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
224 { {"print-map", no_argument
, NULL
, 'M'},
225 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
226 { {"nmagic", no_argument
, NULL
, 'n'},
227 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
228 { {"omagic", no_argument
, NULL
, 'N'},
229 'N', NULL
, N_("Do not page align data, do not make text readonly"),
230 EXACTLY_TWO_DASHES
},
231 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
232 '\0', NULL
, N_("Page align data, make text readonly"), EXACTLY_TWO_DASHES
},
233 { {"output", required_argument
, NULL
, 'o'},
234 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
235 { {NULL
, required_argument
, NULL
, '\0'},
236 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
237 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
238 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
239 { {"emit-relocs", no_argument
, NULL
, 'q'},
240 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
241 { {"relocatable", no_argument
, NULL
, 'r'},
242 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
243 { {NULL
, no_argument
, NULL
, '\0'},
244 'i', NULL
, NULL
, ONE_DASH
},
245 { {"just-symbols", required_argument
, NULL
, 'R'},
246 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
248 { {"strip-all", no_argument
, NULL
, 's'},
249 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
250 { {"strip-debug", no_argument
, NULL
, 'S'},
251 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
252 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
253 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
254 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
255 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
256 { {"trace", no_argument
, NULL
, 't'},
257 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
258 { {"script", required_argument
, NULL
, 'T'},
259 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
260 { {"undefined", required_argument
, NULL
, 'u'},
261 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), TWO_DASHES
},
262 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
263 '\0', N_("[=SECTION]"), N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
264 { {"Ur", no_argument
, NULL
, OPTION_UR
},
265 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
266 { {"version", no_argument
, NULL
, OPTION_VERSION
},
267 'v', NULL
, N_("Print version information"), TWO_DASHES
},
268 { {NULL
, no_argument
, NULL
, '\0'},
269 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
270 { {"discard-all", no_argument
, NULL
, 'x'},
271 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
272 { {"discard-locals", no_argument
, NULL
, 'X'},
273 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
274 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
275 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
276 { {"trace-symbol", required_argument
, NULL
, 'y'},
277 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
278 { {NULL
, required_argument
, NULL
, '\0'},
279 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), ONE_DASH
},
280 { {"start-group", no_argument
, NULL
, '('},
281 '(', NULL
, N_("Start a group"), TWO_DASHES
},
282 { {"end-group", no_argument
, NULL
, ')'},
283 ')', NULL
, N_("End a group"), TWO_DASHES
},
284 { {"accept-unknown-input-arch", no_argument
, NULL
, OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
285 '\0', NULL
, N_("Accept input files whose architecture cannot be determined"), TWO_DASHES
},
286 { {"no-accept-unknown-input-arch", no_argument
, NULL
, OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
287 '\0', NULL
, N_("Reject input files whose architecture is unknown"), TWO_DASHES
},
288 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
289 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
290 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
291 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
292 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
293 '\0', NULL
, NULL
, ONE_DASH
},
294 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
295 '\0', NULL
, NULL
, ONE_DASH
},
296 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
297 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
298 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
299 '\0', NULL
, NULL
, ONE_DASH
},
300 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
301 '\0', NULL
, NULL
, ONE_DASH
},
302 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
303 '\0', NULL
, NULL
, ONE_DASH
},
304 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
305 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
306 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
307 '\0', NULL
, N_("Check section addresses for overlaps (default)"), TWO_DASHES
},
308 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
309 '\0', NULL
, N_("Do not check section addresses for overlaps"),
311 { {"cref", no_argument
, NULL
, OPTION_CREF
},
312 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
313 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
314 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
315 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
316 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), TWO_DASHES
},
317 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
318 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
319 { {"fini", required_argument
, NULL
, OPTION_FINI
},
320 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
321 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
322 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
323 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
324 '\0', NULL
, N_("Remove unused sections (on some targets)"),
326 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
327 '\0', NULL
, N_("Don't remove unused sections (default)"),
329 { {"help", no_argument
, NULL
, OPTION_HELP
},
330 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
331 { {"init", required_argument
, NULL
, OPTION_INIT
},
332 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
333 { {"Map", required_argument
, NULL
, OPTION_MAP
},
334 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
335 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
336 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
337 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
338 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
339 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
340 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
341 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
342 '\0', NULL
, N_("Do not allow unresolved references in object files"), TWO_DASHES
},
343 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
344 '\0', NULL
, N_("Allow unresolved references in shared libaries"), TWO_DASHES
},
345 { {"no-allow-shlib-undefined", no_argument
, NULL
, OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
346 '\0', NULL
, N_("Do not allow unresolved references in shared libs"), TWO_DASHES
},
347 { {"allow-multiple-definition", no_argument
, NULL
, OPTION_ALLOW_MULTIPLE_DEFINITION
},
348 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
349 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
350 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
351 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
352 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
353 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
354 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
355 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
356 '\0', NULL
, N_("Create an output file even if errors occur"), TWO_DASHES
},
357 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
358 '\0', NULL
, NULL
, NO_HELP
},
359 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
360 '\0', NULL
, N_("Only use library directories specified on\n\t\t\t\tthe command line"), ONE_DASH
},
361 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
362 '\0', N_("TARGET"), N_("Specify target of output file"), EXACTLY_TWO_DASHES
},
363 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
364 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
365 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
366 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
367 { {"retain-symbols-file", required_argument
, NULL
,
368 OPTION_RETAIN_SYMBOLS_FILE
},
369 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
370 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
371 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
372 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
373 '\0', N_("PATH"), N_("Set link time shared library search path"), ONE_DASH
},
374 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
375 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
376 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
377 '\0', NULL
, NULL
, ONE_DASH
},
378 { {"pie", no_argument
, NULL
, OPTION_PIE
},
379 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
380 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
381 '\0', NULL
, NULL
, TWO_DASHES
},
382 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
383 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
384 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
385 '\0', NULL
, NULL
, NO_HELP
},
386 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
387 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"), TWO_DASHES
},
388 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
389 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"), TWO_DASHES
},
390 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
391 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"), TWO_DASHES
},
392 { {"stats", no_argument
, NULL
, OPTION_STATS
},
393 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
394 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
395 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
396 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
397 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
398 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
399 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
400 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
401 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"), TWO_DASHES
},
402 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
403 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
404 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
405 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
406 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
407 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
408 { {"unresolved-symbols=<method>", required_argument
, NULL
, OPTION_UNRESOLVED_SYMBOLS
},
409 '\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"),
411 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
412 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
413 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
414 '\0', NULL
, NULL
, NO_HELP
},
415 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
416 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
417 { {"version-exports-section", required_argument
, NULL
,
418 OPTION_VERSION_EXPORTS_SECTION
},
419 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n\t\t\t\tSYMBOL as the version."),
421 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
422 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
423 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
424 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
426 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
427 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
428 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
429 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
430 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
431 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
433 { {"warn-unresolved-symbols", no_argument
, NULL
, OPTION_WARN_UNRESOLVED_SYMBOLS
},
434 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
435 { {"error-unresolved-symbols", no_argument
, NULL
, OPTION_ERROR_UNRESOLVED_SYMBOLS
},
436 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
437 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
438 '\0', NULL
, N_("Treat warnings as errors"),
440 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
441 '\0', NULL
, N_("Include all objects from following archives"), TWO_DASHES
},
442 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
443 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
444 { {"mpc860c0", optional_argument
, NULL
, OPTION_MPC860C0
},
445 '\0', N_("[=WORDS]"), N_("Modify problematic branches in last WORDS (1-10,\n\t\t\t\tdefault 5) words of a page"), TWO_DASHES
}
448 #define OPTION_COUNT ARRAY_SIZE (ld_options)
450 /* Test STRING for containing a string of digits that form a number
451 between MIN and MAX. The return value is the number or ERR. */
454 is_num (const char *string
, int min
, int max
, int err
)
458 for (; *string
; ++string
)
460 if (! ISDIGIT (*string
))
465 result
= result
* 10 + (*string
- '0');
467 if (result
< min
|| result
> max
)
474 parse_args (unsigned argc
, char **argv
)
479 char *default_dirlist
= NULL
;
481 struct option
*longopts
;
482 struct option
*really_longopts
;
484 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
486 shortopts
= xmalloc (OPTION_COUNT
* 3 + 2);
487 longopts
= xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
488 really_longopts
= xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
490 /* Starting the short option string with '-' is for programs that
491 expect options and other ARGV-elements in any order and that care about
492 the ordering of the two. We describe each non-option ARGV-element
493 as if it were the argument of an option with character code 1. */
498 for (i
= 0; i
< OPTION_COUNT
; i
++)
500 if (ld_options
[i
].shortopt
!= '\0')
502 shortopts
[is
] = ld_options
[i
].shortopt
;
504 if (ld_options
[i
].opt
.has_arg
== required_argument
505 || ld_options
[i
].opt
.has_arg
== optional_argument
)
509 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
516 if (ld_options
[i
].opt
.name
!= NULL
)
518 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
520 really_longopts
[irl
] = ld_options
[i
].opt
;
525 longopts
[il
] = ld_options
[i
].opt
;
530 shortopts
[is
] = '\0';
531 longopts
[il
].name
= NULL
;
532 really_longopts
[irl
].name
= NULL
;
534 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
536 /* The -G option is ambiguous on different platforms. Sometimes it
537 specifies the largest data size to put into the small data
538 section. Sometimes it is equivalent to --shared. Unfortunately,
539 the first form takes an argument, while the second does not.
541 We need to permit the --shared form because on some platforms,
542 such as Solaris, gcc -shared will pass -G to the linker.
544 To permit either usage, we look through the argument list. If we
545 find -G not followed by a number, we change it into --shared.
546 This will work for most normal cases. */
547 for (i
= 1; i
< argc
; i
++)
548 if (strcmp (argv
[i
], "-G") == 0
550 || ! ISDIGIT (argv
[i
+ 1][0])))
551 argv
[i
] = (char *) "--shared";
553 /* Because we permit long options to start with a single dash, and
554 we have a --library option, and the -l option is conventionally
555 used with an immediately following argument, we can have bad
556 results if somebody tries to use -l with a library whose name
557 happens to start with "ibrary", as in -li. We avoid problems by
558 simply turning -l into --library. This means that users will
559 have to use two dashes in order to use --library, which is OK
560 since that's how it is documented.
562 FIXME: It's possible that this problem can arise for other short
563 options as well, although the user does always have the recourse
564 of adding a space between the option and the argument. */
565 for (i
= 1; i
< argc
; i
++)
567 if (argv
[i
][0] == '-'
569 && argv
[i
][2] != '\0')
573 n
= xmalloc (strlen (argv
[i
]) + 20);
574 sprintf (n
, "--library=%s", argv
[i
] + 2);
585 /* Using last_optind lets us avoid calling ldemul_parse_args
586 multiple times on a single option, which would lead to
587 confusion in the internal static variables maintained by
588 getopt. This could otherwise happen for an argument like
589 -nx, in which the -n is parsed as a single option, and we
590 loop around to pick up the -x. */
591 if (optind
!= last_optind
)
592 if (ldemul_parse_args (argc
, argv
))
595 /* getopt_long_only is like getopt_long, but '-' as well as '--'
596 can indicate a long option. */
598 last_optind
= optind
;
599 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
602 optind
= last_optind
;
603 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
606 if (ldemul_handle_option (optc
))
615 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
617 einfo (_("%P%F: use the --help option for usage information\n"));
619 case 1: /* File name. */
620 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
626 /* For HP/UX compatibility. Actually -a shared should mean
627 ``use only shared libraries'' but, then, we don't
628 currently support shared libraries on HP/UX anyhow. */
629 if (strcmp (optarg
, "archive") == 0)
630 config
.dynamic_link
= FALSE
;
631 else if (strcmp (optarg
, "shared") == 0
632 || strcmp (optarg
, "default") == 0)
633 config
.dynamic_link
= TRUE
;
635 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
638 /* FIXME: We just ignore these, but we should handle them. */
639 if (strcmp (optarg
, "definitions") == 0)
641 else if (strcmp (optarg
, "nodefinitions") == 0)
643 else if (strcmp (optarg
, "nosymbolic") == 0)
645 else if (strcmp (optarg
, "pure-text") == 0)
648 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
651 ldfile_add_arch (optarg
);
654 lang_add_target (optarg
);
657 ldfile_open_command_file (optarg
);
658 parser_input
= input_mri_script
;
661 case OPTION_CALL_SHARED
:
662 config
.dynamic_link
= TRUE
;
663 /* When linking against shared libraries, the default behaviour is
664 to report any unresolved references. This is for backwards
665 comptability with previous linker behaviour. Whilst strictly
666 speaking it is not a failure to encounter unresolved symbols at
667 link time - the symbol *might* be available at load time - it is
668 nevertheless necessary for the correct execution of the autoconf
669 package. (It needs to be able to detect functions that are not
670 provided by the host OS). Since this package is used by lots of
671 projects, maintaining the old linker behaviour is important. */
672 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
673 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
674 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
675 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
677 case OPTION_NON_SHARED
:
678 config
.dynamic_link
= FALSE
;
679 /* When linking against static libraries, the default
680 behaviour is to report any unresolved references. */
681 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
682 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
683 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
684 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
687 command_line
.cref
= TRUE
;
688 link_info
.notice_all
= TRUE
;
691 command_line
.force_common_definition
= TRUE
;
695 lex_redirect (optarg
);
696 parser_input
= input_defsym
;
702 case OPTION_DEMANGLE
:
706 enum demangling_styles style
;
708 style
= cplus_demangle_name_to_style (optarg
);
709 if (style
== unknown_demangling
)
710 einfo (_("%F%P: unknown demangling style `%s'"),
713 cplus_demangle_set_style (style
);
716 case 'I': /* Used on Solaris. */
717 case OPTION_DYNAMIC_LINKER
:
718 command_line
.interpreter
= optarg
;
721 command_line
.endian
= ENDIAN_BIG
;
724 command_line
.endian
= ENDIAN_LITTLE
;
726 case OPTION_EMBEDDED_RELOCS
:
727 command_line
.embedded_relocs
= TRUE
;
729 case OPTION_EXPORT_DYNAMIC
:
730 case 'E': /* HP/UX compatibility. */
731 link_info
.export_dynamic
= TRUE
;
734 lang_add_entry (optarg
, TRUE
);
737 if (command_line
.auxiliary_filters
== NULL
)
739 command_line
.auxiliary_filters
= xmalloc (2 * sizeof (char *));
740 command_line
.auxiliary_filters
[0] = optarg
;
741 command_line
.auxiliary_filters
[1] = NULL
;
749 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
751 command_line
.auxiliary_filters
752 = xrealloc (command_line
.auxiliary_filters
,
753 (c
+ 2) * sizeof (char *));
754 command_line
.auxiliary_filters
[c
] = optarg
;
755 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
759 command_line
.filter_shlib
= optarg
;
761 case OPTION_FORCE_EXE_SUFFIX
:
762 command_line
.force_exe_suffix
= TRUE
;
767 g_switch_value
= strtoul (optarg
, &end
, 0);
769 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
775 case OPTION_GC_SECTIONS
:
776 command_line
.gc_sections
= TRUE
;
783 ldfile_add_library_path (optarg
, TRUE
);
786 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
789 config
.map_filename
= "-";
792 /* Ignore. Was handled in a pre-parse. */
795 config
.map_filename
= optarg
;
798 config
.text_read_only
= FALSE
;
799 config
.magic_demand_paged
= FALSE
;
800 config
.dynamic_link
= FALSE
;
802 case OPTION_NO_OMAGIC
:
803 config
.text_read_only
= TRUE
;
804 config
.magic_demand_paged
= TRUE
;
805 /* NB/ Does not set dynamic_link to TRUE.
806 Use --call-shared or -Bdynamic for this. */
809 config
.magic_demand_paged
= FALSE
;
810 config
.dynamic_link
= FALSE
;
812 case OPTION_NO_DEFINE_COMMON
:
813 command_line
.inhibit_common_definition
= TRUE
;
815 case OPTION_NO_DEMANGLE
:
818 case OPTION_NO_GC_SECTIONS
:
819 command_line
.gc_sections
= FALSE
;
821 case OPTION_NO_KEEP_MEMORY
:
822 link_info
.keep_memory
= FALSE
;
824 case OPTION_NO_UNDEFINED
:
825 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
827 case OPTION_ALLOW_SHLIB_UNDEFINED
:
828 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
830 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
831 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
833 case OPTION_UNRESOLVED_SYMBOLS
:
834 if (strcmp (optarg
, "ignore-all") == 0)
836 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
837 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
839 else if (strcmp (optarg
, "report-all") == 0)
841 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
842 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
844 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
846 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
847 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
849 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
851 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
852 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
855 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
857 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
858 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
859 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
860 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
861 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
862 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
865 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
866 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
867 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
868 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
869 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
870 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
872 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
873 link_info
.allow_multiple_definition
= TRUE
;
875 case OPTION_NO_UNDEFINED_VERSION
:
876 link_info
.allow_undefined_version
= FALSE
;
878 case OPTION_NO_WARN_MISMATCH
:
879 command_line
.warn_mismatch
= FALSE
;
881 case OPTION_NOINHIBIT_EXEC
:
882 force_make_executable
= TRUE
;
884 case OPTION_NOSTDLIB
:
885 config
.only_cmd_line_lib_dirs
= TRUE
;
887 case OPTION_NO_WHOLE_ARCHIVE
:
888 whole_archive
= FALSE
;
891 /* FIXME "-O<non-digits> <value>" used to set the address of
892 section <non-digits>. Was this for compatibility with
893 something, or can we create a new option to do that
894 (with a syntax similar to -defsym)?
895 getopt can't handle two args to an option without kludges. */
897 /* Enable optimizations of output files. */
898 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
901 lang_add_output (optarg
, 0);
904 lang_add_output_format (optarg
, NULL
, NULL
, 0);
907 link_info
.emitrelocations
= TRUE
;
911 if (optind
== last_optind
)
912 /* This can happen if the user put "-rpath,a" on the command
913 line. (Or something similar. The comma is important).
914 Getopt becomes confused and thinks that this is a -r option
915 but it cannot parse the text after the -r so it refuses to
916 increment the optind counter. Detect this case and issue
917 an error message here. We cannot just make this a warning,
918 increment optind, and continue because getopt is too confused
919 and will seg-fault the next time around. */
920 einfo(_("%P%F: bad -rpath option\n"));
922 link_info
.relocatable
= TRUE
;
923 config
.build_constructors
= FALSE
;
924 config
.magic_demand_paged
= FALSE
;
925 config
.text_read_only
= FALSE
;
926 config
.dynamic_link
= FALSE
;
929 /* The GNU linker traditionally uses -R to mean to include
930 only the symbols from a file. The Solaris linker uses -R
931 to set the path used by the runtime linker to find
932 libraries. This is the GNU linker -rpath argument. We
933 try to support both simultaneously by checking the file
934 named. If it is a directory, rather than a regular file,
935 we assume -rpath was meant. */
939 if (stat (optarg
, &s
) >= 0
940 && ! S_ISDIR (s
.st_mode
))
942 lang_add_input_file (optarg
,
943 lang_input_file_is_symbols_only_enum
,
950 if (command_line
.rpath
== NULL
)
951 command_line
.rpath
= xstrdup (optarg
);
954 size_t rpath_len
= strlen (command_line
.rpath
);
955 size_t optarg_len
= strlen (optarg
);
957 char *cp
= command_line
.rpath
;
959 /* First see whether OPTARG is already in the path. */
964 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
966 if (optarg
[idx
] == '\0'
967 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
972 cp
= strchr (cp
, ':');
980 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
981 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
982 free (command_line
.rpath
);
983 command_line
.rpath
= buf
;
987 case OPTION_RPATH_LINK
:
988 if (command_line
.rpath_link
== NULL
)
989 command_line
.rpath_link
= xstrdup (optarg
);
994 buf
= xmalloc (strlen (command_line
.rpath_link
)
997 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
998 free (command_line
.rpath_link
);
999 command_line
.rpath_link
= buf
;
1003 command_line
.relax
= TRUE
;
1005 case OPTION_RETAIN_SYMBOLS_FILE
:
1006 add_keepsyms_file (optarg
);
1009 link_info
.strip
= strip_debugger
;
1012 link_info
.strip
= strip_all
;
1014 case OPTION_STRIP_DISCARDED
:
1015 link_info
.strip_discarded
= TRUE
;
1017 case OPTION_NO_STRIP_DISCARDED
:
1018 link_info
.strip_discarded
= FALSE
;
1021 if (config
.has_shared
)
1023 link_info
.shared
= TRUE
;
1024 /* When creating a shared library, the default
1025 behaviour is to ignore any unresolved references. */
1026 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1027 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1028 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1029 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1032 einfo (_("%P%F: -shared not supported\n"));
1035 if (config
.has_shared
)
1037 link_info
.shared
= TRUE
;
1038 link_info
.pie
= TRUE
;
1041 einfo (_("%P%F: -pie not supported\n"));
1043 case 'h': /* Used on Solaris. */
1045 command_line
.soname
= optarg
;
1047 case OPTION_SORT_COMMON
:
1048 config
.sort_common
= TRUE
;
1051 config
.stats
= TRUE
;
1053 case OPTION_SYMBOLIC
:
1054 link_info
.symbolic
= TRUE
;
1060 ldfile_open_command_file (optarg
);
1061 parser_input
= input_script
;
1064 case OPTION_SECTION_START
:
1070 /* Check for <something>=<somthing>... */
1071 optarg2
= strchr (optarg
, '=');
1072 if (optarg2
== NULL
)
1073 einfo (_("%P%F: invalid argument to option \"--section-start\"\n"));
1077 /* So far so good. Are all the args present? */
1078 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1079 einfo (_("%P%F: missing argument(s) to option \"--section-start\"\n"));
1081 /* We must copy the section name as set_section_start
1082 doesn't do it for us. */
1083 len
= optarg2
- optarg
;
1084 sec_name
= xmalloc (len
);
1085 memcpy (sec_name
, optarg
, len
- 1);
1086 sec_name
[len
- 1] = 0;
1088 /* Then set it... */
1089 set_section_start (sec_name
, optarg2
);
1092 case OPTION_TARGET_HELP
:
1093 /* Mention any target specific options. */
1094 ldemul_list_emulation_options (stdout
);
1097 set_section_start (".bss", optarg
);
1100 set_section_start (".data", optarg
);
1103 set_section_start (".text", optarg
);
1105 case OPTION_TRADITIONAL_FORMAT
:
1106 link_info
.traditional_format
= TRUE
;
1108 case OPTION_TASK_LINK
:
1109 link_info
.task_link
= TRUE
;
1110 /* Fall through - do an implied -r option. */
1112 link_info
.relocatable
= TRUE
;
1113 config
.build_constructors
= TRUE
;
1114 config
.magic_demand_paged
= FALSE
;
1115 config
.text_read_only
= FALSE
;
1116 config
.dynamic_link
= FALSE
;
1119 ldlang_add_undef (optarg
);
1123 lang_add_unique (optarg
);
1125 config
.unique_orphan_sections
= TRUE
;
1127 case OPTION_VERBOSE
:
1129 version_printed
= TRUE
;
1130 trace_file_tries
= TRUE
;
1131 overflow_cutoff_limit
= -2;
1135 version_printed
= TRUE
;
1139 version_printed
= TRUE
;
1141 case OPTION_VERSION
:
1145 case OPTION_VERSION_SCRIPT
:
1146 /* This option indicates a small script that only specifies
1147 version information. Read it, but don't assume that
1148 we've seen a linker script. */
1150 FILE *hold_script_handle
;
1152 hold_script_handle
= saved_script_handle
;
1153 ldfile_open_command_file (optarg
);
1154 saved_script_handle
= hold_script_handle
;
1155 parser_input
= input_version_script
;
1159 case OPTION_VERSION_EXPORTS_SECTION
:
1160 /* This option records a version symbol to be applied to the
1161 symbols listed for export to be found in the object files
1162 .exports sections. */
1163 command_line
.version_exports_section
= optarg
;
1165 case OPTION_WARN_COMMON
:
1166 config
.warn_common
= TRUE
;
1168 case OPTION_WARN_CONSTRUCTORS
:
1169 config
.warn_constructors
= TRUE
;
1171 case OPTION_WARN_FATAL
:
1172 config
.fatal_warnings
= TRUE
;
1174 case OPTION_WARN_MULTIPLE_GP
:
1175 config
.warn_multiple_gp
= TRUE
;
1177 case OPTION_WARN_ONCE
:
1178 config
.warn_once
= TRUE
;
1180 case OPTION_WARN_SECTION_ALIGN
:
1181 config
.warn_section_align
= TRUE
;
1183 case OPTION_WHOLE_ARCHIVE
:
1184 whole_archive
= TRUE
;
1189 case OPTION_DISCARD_NONE
:
1190 link_info
.discard
= discard_none
;
1193 link_info
.discard
= discard_l
;
1196 link_info
.discard
= discard_all
;
1199 if (strncmp (optarg
, "P,", 2) == 0)
1201 if (default_dirlist
!= NULL
)
1202 free (default_dirlist
);
1203 default_dirlist
= xstrdup (optarg
);
1208 case OPTION_SPARE_DYNAMIC_TAGS
:
1209 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1211 case OPTION_SPLIT_BY_RELOC
:
1213 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1215 config
.split_by_reloc
= 32768;
1217 case OPTION_SPLIT_BY_FILE
:
1219 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1221 config
.split_by_file
= 1;
1223 case OPTION_CHECK_SECTIONS
:
1224 command_line
.check_section_addresses
= TRUE
;
1226 case OPTION_NO_CHECK_SECTIONS
:
1227 command_line
.check_section_addresses
= FALSE
;
1229 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1230 command_line
.accept_unknown_input_arch
= TRUE
;
1232 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1233 command_line
.accept_unknown_input_arch
= FALSE
;
1237 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1239 lang_enter_group ();
1244 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1246 lang_leave_group ();
1249 case OPTION_MPC860C0
:
1250 /* Default value (in bytes). */
1251 link_info
.mpc860c0
= 20;
1256 words
= is_num (optarg
, 1, 10, 0);
1258 einfo (_("%P%F: invalid argument to option \"mpc860c0\"\n"));
1260 /* Convert words to bytes. */
1261 link_info
.mpc860c0
= words
* 4;
1263 command_line
.relax
= TRUE
;
1267 link_info
.init_function
= optarg
;
1271 link_info
.fini_function
= optarg
;
1277 lang_leave_group ();
1279 if (default_dirlist
!= NULL
)
1281 set_default_dirlist (default_dirlist
);
1282 free (default_dirlist
);
1285 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1286 /* FIXME: Should we allow emulations a chance to set this ? */
1287 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1289 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1290 /* FIXME: Should we allow emulations a chance to set this ? */
1291 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1294 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1295 library search path. */
1298 set_default_dirlist (char *dirlist_ptr
)
1304 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1307 if (*dirlist_ptr
!= '\0')
1308 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1311 dirlist_ptr
= p
+ 1;
1316 set_section_start (char *sect
, char *valstr
)
1319 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1321 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1322 lang_section_start (sect
, exp_intop (val
));
1325 /* Print help messages for the options. */
1331 const char **targets
, **pp
;
1333 printf (_("Usage: %s [options] file...\n"), program_name
);
1335 printf (_("Options:\n"));
1336 for (i
= 0; i
< OPTION_COUNT
; i
++)
1338 if (ld_options
[i
].doc
!= NULL
)
1352 if (ld_options
[j
].shortopt
!= '\0'
1353 && ld_options
[j
].control
!= NO_HELP
)
1355 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1356 len
+= (comma
? 2 : 0) + 2;
1357 if (ld_options
[j
].arg
!= NULL
)
1359 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1364 printf ("%s", _(ld_options
[j
].arg
));
1365 len
+= strlen (_(ld_options
[j
].arg
));
1371 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1376 if (ld_options
[j
].opt
.name
!= NULL
1377 && ld_options
[j
].control
!= NO_HELP
)
1380 (ld_options
[j
].control
== TWO_DASHES
1381 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1385 two_dashes
? "-" : "",
1386 ld_options
[j
].opt
.name
);
1387 len
+= ((comma
? 2 : 0)
1389 + (two_dashes
? 1 : 0)
1390 + strlen (ld_options
[j
].opt
.name
));
1391 if (ld_options
[j
].arg
!= NULL
)
1393 printf (" %s", _(ld_options
[j
].arg
));
1394 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1400 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1408 for (; len
< 30; len
++)
1411 printf ("%s\n", _(ld_options
[i
].doc
));
1415 /* Note: Various tools (such as libtool) depend upon the
1416 format of the listings below - do not change them. */
1417 /* xgettext:c-format */
1418 printf (_("%s: supported targets:"), program_name
);
1419 targets
= bfd_target_list ();
1420 for (pp
= targets
; *pp
!= NULL
; pp
++)
1421 printf (" %s", *pp
);
1425 /* xgettext:c-format */
1426 printf (_("%s: supported emulations: "), program_name
);
1427 ldemul_list_emulations (stdout
);
1430 /* xgettext:c-format */
1431 printf (_("%s: emulation specific options:\n"), program_name
);
1432 ldemul_list_emulation_options (stdout
);
1435 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);