1 /* Parse options for the GNU linker.
2 Copyright (C) 1991-2017 Free Software Foundation, Inc.
4 This file is part of the GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
24 #include "libiberty.h"
27 #include "safe-ctype.h"
43 #endif /* ENABLE_PLUGINS */
45 #ifndef PATH_SEPARATOR
46 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
47 #define PATH_SEPARATOR ';'
49 #define PATH_SEPARATOR ':'
53 /* Somewhere above, sys/stat.h got included . . . . */
54 #if !defined(S_ISDIR) && defined(S_IFDIR)
55 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
58 static void set_default_dirlist (char *);
59 static void set_section_start (char *, char *);
60 static void set_segment_start (const char *, char *);
61 static void help (void);
63 /* The long options. This structure is used for both the option
64 parsing and the help text. */
67 /* Use one dash before long option name. */
69 /* Use two dashes before long option name. */
71 /* Only accept two dashes before the long option name.
72 This is an overloading of the use of this enum, since originally it
73 was only intended to tell the --help display function how to display
74 the long option name. This feature was added in order to resolve
75 the confusion about the -omagic command line switch. Is it setting
76 the output file name to "magic" or is it setting the NMAGIC flag on
77 the output ? It has been decided that it is setting the output file
78 name, and that if you want to set the NMAGIC flag you should use -N
81 /* Don't mention this option in --help output. */
87 /* The long option information. */
89 /* The short option with the same meaning ('\0' if none). */
91 /* The name of the argument (NULL if none). */
93 /* The documentation string. If this is NULL, this is a synonym for
94 the previous option. */
96 enum control_enum control
;
99 static const struct ld_option ld_options
[] =
101 { {NULL
, required_argument
, NULL
, '\0'},
102 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
104 { {"architecture", required_argument
, NULL
, 'A'},
105 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
106 { {"format", required_argument
, NULL
, 'b'},
107 'b', N_("TARGET"), N_("Specify target for following input files"),
109 { {"mri-script", required_argument
, NULL
, 'c'},
110 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
111 { {"dc", no_argument
, NULL
, 'd'},
112 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
113 { {"dp", no_argument
, NULL
, 'd'},
114 '\0', NULL
, NULL
, ONE_DASH
},
115 { {"entry", required_argument
, NULL
, 'e'},
116 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
117 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
118 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
119 { {"no-export-dynamic", no_argument
, NULL
, OPTION_NO_EXPORT_DYNAMIC
},
120 '\0', NULL
, N_("Undo the effect of --export-dynamic"), TWO_DASHES
},
121 { {"EB", no_argument
, NULL
, OPTION_EB
},
122 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
123 { {"EL", no_argument
, NULL
, OPTION_EL
},
124 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
125 { {"auxiliary", required_argument
, NULL
, 'f'},
126 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
128 { {"filter", required_argument
, NULL
, 'F'},
129 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
131 { {NULL
, no_argument
, NULL
, '\0'},
132 'g', NULL
, N_("Ignored"), ONE_DASH
},
133 { {"gpsize", required_argument
, NULL
, 'G'},
134 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
136 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
137 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
138 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
139 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
141 { {"no-dynamic-linker", no_argument
, NULL
, OPTION_NO_DYNAMIC_LINKER
},
142 '\0', NULL
, N_("Produce an executable with no program interpreter header"),
144 { {"library", required_argument
, NULL
, 'l'},
145 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
146 { {"library-path", required_argument
, NULL
, 'L'},
147 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
149 { {"sysroot=<DIRECTORY>", required_argument
, NULL
, OPTION_SYSROOT
},
150 '\0', NULL
, N_("Override the default sysroot location"), TWO_DASHES
},
151 { {NULL
, required_argument
, NULL
, '\0'},
152 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
153 { {"print-map", no_argument
, NULL
, 'M'},
154 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
155 { {"nmagic", no_argument
, NULL
, 'n'},
156 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
157 { {"omagic", no_argument
, NULL
, 'N'},
158 'N', NULL
, N_("Do not page align data, do not make text readonly"),
159 EXACTLY_TWO_DASHES
},
160 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
161 '\0', NULL
, N_("Page align data, make text readonly"),
162 EXACTLY_TWO_DASHES
},
163 { {"output", required_argument
, NULL
, 'o'},
164 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
165 { {NULL
, required_argument
, NULL
, '\0'},
166 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
167 { {"out-implib", required_argument
, NULL
, OPTION_OUT_IMPLIB
},
168 '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES
},
169 #ifdef ENABLE_PLUGINS
170 { {"plugin", required_argument
, NULL
, OPTION_PLUGIN
},
171 '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH
},
172 { {"plugin-opt", required_argument
, NULL
, OPTION_PLUGIN_OPT
},
173 '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH
},
174 { {"flto", optional_argument
, NULL
, OPTION_IGNORE
},
175 '\0', NULL
, N_("Ignored for GCC LTO option compatibility"),
177 { {"flto-partition=", required_argument
, NULL
, OPTION_IGNORE
},
178 '\0', NULL
, N_("Ignored for GCC LTO option compatibility"),
180 #endif /* ENABLE_PLUGINS */
181 { {"fuse-ld=", required_argument
, NULL
, OPTION_IGNORE
},
182 '\0', NULL
, N_("Ignored for GCC linker option compatibility"),
184 { {"map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
185 '\0', NULL
, N_("Ignored for gold option compatibility"),
187 { {"no-map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
188 '\0', NULL
, N_("Ignored for gold option compatibility"),
190 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
191 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
192 { {"emit-relocs", no_argument
, NULL
, 'q'},
193 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
194 { {"relocatable", no_argument
, NULL
, 'r'},
195 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
196 { {NULL
, no_argument
, NULL
, '\0'},
197 'i', NULL
, NULL
, ONE_DASH
},
198 { {"just-symbols", required_argument
, NULL
, 'R'},
199 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
201 { {"strip-all", no_argument
, NULL
, 's'},
202 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
203 { {"strip-debug", no_argument
, NULL
, 'S'},
204 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
205 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
206 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
207 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
208 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
209 { {"trace", no_argument
, NULL
, 't'},
210 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
211 { {"script", required_argument
, NULL
, 'T'},
212 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
213 { {"default-script", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
214 '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES
},
215 { {"dT", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
216 '\0', NULL
, NULL
, ONE_DASH
},
217 { {"undefined", required_argument
, NULL
, 'u'},
218 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
220 { {"require-defined", required_argument
, NULL
, OPTION_REQUIRE_DEFINED_SYMBOL
},
221 '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
223 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
224 '\0', N_("[=SECTION]"),
225 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
226 { {"Ur", no_argument
, NULL
, OPTION_UR
},
227 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
228 { {"version", no_argument
, NULL
, OPTION_VERSION
},
229 'v', NULL
, N_("Print version information"), TWO_DASHES
},
230 { {NULL
, no_argument
, NULL
, '\0'},
231 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
232 { {"discard-all", no_argument
, NULL
, 'x'},
233 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
234 { {"discard-locals", no_argument
, NULL
, 'X'},
235 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
236 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
237 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
238 { {"trace-symbol", required_argument
, NULL
, 'y'},
239 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
240 { {NULL
, required_argument
, NULL
, '\0'},
241 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
243 { {"start-group", no_argument
, NULL
, '('},
244 '(', NULL
, N_("Start a group"), TWO_DASHES
},
245 { {"end-group", no_argument
, NULL
, ')'},
246 ')', NULL
, N_("End a group"), TWO_DASHES
},
247 { {"accept-unknown-input-arch", no_argument
, NULL
,
248 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
250 N_("Accept input files whose architecture cannot be determined"),
252 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
253 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
254 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
257 /* The next two options are deprecated because of their similarity to
258 --as-needed and --no-as-needed. They have been replaced by
259 --copy-dt-needed-entries and --no-copy-dt-needed-entries. */
260 { {"add-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
261 '\0', NULL
, NULL
, NO_HELP
},
262 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
263 '\0', NULL
, NULL
, NO_HELP
},
265 { {"as-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_REGULAR
},
266 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
268 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
},
269 '\0', NULL
, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
270 " the command line"),
272 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
273 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
274 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
275 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
276 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
277 '\0', NULL
, NULL
, ONE_DASH
},
278 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
279 '\0', NULL
, NULL
, ONE_DASH
},
280 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
281 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
282 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
283 '\0', NULL
, NULL
, ONE_DASH
},
284 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
285 '\0', NULL
, NULL
, ONE_DASH
},
286 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
287 '\0', NULL
, NULL
, ONE_DASH
},
288 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
289 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
290 { {"Bsymbolic-functions", no_argument
, NULL
, OPTION_SYMBOLIC_FUNCTIONS
},
291 '\0', NULL
, N_("Bind global function references locally"), ONE_DASH
},
292 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
293 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
295 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
296 '\0', NULL
, N_("Do not check section addresses for overlaps"),
298 { {"copy-dt-needed-entries", no_argument
, NULL
,
299 OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
300 '\0', NULL
, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
302 { {"no-copy-dt-needed-entries", no_argument
, NULL
,
303 OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
304 '\0', NULL
, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
307 { {"cref", no_argument
, NULL
, OPTION_CREF
},
308 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
309 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
310 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
311 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
312 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
314 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
315 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
316 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
317 '\0', NULL
, N_("Treat warnings as errors"),
319 { {"no-fatal-warnings", no_argument
, NULL
, OPTION_NO_WARN_FATAL
},
320 '\0', NULL
, N_("Do not treat warnings as errors (default)"),
322 { {"fini", required_argument
, NULL
, OPTION_FINI
},
323 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
324 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
325 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
326 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
327 '\0', NULL
, N_("Remove unused sections (on some targets)"),
329 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
330 '\0', NULL
, N_("Don't remove unused sections (default)"),
332 { {"print-gc-sections", no_argument
, NULL
, OPTION_PRINT_GC_SECTIONS
},
333 '\0', NULL
, N_("List removed unused sections on stderr"),
335 { {"no-print-gc-sections", no_argument
, NULL
, OPTION_NO_PRINT_GC_SECTIONS
},
336 '\0', NULL
, N_("Do not list removed unused sections"),
338 { {"gc-keep-exported", no_argument
, NULL
, OPTION_GC_KEEP_EXPORTED
},
339 '\0', NULL
, N_("Keep exported symbols when removing unused sections"),
341 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
342 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
344 { {"help", no_argument
, NULL
, OPTION_HELP
},
345 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
346 { {"init", required_argument
, NULL
, OPTION_INIT
},
347 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
348 { {"Map", required_argument
, NULL
, OPTION_MAP
},
349 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
350 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
351 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
352 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
353 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
354 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
355 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
356 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
357 '\0', NULL
, N_("Do not allow unresolved references in object files"),
359 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
360 '\0', NULL
, N_("Allow unresolved references in shared libraries"),
362 { {"no-allow-shlib-undefined", no_argument
, NULL
,
363 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
364 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
366 { {"allow-multiple-definition", no_argument
, NULL
,
367 OPTION_ALLOW_MULTIPLE_DEFINITION
},
368 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
369 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
370 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
371 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
372 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
373 { {"default-imported-symver", no_argument
, NULL
,
374 OPTION_DEFAULT_IMPORTED_SYMVER
},
375 '\0', NULL
, N_("Create default symbol version for imported symbols"),
377 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
378 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
379 { {"no-warn-search-mismatch", no_argument
, NULL
,
380 OPTION_NO_WARN_SEARCH_MISMATCH
},
381 '\0', NULL
, N_("Don't warn on finding an incompatible library"),
383 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
384 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
385 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
386 '\0', NULL
, N_("Create an output file even if errors occur"),
388 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
389 '\0', NULL
, NULL
, NO_HELP
},
390 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
391 '\0', NULL
, N_("Only use library directories specified on\n"
392 " the command line"),
394 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
395 '\0', N_("TARGET"), N_("Specify target of output file"),
396 EXACTLY_TWO_DASHES
},
397 { {"print-output-format", no_argument
, NULL
, OPTION_PRINT_OUTPUT_FORMAT
},
398 '\0', NULL
, N_("Print default output format"), TWO_DASHES
},
399 { {"print-sysroot", no_argument
, NULL
, OPTION_PRINT_SYSROOT
},
400 '\0', NULL
, N_("Print current sysroot"), TWO_DASHES
},
401 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
402 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
403 { {"reduce-memory-overheads", no_argument
, NULL
,
404 OPTION_REDUCE_MEMORY_OVERHEADS
},
405 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
407 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
408 '\0', NULL
, N_("Reduce code size by using target specific optimizations"), TWO_DASHES
},
409 { {"no-relax", no_argument
, NULL
, OPTION_NO_RELAX
},
410 '\0', NULL
, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES
},
411 { {"retain-symbols-file", required_argument
, NULL
,
412 OPTION_RETAIN_SYMBOLS_FILE
},
413 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
414 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
415 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
416 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
417 '\0', N_("PATH"), N_("Set link time shared library search path"),
419 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
420 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
421 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
422 '\0', NULL
, NULL
, ONE_DASH
},
423 { {"pie", no_argument
, NULL
, OPTION_PIE
},
424 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
425 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
426 '\0', NULL
, NULL
, TWO_DASHES
},
427 { {"sort-common", optional_argument
, NULL
, OPTION_SORT_COMMON
},
428 '\0', N_("[=ascending|descending]"),
429 N_("Sort common symbols by alignment [in specified order]"),
431 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
432 '\0', NULL
, NULL
, NO_HELP
},
433 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
434 '\0', N_("name|alignment"),
435 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
436 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
437 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
439 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
440 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
442 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
443 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
445 { {"stats", no_argument
, NULL
, OPTION_STATS
},
446 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
447 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
448 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
449 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
450 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
451 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
452 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
453 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
454 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
456 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
457 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
458 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
459 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
460 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
461 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
462 { {"Ttext-segment", required_argument
, NULL
, OPTION_TTEXT_SEGMENT
},
463 '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH
},
464 { {"Trodata-segment", required_argument
, NULL
, OPTION_TRODATA_SEGMENT
},
465 '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH
},
466 { {"Tldata-segment", required_argument
, NULL
, OPTION_TLDATA_SEGMENT
},
467 '\0', N_("ADDRESS"), N_("Set address of ldata segment"), ONE_DASH
},
468 { {"unresolved-symbols=<method>", required_argument
, NULL
,
469 OPTION_UNRESOLVED_SYMBOLS
},
470 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
471 " ignore-all, report-all, ignore-in-object-files,\n"
472 " ignore-in-shared-libs"),
474 { {"verbose", optional_argument
, NULL
, OPTION_VERBOSE
},
475 '\0', N_("[=NUMBER]"),
476 N_("Output lots of information during link"), TWO_DASHES
},
477 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
478 '\0', NULL
, NULL
, NO_HELP
},
479 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
480 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
481 { {"version-exports-section", required_argument
, NULL
,
482 OPTION_VERSION_EXPORTS_SECTION
},
483 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
484 " SYMBOL as the version."),
486 { {"dynamic-list-data", no_argument
, NULL
, OPTION_DYNAMIC_LIST_DATA
},
487 '\0', NULL
, N_("Add data symbols to dynamic list"), TWO_DASHES
},
488 { {"dynamic-list-cpp-new", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_NEW
},
489 '\0', NULL
, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES
},
490 { {"dynamic-list-cpp-typeinfo", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_TYPEINFO
},
491 '\0', NULL
, N_("Use C++ typeinfo dynamic list"), TWO_DASHES
},
492 { {"dynamic-list", required_argument
, NULL
, OPTION_DYNAMIC_LIST
},
493 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES
},
494 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
495 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
496 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
497 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
499 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
500 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
501 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
502 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
503 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
504 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
506 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_SHARED_TEXTREL
},
507 '\0', NULL
, N_("Warn if shared object has DT_TEXTREL"),
509 { {"warn-alternate-em", no_argument
, NULL
, OPTION_WARN_ALTERNATE_EM
},
510 '\0', NULL
, N_("Warn if an object has alternate ELF machine code"),
512 { {"warn-unresolved-symbols", no_argument
, NULL
,
513 OPTION_WARN_UNRESOLVED_SYMBOLS
},
514 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
515 { {"error-unresolved-symbols", no_argument
, NULL
,
516 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
517 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
518 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
519 '\0', NULL
, N_("Include all objects from following archives"),
521 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
522 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
523 { {"ignore-unresolved-symbol", required_argument
, NULL
,
524 OPTION_IGNORE_UNRESOLVED_SYMBOL
},
526 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES
},
527 { {"push-state", no_argument
, NULL
, OPTION_PUSH_STATE
},
528 '\0', NULL
, N_("Push state of flags governing input file handling"),
530 { {"pop-state", no_argument
, NULL
, OPTION_POP_STATE
},
531 '\0', NULL
, N_("Pop state of flags governing input file handling"),
533 { {"print-memory-usage", no_argument
, NULL
, OPTION_PRINT_MEMORY_USAGE
},
534 '\0', NULL
, N_("Report target memory usage"), TWO_DASHES
},
535 { {"orphan-handling", required_argument
, NULL
, OPTION_ORPHAN_HANDLING
},
536 '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
540 #define OPTION_COUNT ARRAY_SIZE (ld_options)
543 parse_args (unsigned argc
, char **argv
)
548 char *default_dirlist
= NULL
;
550 struct option
*longopts
;
551 struct option
*really_longopts
;
553 enum report_method how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
555 shortopts
= (char *) xmalloc (OPTION_COUNT
* 3 + 2);
556 longopts
= (struct option
*)
557 xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
558 really_longopts
= (struct option
*)
559 malloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
561 /* Starting the short option string with '-' is for programs that
562 expect options and other ARGV-elements in any order and that care about
563 the ordering of the two. We describe each non-option ARGV-element
564 as if it were the argument of an option with character code 1. */
569 for (i
= 0; i
< OPTION_COUNT
; i
++)
571 if (ld_options
[i
].shortopt
!= '\0')
573 shortopts
[is
] = ld_options
[i
].shortopt
;
575 if (ld_options
[i
].opt
.has_arg
== required_argument
576 || ld_options
[i
].opt
.has_arg
== optional_argument
)
580 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
587 if (ld_options
[i
].opt
.name
!= NULL
)
589 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
591 really_longopts
[irl
] = ld_options
[i
].opt
;
596 longopts
[il
] = ld_options
[i
].opt
;
601 shortopts
[is
] = '\0';
602 longopts
[il
].name
= NULL
;
603 really_longopts
[irl
].name
= NULL
;
605 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
607 /* The -G option is ambiguous on different platforms. Sometimes it
608 specifies the largest data size to put into the small data
609 section. Sometimes it is equivalent to --shared. Unfortunately,
610 the first form takes an argument, while the second does not.
612 We need to permit the --shared form because on some platforms,
613 such as Solaris, gcc -shared will pass -G to the linker.
615 To permit either usage, we look through the argument list. If we
616 find -G not followed by a number, we change it into --shared.
617 This will work for most normal cases. */
618 for (i
= 1; i
< argc
; i
++)
619 if (strcmp (argv
[i
], "-G") == 0
621 || ! ISDIGIT (argv
[i
+ 1][0])))
622 argv
[i
] = (char *) "--shared";
624 /* Because we permit long options to start with a single dash, and
625 we have a --library option, and the -l option is conventionally
626 used with an immediately following argument, we can have bad
627 results if somebody tries to use -l with a library whose name
628 happens to start with "ibrary", as in -li. We avoid problems by
629 simply turning -l into --library. This means that users will
630 have to use two dashes in order to use --library, which is OK
631 since that's how it is documented.
633 FIXME: It's possible that this problem can arise for other short
634 options as well, although the user does always have the recourse
635 of adding a space between the option and the argument. */
636 for (i
= 1; i
< argc
; i
++)
638 if (argv
[i
][0] == '-'
640 && argv
[i
][2] != '\0')
644 n
= (char *) xmalloc (strlen (argv
[i
]) + 20);
645 sprintf (n
, "--library=%s", argv
[i
] + 2);
655 static unsigned int defsym_count
;
657 /* Using last_optind lets us avoid calling ldemul_parse_args
658 multiple times on a single option, which would lead to
659 confusion in the internal static variables maintained by
660 getopt. This could otherwise happen for an argument like
661 -nx, in which the -n is parsed as a single option, and we
662 loop around to pick up the -x. */
663 if (optind
!= last_optind
)
664 if (ldemul_parse_args (argc
, argv
))
667 /* getopt_long_only is like getopt_long, but '-' as well as '--'
668 can indicate a long option. */
670 last_optind
= optind
;
671 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
674 optind
= last_optind
;
675 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
678 if (ldemul_handle_option (optc
))
688 /* If the last word on the command line is an option that
689 requires an argument, getopt will refuse to recognise it.
690 Try to catch such options here and issue a more helpful
691 error message than just "unrecognized option". */
694 for (opt
= ARRAY_SIZE (ld_options
); opt
--;)
695 if (ld_options
[opt
].opt
.has_arg
== required_argument
696 /* FIXME: There are a few short options that do not
697 have long equivalents, but which require arguments.
698 We should handle them too. */
699 && ld_options
[opt
].opt
.name
!= NULL
700 && strcmp (argv
[last_optind
] + ld_options
[opt
].control
, ld_options
[opt
].opt
.name
) == 0)
702 einfo (_("%P: %s: missing argument\n"), argv
[last_optind
]);
707 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
712 einfo (_("%P%F: use the --help option for usage information\n"));
715 case 1: /* File name. */
716 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
722 /* For HP/UX compatibility. Actually -a shared should mean
723 ``use only shared libraries'' but, then, we don't
724 currently support shared libraries on HP/UX anyhow. */
725 if (strcmp (optarg
, "archive") == 0)
726 input_flags
.dynamic
= FALSE
;
727 else if (strcmp (optarg
, "shared") == 0
728 || strcmp (optarg
, "default") == 0)
729 input_flags
.dynamic
= TRUE
;
731 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
734 /* FIXME: We just ignore these, but we should handle them. */
735 if (strcmp (optarg
, "definitions") == 0)
737 else if (strcmp (optarg
, "nodefinitions") == 0)
739 else if (strcmp (optarg
, "nosymbolic") == 0)
741 else if (strcmp (optarg
, "pure-text") == 0)
744 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
747 ldfile_add_arch (optarg
);
750 lang_add_target (optarg
);
753 ldfile_open_command_file (optarg
);
754 parser_input
= input_mri_script
;
757 case OPTION_CALL_SHARED
:
758 input_flags
.dynamic
= TRUE
;
760 case OPTION_NON_SHARED
:
761 input_flags
.dynamic
= FALSE
;
764 command_line
.cref
= TRUE
;
765 link_info
.notice_all
= TRUE
;
768 command_line
.force_common_definition
= TRUE
;
772 lex_redirect (optarg
, "--defsym", ++defsym_count
);
773 parser_input
= input_defsym
;
777 case OPTION_DEMANGLE
:
781 enum demangling_styles style
;
783 style
= cplus_demangle_name_to_style (optarg
);
784 if (style
== unknown_demangling
)
785 einfo (_("%F%P: unknown demangling style `%s'\n"),
788 cplus_demangle_set_style (style
);
791 case 'I': /* Used on Solaris. */
792 case OPTION_DYNAMIC_LINKER
:
793 command_line
.interpreter
= optarg
;
794 link_info
.nointerp
= 0;
796 case OPTION_NO_DYNAMIC_LINKER
:
797 link_info
.nointerp
= 1;
800 /* Already handled in ldmain.c. */
803 command_line
.endian
= ENDIAN_BIG
;
806 command_line
.endian
= ENDIAN_LITTLE
;
808 case OPTION_EMBEDDED_RELOCS
:
809 command_line
.embedded_relocs
= TRUE
;
811 case OPTION_EXPORT_DYNAMIC
:
812 case 'E': /* HP/UX compatibility. */
813 link_info
.export_dynamic
= TRUE
;
815 case OPTION_NO_EXPORT_DYNAMIC
:
816 link_info
.export_dynamic
= FALSE
;
819 lang_add_entry (optarg
, TRUE
);
822 if (command_line
.auxiliary_filters
== NULL
)
824 command_line
.auxiliary_filters
= (char **)
825 xmalloc (2 * sizeof (char *));
826 command_line
.auxiliary_filters
[0] = optarg
;
827 command_line
.auxiliary_filters
[1] = NULL
;
835 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
837 command_line
.auxiliary_filters
= (char **)
838 xrealloc (command_line
.auxiliary_filters
,
839 (c
+ 2) * sizeof (char *));
840 command_line
.auxiliary_filters
[c
] = optarg
;
841 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
845 command_line
.filter_shlib
= optarg
;
847 case OPTION_FORCE_EXE_SUFFIX
:
848 command_line
.force_exe_suffix
= TRUE
;
853 g_switch_value
= strtoul (optarg
, &end
, 0);
855 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
861 case OPTION_GC_SECTIONS
:
862 link_info
.gc_sections
= TRUE
;
864 case OPTION_PRINT_GC_SECTIONS
:
865 link_info
.print_gc_sections
= TRUE
;
867 case OPTION_GC_KEEP_EXPORTED
:
868 link_info
.gc_keep_exported
= TRUE
;
875 ldfile_add_library_path (optarg
, TRUE
);
878 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
881 config
.map_filename
= "-";
884 /* Ignore. Was handled in a pre-parse. */
887 config
.map_filename
= optarg
;
890 config
.text_read_only
= FALSE
;
891 config
.magic_demand_paged
= FALSE
;
892 input_flags
.dynamic
= FALSE
;
894 case OPTION_NO_OMAGIC
:
895 config
.text_read_only
= TRUE
;
896 config
.magic_demand_paged
= TRUE
;
897 /* NB/ Does not set input_flags.dynamic to TRUE.
898 Use --call-shared or -Bdynamic for this. */
901 config
.magic_demand_paged
= FALSE
;
902 input_flags
.dynamic
= FALSE
;
904 case OPTION_NO_DEFINE_COMMON
:
905 command_line
.inhibit_common_definition
= TRUE
;
907 case OPTION_NO_DEMANGLE
:
910 case OPTION_NO_GC_SECTIONS
:
911 link_info
.gc_sections
= FALSE
;
913 case OPTION_NO_PRINT_GC_SECTIONS
:
914 link_info
.print_gc_sections
= FALSE
;
916 case OPTION_NO_KEEP_MEMORY
:
917 link_info
.keep_memory
= FALSE
;
919 case OPTION_NO_UNDEFINED
:
920 link_info
.unresolved_syms_in_objects
921 = how_to_report_unresolved_symbols
;
923 case OPTION_ALLOW_SHLIB_UNDEFINED
:
924 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
926 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
927 link_info
.unresolved_syms_in_shared_libs
928 = how_to_report_unresolved_symbols
;
930 case OPTION_UNRESOLVED_SYMBOLS
:
931 if (strcmp (optarg
, "ignore-all") == 0)
933 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
934 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
936 else if (strcmp (optarg
, "report-all") == 0)
938 link_info
.unresolved_syms_in_objects
939 = how_to_report_unresolved_symbols
;
940 link_info
.unresolved_syms_in_shared_libs
941 = how_to_report_unresolved_symbols
;
943 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
945 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
946 link_info
.unresolved_syms_in_shared_libs
947 = how_to_report_unresolved_symbols
;
949 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
951 link_info
.unresolved_syms_in_objects
952 = how_to_report_unresolved_symbols
;
953 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
956 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg
);
958 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
959 how_to_report_unresolved_symbols
= RM_GENERATE_WARNING
;
960 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_ERROR
)
961 link_info
.unresolved_syms_in_objects
= RM_GENERATE_WARNING
;
962 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_ERROR
)
963 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_WARNING
;
966 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
967 how_to_report_unresolved_symbols
= RM_GENERATE_ERROR
;
968 if (link_info
.unresolved_syms_in_objects
== RM_GENERATE_WARNING
)
969 link_info
.unresolved_syms_in_objects
= RM_GENERATE_ERROR
;
970 if (link_info
.unresolved_syms_in_shared_libs
== RM_GENERATE_WARNING
)
971 link_info
.unresolved_syms_in_shared_libs
= RM_GENERATE_ERROR
;
973 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
974 link_info
.allow_multiple_definition
= TRUE
;
976 case OPTION_NO_UNDEFINED_VERSION
:
977 link_info
.allow_undefined_version
= FALSE
;
979 case OPTION_DEFAULT_SYMVER
:
980 link_info
.create_default_symver
= TRUE
;
982 case OPTION_DEFAULT_IMPORTED_SYMVER
:
983 link_info
.default_imported_symver
= TRUE
;
985 case OPTION_NO_WARN_MISMATCH
:
986 command_line
.warn_mismatch
= FALSE
;
988 case OPTION_NO_WARN_SEARCH_MISMATCH
:
989 command_line
.warn_search_mismatch
= FALSE
;
991 case OPTION_NOINHIBIT_EXEC
:
992 force_make_executable
= TRUE
;
994 case OPTION_NOSTDLIB
:
995 config
.only_cmd_line_lib_dirs
= TRUE
;
997 case OPTION_NO_WHOLE_ARCHIVE
:
998 input_flags
.whole_archive
= FALSE
;
1001 /* FIXME "-O<non-digits> <value>" used to set the address of
1002 section <non-digits>. Was this for compatibility with
1003 something, or can we create a new option to do that
1004 (with a syntax similar to -defsym)?
1005 getopt can't handle two args to an option without kludges. */
1007 /* Enable optimizations of output files. */
1008 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
1011 lang_add_output (optarg
, 0);
1013 case OPTION_OFORMAT
:
1014 lang_add_output_format (optarg
, NULL
, NULL
, 0);
1016 case OPTION_OUT_IMPLIB
:
1017 command_line
.out_implib_filename
= xstrdup (optarg
);
1019 case OPTION_PRINT_SYSROOT
:
1024 case OPTION_PRINT_OUTPUT_FORMAT
:
1025 command_line
.print_output_format
= TRUE
;
1027 #ifdef ENABLE_PLUGINS
1029 plugin_opt_plugin (optarg
);
1031 case OPTION_PLUGIN_OPT
:
1032 if (plugin_opt_plugin_arg (optarg
))
1033 einfo (_("%P%F: bad -plugin-opt option\n"));
1035 #endif /* ENABLE_PLUGINS */
1037 link_info
.emitrelocations
= TRUE
;
1041 if (optind
== last_optind
)
1042 /* This can happen if the user put "-rpath,a" on the command
1043 line. (Or something similar. The comma is important).
1044 Getopt becomes confused and thinks that this is a -r option
1045 but it cannot parse the text after the -r so it refuses to
1046 increment the optind counter. Detect this case and issue
1047 an error message here. We cannot just make this a warning,
1048 increment optind, and continue because getopt is too confused
1049 and will seg-fault the next time around. */
1050 einfo(_("%P%F: unrecognised option: %s\n"), argv
[optind
]);
1052 if (bfd_link_pic (&link_info
))
1053 einfo (_("%P%F: -r and %s may not be used together\n"),
1054 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1056 link_info
.type
= type_relocatable
;
1057 config
.build_constructors
= FALSE
;
1058 config
.magic_demand_paged
= FALSE
;
1059 config
.text_read_only
= FALSE
;
1060 input_flags
.dynamic
= FALSE
;
1063 /* The GNU linker traditionally uses -R to mean to include
1064 only the symbols from a file. The Solaris linker uses -R
1065 to set the path used by the runtime linker to find
1066 libraries. This is the GNU linker -rpath argument. We
1067 try to support both simultaneously by checking the file
1068 named. If it is a directory, rather than a regular file,
1069 we assume -rpath was meant. */
1073 if (stat (optarg
, &s
) >= 0
1074 && ! S_ISDIR (s
.st_mode
))
1076 lang_add_input_file (optarg
,
1077 lang_input_file_is_symbols_only_enum
,
1084 if (command_line
.rpath
== NULL
)
1085 command_line
.rpath
= xstrdup (optarg
);
1088 size_t rpath_len
= strlen (command_line
.rpath
);
1089 size_t optarg_len
= strlen (optarg
);
1091 char *cp
= command_line
.rpath
;
1093 /* First see whether OPTARG is already in the path. */
1096 if (strncmp (optarg
, cp
, optarg_len
) == 0
1097 && (cp
[optarg_len
] == 0
1098 || cp
[optarg_len
] == config
.rpath_separator
))
1102 /* Not yet found. */
1103 cp
= strchr (cp
, config
.rpath_separator
);
1111 buf
= (char *) xmalloc (rpath_len
+ optarg_len
+ 2);
1112 sprintf (buf
, "%s%c%s", command_line
.rpath
,
1113 config
.rpath_separator
, optarg
);
1114 free (command_line
.rpath
);
1115 command_line
.rpath
= buf
;
1119 case OPTION_RPATH_LINK
:
1120 if (command_line
.rpath_link
== NULL
)
1121 command_line
.rpath_link
= xstrdup (optarg
);
1126 buf
= (char *) xmalloc (strlen (command_line
.rpath_link
)
1129 sprintf (buf
, "%s%c%s", command_line
.rpath_link
,
1130 config
.rpath_separator
, optarg
);
1131 free (command_line
.rpath_link
);
1132 command_line
.rpath_link
= buf
;
1135 case OPTION_NO_RELAX
:
1141 case OPTION_RETAIN_SYMBOLS_FILE
:
1142 add_keepsyms_file (optarg
);
1145 link_info
.strip
= strip_debugger
;
1148 link_info
.strip
= strip_all
;
1150 case OPTION_STRIP_DISCARDED
:
1151 link_info
.strip_discarded
= TRUE
;
1153 case OPTION_NO_STRIP_DISCARDED
:
1154 link_info
.strip_discarded
= FALSE
;
1157 if (config
.has_shared
)
1159 if (bfd_link_relocatable (&link_info
))
1160 einfo (_("%P%F: -r and -shared may not be used together\n"));
1162 link_info
.type
= type_dll
;
1163 /* When creating a shared library, the default
1164 behaviour is to ignore any unresolved references. */
1165 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1166 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1167 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1168 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1171 einfo (_("%P%F: -shared not supported\n"));
1174 if (config
.has_shared
)
1176 if (bfd_link_relocatable (&link_info
))
1177 einfo (_("%P%F: -r and -pie may not be used together\n"));
1179 link_info
.type
= type_pie
;
1182 einfo (_("%P%F: -pie not supported\n"));
1184 case 'h': /* Used on Solaris. */
1186 if (optarg
[0] == '\0' && command_line
.soname
1187 && command_line
.soname
[0])
1188 einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
1190 command_line
.soname
= optarg
;
1192 case OPTION_SORT_COMMON
:
1194 || strcmp (optarg
, N_("descending")) == 0)
1195 config
.sort_common
= sort_descending
;
1196 else if (strcmp (optarg
, N_("ascending")) == 0)
1197 config
.sort_common
= sort_ascending
;
1199 einfo (_("%P%F: invalid common section sorting option: %s\n"),
1202 case OPTION_SORT_SECTION
:
1203 if (strcmp (optarg
, N_("name")) == 0)
1204 sort_section
= by_name
;
1205 else if (strcmp (optarg
, N_("alignment")) == 0)
1206 sort_section
= by_alignment
;
1208 einfo (_("%P%F: invalid section sorting option: %s\n"),
1212 config
.stats
= TRUE
;
1214 case OPTION_SYMBOLIC
:
1215 command_line
.symbolic
= symbolic
;
1217 case OPTION_SYMBOLIC_FUNCTIONS
:
1218 command_line
.symbolic
= symbolic_functions
;
1224 previous_script_handle
= saved_script_handle
;
1225 ldfile_open_command_file (optarg
);
1226 parser_input
= input_script
;
1228 previous_script_handle
= NULL
;
1230 case OPTION_DEFAULT_SCRIPT
:
1231 command_line
.default_script
= optarg
;
1233 case OPTION_SECTION_START
:
1239 /* Check for <something>=<somthing>... */
1240 optarg2
= strchr (optarg
, '=');
1241 if (optarg2
== NULL
)
1242 einfo (_("%P%F: invalid argument to option"
1243 " \"--section-start\"\n"));
1247 /* So far so good. Are all the args present? */
1248 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1249 einfo (_("%P%F: missing argument(s) to option"
1250 " \"--section-start\"\n"));
1252 /* We must copy the section name as set_section_start
1253 doesn't do it for us. */
1254 len
= optarg2
- optarg
;
1255 sec_name
= (char *) xmalloc (len
);
1256 memcpy (sec_name
, optarg
, len
- 1);
1257 sec_name
[len
- 1] = 0;
1259 /* Then set it... */
1260 set_section_start (sec_name
, optarg2
);
1263 case OPTION_TARGET_HELP
:
1264 /* Mention any target specific options. */
1265 ldemul_list_emulation_options (stdout
);
1268 set_segment_start (".bss", optarg
);
1271 set_segment_start (".data", optarg
);
1274 set_segment_start (".text", optarg
);
1276 case OPTION_TTEXT_SEGMENT
:
1277 set_segment_start (".text-segment", optarg
);
1279 case OPTION_TRODATA_SEGMENT
:
1280 set_segment_start (".rodata-segment", optarg
);
1282 case OPTION_TLDATA_SEGMENT
:
1283 set_segment_start (".ldata-segment", optarg
);
1285 case OPTION_TRADITIONAL_FORMAT
:
1286 link_info
.traditional_format
= TRUE
;
1288 case OPTION_TASK_LINK
:
1289 link_info
.task_link
= TRUE
;
1292 if (bfd_link_pic (&link_info
))
1293 einfo (_("%P%F: -r and %s may not be used together\n"),
1294 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1296 link_info
.type
= type_relocatable
;
1297 config
.build_constructors
= TRUE
;
1298 config
.magic_demand_paged
= FALSE
;
1299 config
.text_read_only
= FALSE
;
1300 input_flags
.dynamic
= FALSE
;
1303 ldlang_add_undef (optarg
, TRUE
);
1305 case OPTION_REQUIRE_DEFINED_SYMBOL
:
1306 ldlang_add_require_defined (optarg
);
1310 lang_add_unique (optarg
);
1312 config
.unique_orphan_sections
= TRUE
;
1314 case OPTION_VERBOSE
:
1316 version_printed
= TRUE
;
1318 overflow_cutoff_limit
= -2;
1322 int level ATTRIBUTE_UNUSED
= strtoul (optarg
, &end
, 0);
1324 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
1325 #ifdef ENABLE_PLUGINS
1326 report_plugin_symbols
= level
> 1;
1327 #endif /* ENABLE_PLUGINS */
1332 version_printed
= TRUE
;
1336 version_printed
= TRUE
;
1338 case OPTION_VERSION
:
1342 case OPTION_VERSION_SCRIPT
:
1343 /* This option indicates a small script that only specifies
1344 version information. Read it, but don't assume that
1345 we've seen a linker script. */
1347 FILE *hold_script_handle
;
1349 hold_script_handle
= saved_script_handle
;
1350 ldfile_open_command_file (optarg
);
1351 saved_script_handle
= hold_script_handle
;
1352 parser_input
= input_version_script
;
1356 case OPTION_VERSION_EXPORTS_SECTION
:
1357 /* This option records a version symbol to be applied to the
1358 symbols listed for export to be found in the object files
1359 .exports sections. */
1360 command_line
.version_exports_section
= optarg
;
1362 case OPTION_DYNAMIC_LIST_DATA
:
1363 command_line
.dynamic_list
= dynamic_list_data
;
1364 if (command_line
.symbolic
== symbolic
)
1365 command_line
.symbolic
= symbolic_unset
;
1367 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO
:
1368 lang_append_dynamic_list_cpp_typeinfo ();
1369 if (command_line
.dynamic_list
!= dynamic_list_data
)
1370 command_line
.dynamic_list
= dynamic_list
;
1371 if (command_line
.symbolic
== symbolic
)
1372 command_line
.symbolic
= symbolic_unset
;
1374 case OPTION_DYNAMIC_LIST_CPP_NEW
:
1375 lang_append_dynamic_list_cpp_new ();
1376 if (command_line
.dynamic_list
!= dynamic_list_data
)
1377 command_line
.dynamic_list
= dynamic_list
;
1378 if (command_line
.symbolic
== symbolic
)
1379 command_line
.symbolic
= symbolic_unset
;
1381 case OPTION_DYNAMIC_LIST
:
1382 /* This option indicates a small script that only specifies
1383 a dynamic list. Read it, but don't assume that we've
1384 seen a linker script. */
1386 FILE *hold_script_handle
;
1388 hold_script_handle
= saved_script_handle
;
1389 ldfile_open_command_file (optarg
);
1390 saved_script_handle
= hold_script_handle
;
1391 parser_input
= input_dynamic_list
;
1394 if (command_line
.dynamic_list
!= dynamic_list_data
)
1395 command_line
.dynamic_list
= dynamic_list
;
1396 if (command_line
.symbolic
== symbolic
)
1397 command_line
.symbolic
= symbolic_unset
;
1399 case OPTION_WARN_COMMON
:
1400 config
.warn_common
= TRUE
;
1402 case OPTION_WARN_CONSTRUCTORS
:
1403 config
.warn_constructors
= TRUE
;
1405 case OPTION_WARN_FATAL
:
1406 config
.fatal_warnings
= TRUE
;
1408 case OPTION_NO_WARN_FATAL
:
1409 config
.fatal_warnings
= FALSE
;
1411 case OPTION_WARN_MULTIPLE_GP
:
1412 config
.warn_multiple_gp
= TRUE
;
1414 case OPTION_WARN_ONCE
:
1415 config
.warn_once
= TRUE
;
1417 case OPTION_WARN_SECTION_ALIGN
:
1418 config
.warn_section_align
= TRUE
;
1420 case OPTION_WARN_SHARED_TEXTREL
:
1421 link_info
.warn_shared_textrel
= TRUE
;
1423 case OPTION_WARN_ALTERNATE_EM
:
1424 link_info
.warn_alternate_em
= TRUE
;
1426 case OPTION_WHOLE_ARCHIVE
:
1427 input_flags
.whole_archive
= TRUE
;
1429 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
:
1430 input_flags
.add_DT_NEEDED_for_dynamic
= TRUE
;
1432 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
:
1433 input_flags
.add_DT_NEEDED_for_dynamic
= FALSE
;
1435 case OPTION_ADD_DT_NEEDED_FOR_REGULAR
:
1436 input_flags
.add_DT_NEEDED_for_regular
= TRUE
;
1438 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
:
1439 input_flags
.add_DT_NEEDED_for_regular
= FALSE
;
1444 case OPTION_IGNORE_UNRESOLVED_SYMBOL
:
1445 add_ignoresym (&link_info
, optarg
);
1447 case OPTION_DISCARD_NONE
:
1448 link_info
.discard
= discard_none
;
1451 link_info
.discard
= discard_l
;
1454 link_info
.discard
= discard_all
;
1457 if (CONST_STRNEQ (optarg
, "P,"))
1459 if (default_dirlist
!= NULL
)
1460 free (default_dirlist
);
1461 default_dirlist
= xstrdup (optarg
);
1466 case OPTION_SPARE_DYNAMIC_TAGS
:
1467 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1469 case OPTION_SPLIT_BY_RELOC
:
1471 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1473 config
.split_by_reloc
= 32768;
1475 case OPTION_SPLIT_BY_FILE
:
1477 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1479 config
.split_by_file
= 1;
1481 case OPTION_CHECK_SECTIONS
:
1482 command_line
.check_section_addresses
= 1;
1484 case OPTION_NO_CHECK_SECTIONS
:
1485 command_line
.check_section_addresses
= 0;
1487 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1488 command_line
.accept_unknown_input_arch
= TRUE
;
1490 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1491 command_line
.accept_unknown_input_arch
= FALSE
;
1494 lang_enter_group ();
1499 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1501 lang_leave_group ();
1506 link_info
.init_function
= optarg
;
1510 link_info
.fini_function
= optarg
;
1513 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1514 link_info
.reduce_memory_overheads
= TRUE
;
1515 if (config
.hash_table_size
== 0)
1516 config
.hash_table_size
= 1021;
1519 case OPTION_HASH_SIZE
:
1521 bfd_size_type new_size
;
1523 new_size
= strtoul (optarg
, NULL
, 0);
1525 config
.hash_table_size
= new_size
;
1527 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1531 case OPTION_PUSH_STATE
:
1532 input_flags
.pushed
= xmemdup (&input_flags
,
1533 sizeof (input_flags
),
1534 sizeof (input_flags
));
1537 case OPTION_POP_STATE
:
1538 if (input_flags
.pushed
== NULL
)
1539 einfo (_("%P%F: no state pushed before popping\n"));
1542 struct lang_input_statement_flags
*oldp
= input_flags
.pushed
;
1543 memcpy (&input_flags
, oldp
, sizeof (input_flags
));
1548 case OPTION_PRINT_MEMORY_USAGE
:
1549 command_line
.print_memory_usage
= TRUE
;
1552 case OPTION_ORPHAN_HANDLING
:
1553 if (strcasecmp (optarg
, "place") == 0)
1554 config
.orphan_handling
= orphan_handling_place
;
1555 else if (strcasecmp (optarg
, "warn") == 0)
1556 config
.orphan_handling
= orphan_handling_warn
;
1557 else if (strcasecmp (optarg
, "error") == 0)
1558 config
.orphan_handling
= orphan_handling_error
;
1559 else if (strcasecmp (optarg
, "discard") == 0)
1560 config
.orphan_handling
= orphan_handling_discard
;
1562 einfo (_("%P%F: invalid argument to option"
1563 " \"--orphan-handling\"\n"));
1568 if (command_line
.soname
&& command_line
.soname
[0] == '\0')
1570 einfo (_("%P: SONAME must not be empty string; ignored\n"));
1571 command_line
.soname
= NULL
;
1576 lang_leave_group ();
1580 if (default_dirlist
!= NULL
)
1582 set_default_dirlist (default_dirlist
);
1583 free (default_dirlist
);
1586 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1587 /* FIXME: Should we allow emulations a chance to set this ? */
1588 link_info
.unresolved_syms_in_objects
= how_to_report_unresolved_symbols
;
1590 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1591 /* FIXME: Should we allow emulations a chance to set this ? */
1592 link_info
.unresolved_syms_in_shared_libs
= how_to_report_unresolved_symbols
;
1594 if (bfd_link_relocatable (&link_info
)
1595 && command_line
.check_section_addresses
< 0)
1596 command_line
.check_section_addresses
= 0;
1598 /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data,
1599 --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and
1600 --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are
1601 for PIC outputs. -Bsymbolic overrides all others and vice versa. */
1602 switch (command_line
.symbolic
)
1604 case symbolic_unset
:
1607 /* -Bsymbolic is for PIC output only. */
1608 if (bfd_link_pic (&link_info
))
1610 link_info
.symbolic
= TRUE
;
1611 /* Should we free the unused memory? */
1612 link_info
.dynamic_list
= NULL
;
1613 command_line
.dynamic_list
= dynamic_list_unset
;
1616 case symbolic_functions
:
1617 /* -Bsymbolic-functions is for PIC output only. */
1618 if (bfd_link_pic (&link_info
))
1619 command_line
.dynamic_list
= dynamic_list_data
;
1623 switch (command_line
.dynamic_list
)
1625 case dynamic_list_unset
:
1627 case dynamic_list_data
:
1628 link_info
.dynamic_data
= TRUE
;
1631 link_info
.dynamic
= TRUE
;
1635 if (!bfd_link_dll (&link_info
))
1637 if (command_line
.filter_shlib
)
1638 einfo (_("%P%F: -F may not be used without -shared\n"));
1639 if (command_line
.auxiliary_filters
)
1640 einfo (_("%P%F: -f may not be used without -shared\n"));
1643 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
1644 don't see how else this can be handled, since in this case we
1645 must preserve all externally visible symbols. */
1646 if (bfd_link_relocatable (&link_info
) && link_info
.strip
== strip_all
)
1648 link_info
.strip
= strip_debugger
;
1649 if (link_info
.discard
== discard_sec_merge
)
1650 link_info
.discard
= discard_all
;
1654 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1655 library search path. */
1658 set_default_dirlist (char *dirlist_ptr
)
1664 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1667 if (*dirlist_ptr
!= '\0')
1668 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1671 dirlist_ptr
= p
+ 1;
1676 set_section_start (char *sect
, char *valstr
)
1679 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1681 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1682 lang_section_start (sect
, exp_intop (val
), NULL
);
1686 set_segment_start (const char *section
, char *valstr
)
1692 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1694 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1695 /* If we already have an entry for this segment, update the existing
1698 for (seg
= segments
; seg
; seg
= seg
->next
)
1699 if (strcmp (seg
->name
, name
) == 0)
1702 lang_section_start (section
, exp_intop (val
), seg
);
1705 /* There was no existing value so we must create a new segment
1707 seg
= (segment_type
*) stat_alloc (sizeof (*seg
));
1711 /* Add it to the linked list of segments. */
1712 seg
->next
= segments
;
1714 /* Historically, -Ttext and friends set the base address of a
1715 particular section. For backwards compatibility, we still do
1716 that. If a SEGMENT_START directive is seen, the section address
1717 assignment will be disabled. */
1718 lang_section_start (section
, exp_intop (val
), seg
);
1722 elf_shlib_list_options (FILE *file
)
1725 --audit=AUDITLIB Specify a library to use for auditing\n"));
1727 -Bgroup Selects group name lookup rules for DSO\n"));
1729 --disable-new-dtags Disable new dynamic tags\n"));
1731 --enable-new-dtags Enable new dynamic tags\n"));
1733 --eh-frame-hdr Create .eh_frame_hdr section\n"));
1735 --no-eh-frame-hdr Do not create .eh_frame_hdr section\n"));
1737 --exclude-libs=LIBS Make all symbols in LIBS hidden\n"));
1739 --hash-style=STYLE Set hash style to sysv, gnu or both\n"));
1741 -P AUDITLIB, --depaudit=AUDITLIB\n" "\
1742 Specify a library to use for auditing dependencies\n"));
1744 -z combreloc Merge dynamic relocs into one section and sort\n"));
1746 -z nocombreloc Don't merge dynamic relocs into one section\n"));
1748 -z global Make symbols in DSO available for subsequently\n\
1749 loaded objects\n"));
1751 -z initfirst Mark DSO to be initialized first at runtime\n"));
1753 -z interpose Mark object to interpose all DSOs but executable\n"));
1755 -z lazy Mark object lazy runtime binding (default)\n"));
1757 -z loadfltr Mark object requiring immediate process\n"));
1759 -z nocopyreloc Don't create copy relocs\n"));
1761 -z nodefaultlib Mark object not to use default search paths\n"));
1763 -z nodelete Mark DSO non-deletable at runtime\n"));
1765 -z nodlopen Mark DSO not available to dlopen\n"));
1767 -z nodump Mark DSO not available to dldump\n"));
1769 -z now Mark object non-lazy runtime binding\n"));
1771 -z origin Mark object requiring immediate $ORIGIN\n\
1772 processing at runtime\n"));
1773 #if DEFAULT_LD_Z_RELRO
1775 -z relro Create RELRO program header (default)\n"));
1777 -z norelro Don't create RELRO program header\n"));
1780 -z relro Create RELRO program header\n"));
1782 -z norelro Don't create RELRO program header (default)\n"));
1785 -z common Generate common symbols with STT_COMMON type\n"));
1787 -z nocommon Generate common symbols with STT_OBJECT type\n"));
1789 -z stacksize=SIZE Set size of stack segment\n"));
1791 -z text Treat DT_TEXTREL in shared object as error\n"));
1793 -z notext Don't treat DT_TEXTREL in shared object as error\n"));
1795 -z textoff Don't treat DT_TEXTREL in shared object as error\n"));
1799 elf_static_list_options (FILE *file
)
1802 --build-id[=STYLE] Generate build ID note\n"));
1804 --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]\n\
1805 Compress DWARF debug sections using zlib\n"));
1806 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
1808 Default: zlib-gabi\n"));
1814 -z common-page-size=SIZE Set common page size to SIZE\n"));
1816 -z max-page-size=SIZE Set maximum page size to SIZE\n"));
1818 -z defs Report unresolved symbols in object files.\n"));
1820 -z muldefs Allow multiple definitions\n"));
1822 -z execstack Mark executable as requiring executable stack\n"));
1824 -z noexecstack Mark executable as not requiring executable stack\n"));
1828 elf_plt_unwind_list_options (FILE *file
)
1831 --ld-generated-unwind-info Generate exception handling info for PLT\n\
1832 --no-ld-generated-unwind-info\n\
1833 Don't generate exception handling info for PLT\n"));
1837 ld_list_options (FILE *file
, bfd_boolean elf
, bfd_boolean shlib
,
1838 bfd_boolean plt_unwind
)
1842 printf (_("ELF emulations:\n"));
1844 elf_plt_unwind_list_options (file
);
1845 elf_static_list_options (file
);
1847 elf_shlib_list_options (file
);
1851 /* Print help messages for the options. */
1857 const char **targets
, **pp
;
1860 printf (_("Usage: %s [options] file...\n"), program_name
);
1862 printf (_("Options:\n"));
1863 for (i
= 0; i
< OPTION_COUNT
; i
++)
1865 if (ld_options
[i
].doc
!= NULL
)
1878 if (ld_options
[j
].shortopt
!= '\0'
1879 && ld_options
[j
].control
!= NO_HELP
)
1881 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1882 len
+= (comma
? 2 : 0) + 2;
1883 if (ld_options
[j
].arg
!= NULL
)
1885 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1890 printf ("%s", _(ld_options
[j
].arg
));
1891 len
+= strlen (_(ld_options
[j
].arg
));
1897 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1902 if (ld_options
[j
].opt
.name
!= NULL
1903 && ld_options
[j
].control
!= NO_HELP
)
1906 (ld_options
[j
].control
== TWO_DASHES
1907 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1911 two_dashes
? "-" : "",
1912 ld_options
[j
].opt
.name
);
1913 len
+= ((comma
? 2 : 0)
1915 + (two_dashes
? 1 : 0)
1916 + strlen (ld_options
[j
].opt
.name
));
1917 if (ld_options
[j
].arg
!= NULL
)
1919 printf (" %s", _(ld_options
[j
].arg
));
1920 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1926 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1934 for (; len
< 30; len
++)
1937 printf ("%s\n", _(ld_options
[i
].doc
));
1940 printf (_(" @FILE"));
1941 for (len
= strlen (" @FILE"); len
< 30; len
++)
1943 printf (_("Read options from FILE\n"));
1945 /* Note: Various tools (such as libtool) depend upon the
1946 format of the listings below - do not change them. */
1947 /* xgettext:c-format */
1948 printf (_("%s: supported targets:"), program_name
);
1949 targets
= bfd_target_list ();
1950 for (pp
= targets
; *pp
!= NULL
; pp
++)
1951 printf (" %s", *pp
);
1955 /* xgettext:c-format */
1956 printf (_("%s: supported emulations: "), program_name
);
1957 ldemul_list_emulations (stdout
);
1960 /* xgettext:c-format */
1961 printf (_("%s: emulation specific options:\n"), program_name
);
1962 ld_list_options (stdout
, ELF_LIST_OPTIONS
, ELF_SHLIB_LIST_OPTIONS
,
1963 ELF_PLT_UNWIND_LIST_OPTIONS
);
1964 ldemul_list_emulation_options (stdout
);
1967 if (REPORT_BUGS_TO
[0])
1968 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);