PR2589, ld vs. ld.so
[deliverable/binutils-gdb.git] / ld / lexsup.c
1 /* Parse options for the GNU linker.
2 Copyright (C) 1991-2021 Free Software Foundation, Inc.
3
4 This file is part of the GNU Binutils.
5
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.
10
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.
15
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. */
20
21 #include "sysdep.h"
22 #include "bfd.h"
23 #include "bfdver.h"
24 #include "libiberty.h"
25 #include "filenames.h"
26 #include <stdio.h>
27 #include <string.h>
28 #include <errno.h>
29 #include "safe-ctype.h"
30 #include "getopt.h"
31 #include "bfdlink.h"
32 #include "ctf-api.h"
33 #include "ld.h"
34 #include "ldmain.h"
35 #include "ldmisc.h"
36 #include "ldexp.h"
37 #include "ldlang.h"
38 #include <ldgram.h>
39 #include "ldlex.h"
40 #include "ldfile.h"
41 #include "ldver.h"
42 #include "ldemul.h"
43 #include "demangle.h"
44 #if BFD_SUPPORTS_PLUGINS
45 #include "plugin.h"
46 #endif /* BFD_SUPPORTS_PLUGINS */
47
48 #ifndef PATH_SEPARATOR
49 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
50 #define PATH_SEPARATOR ';'
51 #else
52 #define PATH_SEPARATOR ':'
53 #endif
54 #endif
55
56 /* Somewhere above, sys/stat.h got included . . . . */
57 #if !defined(S_ISDIR) && defined(S_IFDIR)
58 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
59 #endif
60
61 static void set_default_dirlist (char *);
62 static void set_section_start (char *, char *);
63 static void set_segment_start (const char *, char *);
64 static void help (void);
65
66 /* The long options. This structure is used for both the option
67 parsing and the help text. */
68
69 enum control_enum {
70 /* Use one dash before long option name. */
71 ONE_DASH = 1,
72 /* Use two dashes before long option name. */
73 TWO_DASHES = 2,
74 /* Only accept two dashes before the long option name.
75 This is an overloading of the use of this enum, since originally it
76 was only intended to tell the --help display function how to display
77 the long option name. This feature was added in order to resolve
78 the confusion about the -omagic command line switch. Is it setting
79 the output file name to "magic" or is it setting the NMAGIC flag on
80 the output ? It has been decided that it is setting the output file
81 name, and that if you want to set the NMAGIC flag you should use -N
82 or --omagic. */
83 EXACTLY_TWO_DASHES,
84 /* Don't mention this option in --help output. */
85 NO_HELP
86 };
87
88 struct ld_option
89 {
90 /* The long option information. */
91 struct option opt;
92 /* The short option with the same meaning ('\0' if none). */
93 char shortopt;
94 /* The name of the argument (NULL if none). */
95 const char *arg;
96 /* The documentation string. If this is NULL, this is a synonym for
97 the previous option. */
98 const char *doc;
99 enum control_enum control;
100 };
101
102 static const struct ld_option ld_options[] =
103 {
104 { {NULL, required_argument, NULL, '\0'},
105 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
106 ONE_DASH },
107 { {"architecture", required_argument, NULL, 'A'},
108 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES },
109 { {"format", required_argument, NULL, 'b'},
110 'b', N_("TARGET"), N_("Specify target for following input files"),
111 TWO_DASHES },
112 { {"mri-script", required_argument, NULL, 'c'},
113 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES },
114 { {"dc", no_argument, NULL, 'd'},
115 'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
116 { {"dp", no_argument, NULL, 'd'},
117 '\0', NULL, NULL, ONE_DASH },
118 { {"dependency-file", required_argument, NULL, OPTION_DEPENDENCY_FILE},
119 '\0', N_("FILE"), N_("Write dependency file"), TWO_DASHES },
120 { {"force-group-allocation", no_argument, NULL,
121 OPTION_FORCE_GROUP_ALLOCATION},
122 '\0', NULL, N_("Force group members out of groups"), TWO_DASHES },
123 { {"entry", required_argument, NULL, 'e'},
124 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
125 { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
126 'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
127 { {"no-export-dynamic", no_argument, NULL, OPTION_NO_EXPORT_DYNAMIC},
128 '\0', NULL, N_("Undo the effect of --export-dynamic"), TWO_DASHES },
129 { {"enable-non-contiguous-regions", no_argument, NULL, OPTION_NON_CONTIGUOUS_REGIONS},
130 '\0', NULL, N_("Enable support of non-contiguous memory regions"), TWO_DASHES },
131 { {"enable-non-contiguous-regions-warnings", no_argument, NULL, OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS},
132 '\0', NULL, N_("Enable warnings when --enable-non-contiguous-regions may cause unexpected behaviour"), TWO_DASHES },
133 { {"EB", no_argument, NULL, OPTION_EB},
134 '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
135 { {"EL", no_argument, NULL, OPTION_EL},
136 '\0', NULL, N_("Link little-endian objects"), ONE_DASH },
137 { {"auxiliary", required_argument, NULL, 'f'},
138 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
139 TWO_DASHES },
140 { {"filter", required_argument, NULL, 'F'},
141 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
142 TWO_DASHES },
143 { {NULL, no_argument, NULL, '\0'},
144 'g', NULL, N_("Ignored"), ONE_DASH },
145 { {"gpsize", required_argument, NULL, 'G'},
146 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
147 TWO_DASHES },
148 { {"soname", required_argument, NULL, OPTION_SONAME},
149 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
150 { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
151 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
152 TWO_DASHES },
153 { {"no-dynamic-linker", no_argument, NULL, OPTION_NO_DYNAMIC_LINKER},
154 '\0', NULL, N_("Produce an executable with no program interpreter header"),
155 TWO_DASHES },
156 { {"library", required_argument, NULL, 'l'},
157 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
158 { {"library-path", required_argument, NULL, 'L'},
159 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
160 TWO_DASHES },
161 { {"sysroot=<DIRECTORY>", required_argument, NULL, OPTION_SYSROOT},
162 '\0', NULL, N_("Override the default sysroot location"), TWO_DASHES },
163 { {NULL, required_argument, NULL, '\0'},
164 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH },
165 { {"print-map", no_argument, NULL, 'M'},
166 'M', NULL, N_("Print map file on standard output"), TWO_DASHES },
167 { {"nmagic", no_argument, NULL, 'n'},
168 'n', NULL, N_("Do not page align data"), TWO_DASHES },
169 { {"omagic", no_argument, NULL, 'N'},
170 'N', NULL, N_("Do not page align data, do not make text readonly"),
171 EXACTLY_TWO_DASHES },
172 { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC},
173 '\0', NULL, N_("Page align data, make text readonly"),
174 EXACTLY_TWO_DASHES },
175 { {"output", required_argument, NULL, 'o'},
176 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES },
177 { {NULL, required_argument, NULL, '\0'},
178 'O', NULL, N_("Optimize output file"), ONE_DASH },
179 { {"out-implib", required_argument, NULL, OPTION_OUT_IMPLIB},
180 '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES },
181 #if BFD_SUPPORTS_PLUGINS
182 { {"plugin", required_argument, NULL, OPTION_PLUGIN},
183 '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
184 { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
185 '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
186 { {"flto", optional_argument, NULL, OPTION_IGNORE},
187 '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
188 ONE_DASH },
189 { {"flto-partition=", required_argument, NULL, OPTION_IGNORE},
190 '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
191 ONE_DASH },
192 #else
193 { {"plugin", required_argument, NULL, OPTION_IGNORE},
194 '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH },
195 { {"plugin-opt", required_argument, NULL, OPTION_IGNORE},
196 '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH },
197 #endif /* BFD_SUPPORTS_PLUGINS */
198 { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE},
199 '\0', NULL, N_("Ignored for GCC linker option compatibility"),
200 ONE_DASH },
201 { {"map-whole-files", optional_argument, NULL, OPTION_IGNORE},
202 '\0', NULL, N_("Ignored for gold option compatibility"),
203 TWO_DASHES },
204 { {"no-map-whole-files", optional_argument, NULL, OPTION_IGNORE},
205 '\0', NULL, N_("Ignored for gold option compatibility"),
206 TWO_DASHES },
207 { {"Qy", no_argument, NULL, OPTION_IGNORE},
208 '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
209 { {"emit-relocs", no_argument, NULL, 'q'},
210 'q', NULL, "Generate relocations in final output", TWO_DASHES },
211 { {"relocatable", no_argument, NULL, 'r'},
212 'r', NULL, N_("Generate relocatable output"), TWO_DASHES },
213 { {NULL, no_argument, NULL, '\0'},
214 'i', NULL, NULL, ONE_DASH },
215 { {"just-symbols", required_argument, NULL, 'R'},
216 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
217 TWO_DASHES },
218 { {"strip-all", no_argument, NULL, 's'},
219 's', NULL, N_("Strip all symbols"), TWO_DASHES },
220 { {"strip-debug", no_argument, NULL, 'S'},
221 'S', NULL, N_("Strip debugging symbols"), TWO_DASHES },
222 { {"strip-discarded", no_argument, NULL, OPTION_STRIP_DISCARDED},
223 '\0', NULL, N_("Strip symbols in discarded sections"), TWO_DASHES },
224 { {"no-strip-discarded", no_argument, NULL, OPTION_NO_STRIP_DISCARDED},
225 '\0', NULL, N_("Do not strip symbols in discarded sections"), TWO_DASHES },
226 { {"trace", no_argument, NULL, 't'},
227 't', NULL, N_("Trace file opens"), TWO_DASHES },
228 { {"script", required_argument, NULL, 'T'},
229 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
230 { {"default-script", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
231 '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES },
232 { {"dT", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
233 '\0', NULL, NULL, ONE_DASH },
234 { {"undefined", required_argument, NULL, 'u'},
235 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
236 TWO_DASHES },
237 { {"require-defined", required_argument, NULL, OPTION_REQUIRE_DEFINED_SYMBOL},
238 '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
239 TWO_DASHES },
240 { {"unique", optional_argument, NULL, OPTION_UNIQUE},
241 '\0', N_("[=SECTION]"),
242 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
243 { {"Ur", no_argument, NULL, OPTION_UR},
244 '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
245 { {"version", no_argument, NULL, OPTION_VERSION},
246 'v', NULL, N_("Print version information"), TWO_DASHES },
247 { {NULL, no_argument, NULL, '\0'},
248 'V', NULL, N_("Print version and emulation information"), ONE_DASH },
249 { {"discard-all", no_argument, NULL, 'x'},
250 'x', NULL, N_("Discard all local symbols"), TWO_DASHES },
251 { {"discard-locals", no_argument, NULL, 'X'},
252 'X', NULL, N_("Discard temporary local symbols (default)"), TWO_DASHES },
253 { {"discard-none", no_argument, NULL, OPTION_DISCARD_NONE},
254 '\0', NULL, N_("Don't discard any local symbols"), TWO_DASHES },
255 { {"trace-symbol", required_argument, NULL, 'y'},
256 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
257 { {NULL, required_argument, NULL, '\0'},
258 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
259 ONE_DASH },
260 { {"start-group", no_argument, NULL, '('},
261 '(', NULL, N_("Start a group"), TWO_DASHES },
262 { {"end-group", no_argument, NULL, ')'},
263 ')', NULL, N_("End a group"), TWO_DASHES },
264 { {"accept-unknown-input-arch", no_argument, NULL,
265 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH},
266 '\0', NULL,
267 N_("Accept input files whose architecture cannot be determined"),
268 TWO_DASHES },
269 { {"no-accept-unknown-input-arch", no_argument, NULL,
270 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
271 '\0', NULL, N_("Reject input files whose architecture is unknown"),
272 TWO_DASHES },
273
274 /* The next two options are deprecated because of their similarity to
275 --as-needed and --no-as-needed. They have been replaced by
276 --copy-dt-needed-entries and --no-copy-dt-needed-entries. */
277 { {"add-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
278 '\0', NULL, NULL, NO_HELP },
279 { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
280 '\0', NULL, NULL, NO_HELP },
281
282 { {"as-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_REGULAR},
283 '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
284 TWO_DASHES },
285 { {"no-as-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR},
286 '\0', NULL, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
287 " the command line"),
288 TWO_DASHES },
289 { {"assert", required_argument, NULL, OPTION_ASSERT},
290 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
291 { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
292 '\0', NULL, N_("Link against shared libraries"), ONE_DASH },
293 { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
294 '\0', NULL, NULL, ONE_DASH },
295 { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
296 '\0', NULL, NULL, ONE_DASH },
297 { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
298 '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
299 { {"dn", no_argument, NULL, OPTION_NON_SHARED},
300 '\0', NULL, NULL, ONE_DASH },
301 { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
302 '\0', NULL, NULL, ONE_DASH },
303 { {"static", no_argument, NULL, OPTION_NON_SHARED},
304 '\0', NULL, NULL, ONE_DASH },
305 { {"Bno-symbolic", no_argument, NULL, OPTION_NO_SYMBOLIC},
306 '\0', NULL, N_("Don't bind global references locally"), ONE_DASH },
307 { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
308 '\0', NULL, N_("Bind global references locally"), ONE_DASH },
309 { {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS},
310 '\0', NULL, N_("Bind global function references locally"), ONE_DASH },
311 { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
312 '\0', NULL, N_("Check section addresses for overlaps (default)"),
313 TWO_DASHES },
314 { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
315 '\0', NULL, N_("Do not check section addresses for overlaps"),
316 TWO_DASHES },
317 { {"copy-dt-needed-entries", no_argument, NULL,
318 OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
319 '\0', NULL, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
320 TWO_DASHES },
321 { {"no-copy-dt-needed-entries", no_argument, NULL,
322 OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
323 '\0', NULL, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
324 TWO_DASHES },
325
326 { {"cref", no_argument, NULL, OPTION_CREF},
327 '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
328 { {"defsym", required_argument, NULL, OPTION_DEFSYM},
329 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
330 { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
331 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
332 TWO_DASHES },
333 { {"disable-multiple-abs-defs", no_argument, NULL,
334 OPTION_DISABLE_MULTIPLE_DEFS_ABS},
335 '\0', NULL, N_("Do not allow multiple definitions with symbols included\n"
336 " in filename invoked by -R or --just-symbols"),
337 TWO_DASHES},
338 { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
339 '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
340 { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
341 '\0', NULL, N_("Treat warnings as errors"),
342 TWO_DASHES },
343 { {"no-fatal-warnings", no_argument, NULL, OPTION_NO_WARN_FATAL},
344 '\0', NULL, N_("Do not treat warnings as errors (default)"),
345 TWO_DASHES },
346 { {"fini", required_argument, NULL, OPTION_FINI},
347 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
348 { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
349 '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
350 { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
351 '\0', NULL, N_("Remove unused sections (on some targets)"),
352 TWO_DASHES },
353 { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
354 '\0', NULL, N_("Don't remove unused sections (default)"),
355 TWO_DASHES },
356 { {"print-gc-sections", no_argument, NULL, OPTION_PRINT_GC_SECTIONS},
357 '\0', NULL, N_("List removed unused sections on stderr"),
358 TWO_DASHES },
359 { {"no-print-gc-sections", no_argument, NULL, OPTION_NO_PRINT_GC_SECTIONS},
360 '\0', NULL, N_("Do not list removed unused sections"),
361 TWO_DASHES },
362 { {"gc-keep-exported", no_argument, NULL, OPTION_GC_KEEP_EXPORTED},
363 '\0', NULL, N_("Keep exported symbols when removing unused sections"),
364 TWO_DASHES },
365 { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
366 '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
367 TWO_DASHES },
368 { {"help", no_argument, NULL, OPTION_HELP},
369 '\0', NULL, N_("Print option help"), TWO_DASHES },
370 { {"init", required_argument, NULL, OPTION_INIT},
371 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
372 { {"Map", required_argument, NULL, OPTION_MAP},
373 '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH },
374 { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
375 '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
376 { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
377 '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
378 { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
379 '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES },
380 { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
381 '\0', NULL, N_("Do not allow unresolved references in object files"),
382 TWO_DASHES },
383 { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED},
384 '\0', NULL, N_("Allow unresolved references in shared libraries"),
385 TWO_DASHES },
386 { {"no-allow-shlib-undefined", no_argument, NULL,
387 OPTION_NO_ALLOW_SHLIB_UNDEFINED},
388 '\0', NULL, N_("Do not allow unresolved references in shared libs"),
389 TWO_DASHES },
390 { {"allow-multiple-definition", no_argument, NULL,
391 OPTION_ALLOW_MULTIPLE_DEFINITION},
392 '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES },
393 #if SUPPORT_ERROR_HANDLING_SCRIPT
394 { {"error-handling-script", required_argument, NULL,
395 OPTION_ERROR_HANDLING_SCRIPT},
396 '\0', N_("SCRIPT"), N_("Provide a script to help with undefined symbol errors"), TWO_DASHES},
397 #endif
398 { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
399 '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
400 { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER},
401 '\0', NULL, N_("Create default symbol version"), TWO_DASHES },
402 { {"default-imported-symver", no_argument, NULL,
403 OPTION_DEFAULT_IMPORTED_SYMVER},
404 '\0', NULL, N_("Create default symbol version for imported symbols"),
405 TWO_DASHES },
406 { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
407 '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
408 { {"no-warn-search-mismatch", no_argument, NULL,
409 OPTION_NO_WARN_SEARCH_MISMATCH},
410 '\0', NULL, N_("Don't warn on finding an incompatible library"),
411 TWO_DASHES},
412 { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
413 '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
414 { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
415 '\0', NULL, N_("Create an output file even if errors occur"),
416 TWO_DASHES },
417 { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
418 '\0', NULL, NULL, NO_HELP },
419 { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB},
420 '\0', NULL, N_("Only use library directories specified on\n"
421 " the command line"),
422 ONE_DASH },
423 { {"oformat", required_argument, NULL, OPTION_OFORMAT},
424 '\0', N_("TARGET"), N_("Specify target of output file"),
425 EXACTLY_TWO_DASHES },
426 { {"print-output-format", no_argument, NULL, OPTION_PRINT_OUTPUT_FORMAT},
427 '\0', NULL, N_("Print default output format"), TWO_DASHES },
428 { {"print-sysroot", no_argument, NULL, OPTION_PRINT_SYSROOT},
429 '\0', NULL, N_("Print current sysroot"), TWO_DASHES },
430 { {"qmagic", no_argument, NULL, OPTION_IGNORE},
431 '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
432 { {"reduce-memory-overheads", no_argument, NULL,
433 OPTION_REDUCE_MEMORY_OVERHEADS},
434 '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
435 TWO_DASHES },
436 { {"relax", no_argument, NULL, OPTION_RELAX},
437 '\0', NULL, N_("Reduce code size by using target specific optimizations"), TWO_DASHES },
438 { {"no-relax", no_argument, NULL, OPTION_NO_RELAX},
439 '\0', NULL, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES },
440 { {"retain-symbols-file", required_argument, NULL,
441 OPTION_RETAIN_SYMBOLS_FILE},
442 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
443 { {"rpath", required_argument, NULL, OPTION_RPATH},
444 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH },
445 { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
446 '\0', N_("PATH"), N_("Set link time shared library search path"),
447 ONE_DASH },
448 { {"shared", no_argument, NULL, OPTION_SHARED},
449 '\0', NULL, N_("Create a shared library"), ONE_DASH },
450 { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */
451 '\0', NULL, NULL, ONE_DASH },
452 { {"pie", no_argument, NULL, OPTION_PIE},
453 '\0', NULL, N_("Create a position independent executable"), ONE_DASH },
454 { {"pic-executable", no_argument, NULL, OPTION_PIE},
455 '\0', NULL, NULL, TWO_DASHES },
456 { {"sort-common", optional_argument, NULL, OPTION_SORT_COMMON},
457 '\0', N_("[=ascending|descending]"),
458 N_("Sort common symbols by alignment [in specified order]"),
459 TWO_DASHES },
460 { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
461 '\0', NULL, NULL, NO_HELP },
462 { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
463 '\0', N_("name|alignment"),
464 N_("Sort sections by name or maximum alignment"), TWO_DASHES },
465 { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
466 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
467 TWO_DASHES },
468 { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE},
469 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
470 TWO_DASHES },
471 { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC},
472 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
473 TWO_DASHES },
474 { {"stats", no_argument, NULL, OPTION_STATS},
475 '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
476 { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
477 '\0', NULL, N_("Display target specific options"), TWO_DASHES },
478 { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
479 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
480 { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
481 '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
482 { {"section-start", required_argument, NULL, OPTION_SECTION_START},
483 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
484 TWO_DASHES },
485 { {"Tbss", required_argument, NULL, OPTION_TBSS},
486 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
487 { {"Tdata", required_argument, NULL, OPTION_TDATA},
488 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
489 { {"Ttext", required_argument, NULL, OPTION_TTEXT},
490 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
491 { {"Ttext-segment", required_argument, NULL, OPTION_TTEXT_SEGMENT},
492 '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH },
493 { {"Trodata-segment", required_argument, NULL, OPTION_TRODATA_SEGMENT},
494 '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH },
495 { {"Tldata-segment", required_argument, NULL, OPTION_TLDATA_SEGMENT},
496 '\0', N_("ADDRESS"), N_("Set address of ldata segment"), ONE_DASH },
497 { {"unresolved-symbols=<method>", required_argument, NULL,
498 OPTION_UNRESOLVED_SYMBOLS},
499 '\0', NULL, N_("How to handle unresolved symbols. <method> is:\n"
500 " ignore-all, report-all, ignore-in-object-files,\n"
501 " ignore-in-shared-libs"),
502 TWO_DASHES },
503 { {"verbose", optional_argument, NULL, OPTION_VERBOSE},
504 '\0', N_("[=NUMBER]"),
505 N_("Output lots of information during link"), TWO_DASHES },
506 { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */
507 '\0', NULL, NULL, NO_HELP },
508 { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
509 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
510 { {"version-exports-section", required_argument, NULL,
511 OPTION_VERSION_EXPORTS_SECTION },
512 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
513 " SYMBOL as the version."),
514 TWO_DASHES },
515 { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
516 '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
517 { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
518 '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES },
519 { {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
520 '\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
521 { {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
522 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
523 { {"export-dynamic-symbol", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL},
524 '\0', N_("SYMBOL"), N_("Export the specified symbol"), EXACTLY_TWO_DASHES },
525 { {"export-dynamic-symbol-list", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL_LIST},
526 '\0', N_("FILE"), N_("Read export dynamic symbol list"), EXACTLY_TWO_DASHES },
527 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
528 '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
529 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
530 '\0', NULL, N_("Warn if global constructors/destructors are seen"),
531 TWO_DASHES },
532 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
533 '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
534 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
535 '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
536 { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
537 '\0', NULL, N_("Warn if start of section changes due to alignment"),
538 TWO_DASHES },
539 { {"warn-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
540 '\0', NULL,
541 #if DEFAULT_LD_TEXTREL_CHECK_WARNING
542 N_("Warn if output has DT_TEXTREL (default)"),
543 #else
544 N_("Warn if output has DT_TEXTREL"),
545 #endif
546 TWO_DASHES },
547 { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
548 '\0', NULL, NULL, NO_HELP },
549 { {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM},
550 '\0', NULL, N_("Warn if an object has alternate ELF machine code"),
551 TWO_DASHES },
552 { {"warn-unresolved-symbols", no_argument, NULL,
553 OPTION_WARN_UNRESOLVED_SYMBOLS},
554 '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
555 { {"error-unresolved-symbols", no_argument, NULL,
556 OPTION_ERROR_UNRESOLVED_SYMBOLS},
557 '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES },
558 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
559 '\0', NULL, N_("Include all objects from following archives"),
560 TWO_DASHES },
561 { {"wrap", required_argument, NULL, OPTION_WRAP},
562 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
563 { {"ignore-unresolved-symbol", required_argument, NULL,
564 OPTION_IGNORE_UNRESOLVED_SYMBOL},
565 '\0', N_("SYMBOL"),
566 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
567 { {"push-state", no_argument, NULL, OPTION_PUSH_STATE},
568 '\0', NULL, N_("Push state of flags governing input file handling"),
569 TWO_DASHES },
570 { {"pop-state", no_argument, NULL, OPTION_POP_STATE},
571 '\0', NULL, N_("Pop state of flags governing input file handling"),
572 TWO_DASHES },
573 { {"print-memory-usage", no_argument, NULL, OPTION_PRINT_MEMORY_USAGE},
574 '\0', NULL, N_("Report target memory usage"), TWO_DASHES },
575 { {"orphan-handling", required_argument, NULL, OPTION_ORPHAN_HANDLING},
576 '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
577 TWO_DASHES },
578 { {"print-map-discarded", no_argument, NULL, OPTION_PRINT_MAP_DISCARDED},
579 '\0', NULL, N_("Show discarded sections in map file output (default)"),
580 TWO_DASHES },
581 { {"no-print-map-discarded", no_argument, NULL, OPTION_NO_PRINT_MAP_DISCARDED},
582 '\0', NULL, N_("Do not show discarded sections in map file output"),
583 TWO_DASHES },
584 { {"ctf-variables", no_argument, NULL, OPTION_CTF_VARIABLES},
585 '\0', NULL, N_("Emit names and types of static variables in CTF"),
586 TWO_DASHES },
587 { {"no-ctf-variables", no_argument, NULL, OPTION_NO_CTF_VARIABLES},
588 '\0', NULL, N_("Do not emit names and types of static variables in CTF"),
589 TWO_DASHES },
590 { {"ctf-share-types=<method>", required_argument, NULL,
591 OPTION_CTF_SHARE_TYPES},
592 '\0', NULL, N_("How to share CTF types between translation units.\n"
593 " <method> is: share-unconflicted (default),\n"
594 " share-duplicated"),
595 TWO_DASHES },
596 };
597
598 #define OPTION_COUNT ARRAY_SIZE (ld_options)
599
600 void
601 parse_args (unsigned argc, char **argv)
602 {
603 unsigned i;
604 int is, il, irl;
605 int ingroup = 0;
606 char *default_dirlist = NULL;
607 char *shortopts;
608 struct option *longopts;
609 struct option *really_longopts;
610 int last_optind;
611 enum symbolic_enum
612 {
613 symbolic_unset = 0,
614 symbolic,
615 symbolic_functions,
616 } opt_symbolic = symbolic_unset;
617 enum dynamic_list_enum
618 {
619 dynamic_list_unset = 0,
620 dynamic_list_data,
621 dynamic_list
622 } opt_dynamic_list = dynamic_list_unset;
623 struct bfd_elf_dynamic_list *export_list = NULL;
624
625 shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
626 longopts = (struct option *)
627 xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
628 really_longopts = (struct option *)
629 xmalloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
630
631 /* Starting the short option string with '-' is for programs that
632 expect options and other ARGV-elements in any order and that care about
633 the ordering of the two. We describe each non-option ARGV-element
634 as if it were the argument of an option with character code 1. */
635 shortopts[0] = '-';
636 is = 1;
637 il = 0;
638 irl = 0;
639 for (i = 0; i < OPTION_COUNT; i++)
640 {
641 if (ld_options[i].shortopt != '\0')
642 {
643 shortopts[is] = ld_options[i].shortopt;
644 ++is;
645 if (ld_options[i].opt.has_arg == required_argument
646 || ld_options[i].opt.has_arg == optional_argument)
647 {
648 shortopts[is] = ':';
649 ++is;
650 if (ld_options[i].opt.has_arg == optional_argument)
651 {
652 shortopts[is] = ':';
653 ++is;
654 }
655 }
656 }
657 if (ld_options[i].opt.name != NULL)
658 {
659 if (ld_options[i].control == EXACTLY_TWO_DASHES)
660 {
661 really_longopts[irl] = ld_options[i].opt;
662 ++irl;
663 }
664 else
665 {
666 longopts[il] = ld_options[i].opt;
667 ++il;
668 }
669 }
670 }
671 shortopts[is] = '\0';
672 longopts[il].name = NULL;
673 really_longopts[irl].name = NULL;
674
675 ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
676
677 /* The -G option is ambiguous on different platforms. Sometimes it
678 specifies the largest data size to put into the small data
679 section. Sometimes it is equivalent to --shared. Unfortunately,
680 the first form takes an argument, while the second does not.
681
682 We need to permit the --shared form because on some platforms,
683 such as Solaris, gcc -shared will pass -G to the linker.
684
685 To permit either usage, we look through the argument list. If we
686 find -G not followed by a number, we change it into --shared.
687 This will work for most normal cases. */
688 for (i = 1; i < argc; i++)
689 if (strcmp (argv[i], "-G") == 0
690 && (i + 1 >= argc
691 || ! ISDIGIT (argv[i + 1][0])))
692 argv[i] = (char *) "--shared";
693
694 /* Because we permit long options to start with a single dash, and
695 we have a --library option, and the -l option is conventionally
696 used with an immediately following argument, we can have bad
697 results if somebody tries to use -l with a library whose name
698 happens to start with "ibrary", as in -li. We avoid problems by
699 simply turning -l into --library. This means that users will
700 have to use two dashes in order to use --library, which is OK
701 since that's how it is documented.
702
703 FIXME: It's possible that this problem can arise for other short
704 options as well, although the user does always have the recourse
705 of adding a space between the option and the argument. */
706 for (i = 1; i < argc; i++)
707 {
708 if (argv[i][0] == '-'
709 && argv[i][1] == 'l'
710 && argv[i][2] != '\0')
711 {
712 char *n;
713
714 n = (char *) xmalloc (strlen (argv[i]) + 20);
715 sprintf (n, "--library=%s", argv[i] + 2);
716 argv[i] = n;
717 }
718 }
719
720 last_optind = -1;
721 while (1)
722 {
723 int longind = 0;
724 int optc;
725 static unsigned int defsym_count;
726
727 /* Using last_optind lets us avoid calling ldemul_parse_args
728 multiple times on a single option, which would lead to
729 confusion in the internal static variables maintained by
730 getopt. This could otherwise happen for an argument like
731 -nx, in which the -n is parsed as a single option, and we
732 loop around to pick up the -x. */
733 if (optind != last_optind)
734 if (ldemul_parse_args (argc, argv))
735 continue;
736
737 /* getopt_long_only is like getopt_long, but '-' as well as '--'
738 can indicate a long option. */
739 opterr = 0;
740 last_optind = optind;
741 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
742 if (optc == '?')
743 {
744 optind = last_optind;
745 optc = getopt_long (argc, argv, "-", really_longopts, &longind);
746 }
747 /* Attempt to detect grouped short options, eg: "-non-start".
748 Accepting such options is error prone as it is not clear if the user
749 intended "-n -o n-start" or "--non-start". */
750 else if (longind == 0 /* This is a short option. */
751 && optc > 32 /* It is a valid option. */
752 /* The character is not the second character of argv[last_optind]. */
753 && optc != argv[last_optind][1])
754 {
755 if (optarg)
756 einfo (_("%F%P: Error: unable to disambiguate: %s (did you mean -%s ?)\n"),
757 argv[last_optind], argv[last_optind]);
758 else
759 einfo (_("%P: Warning: grouped short command line options are deprecated: %s\n"), argv[last_optind]);
760 }
761
762 if (ldemul_handle_option (optc))
763 continue;
764
765 if (optc == -1)
766 break;
767
768 switch (optc)
769 {
770 case '?':
771 {
772 /* If the last word on the command line is an option that
773 requires an argument, getopt will refuse to recognise it.
774 Try to catch such options here and issue a more helpful
775 error message than just "unrecognized option". */
776 int opt;
777
778 for (opt = ARRAY_SIZE (ld_options); opt--;)
779 if (ld_options[opt].opt.has_arg == required_argument
780 /* FIXME: There are a few short options that do not
781 have long equivalents, but which require arguments.
782 We should handle them too. */
783 && ld_options[opt].opt.name != NULL
784 && strcmp (argv[last_optind] + ld_options[opt].control, ld_options[opt].opt.name) == 0)
785 {
786 einfo (_("%P: %s: missing argument\n"), argv[last_optind]);
787 break;
788 }
789
790 if (opt == -1)
791 einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
792 }
793 /* Fall through. */
794
795 default:
796 einfo (_("%F%P: use the --help option for usage information\n"));
797 break;
798
799 case 1: /* File name. */
800 lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL);
801 break;
802
803 case OPTION_IGNORE:
804 break;
805 case 'a':
806 /* For HP/UX compatibility. Actually -a shared should mean
807 ``use only shared libraries'' but, then, we don't
808 currently support shared libraries on HP/UX anyhow. */
809 if (strcmp (optarg, "archive") == 0)
810 input_flags.dynamic = false;
811 else if (strcmp (optarg, "shared") == 0
812 || strcmp (optarg, "default") == 0)
813 input_flags.dynamic = true;
814 else
815 einfo (_("%F%P: unrecognized -a option `%s'\n"), optarg);
816 break;
817 case OPTION_ASSERT:
818 /* FIXME: We just ignore these, but we should handle them. */
819 if (strcmp (optarg, "definitions") == 0)
820 ;
821 else if (strcmp (optarg, "nodefinitions") == 0)
822 ;
823 else if (strcmp (optarg, "nosymbolic") == 0)
824 ;
825 else if (strcmp (optarg, "pure-text") == 0)
826 ;
827 else
828 einfo (_("%F%P: unrecognized -assert option `%s'\n"), optarg);
829 break;
830 case 'A':
831 ldfile_add_arch (optarg);
832 break;
833 case 'b':
834 lang_add_target (optarg);
835 break;
836 case 'c':
837 ldfile_open_command_file (optarg);
838 parser_input = input_mri_script;
839 yyparse ();
840 break;
841 case OPTION_CALL_SHARED:
842 input_flags.dynamic = true;
843 break;
844 case OPTION_NON_SHARED:
845 input_flags.dynamic = false;
846 break;
847 case OPTION_CREF:
848 command_line.cref = true;
849 link_info.notice_all = true;
850 break;
851 case 'd':
852 command_line.force_common_definition = true;
853 break;
854 case OPTION_FORCE_GROUP_ALLOCATION:
855 command_line.force_group_allocation = true;
856 break;
857 case OPTION_DEFSYM:
858 lex_string = optarg;
859 lex_redirect (optarg, "--defsym", ++defsym_count);
860 parser_input = input_defsym;
861 yyparse ();
862 lex_string = NULL;
863 break;
864 case OPTION_DEMANGLE:
865 demangling = true;
866 if (optarg != NULL)
867 {
868 enum demangling_styles style;
869
870 style = cplus_demangle_name_to_style (optarg);
871 if (style == unknown_demangling)
872 einfo (_("%F%P: unknown demangling style `%s'\n"),
873 optarg);
874
875 cplus_demangle_set_style (style);
876 }
877 break;
878 case 'I': /* Used on Solaris. */
879 case OPTION_DYNAMIC_LINKER:
880 command_line.interpreter = optarg;
881 link_info.nointerp = 0;
882 break;
883 case OPTION_NO_DYNAMIC_LINKER:
884 link_info.nointerp = 1;
885 break;
886 case OPTION_SYSROOT:
887 /* Already handled in ldmain.c. */
888 break;
889 case OPTION_EB:
890 command_line.endian = ENDIAN_BIG;
891 break;
892 case OPTION_EL:
893 command_line.endian = ENDIAN_LITTLE;
894 break;
895 case OPTION_EMBEDDED_RELOCS:
896 command_line.embedded_relocs = true;
897 break;
898 case OPTION_EXPORT_DYNAMIC:
899 case 'E': /* HP/UX compatibility. */
900 link_info.export_dynamic = true;
901 break;
902 case OPTION_NO_EXPORT_DYNAMIC:
903 link_info.export_dynamic = false;
904 break;
905 case OPTION_NON_CONTIGUOUS_REGIONS:
906 link_info.non_contiguous_regions = true;
907 break;
908 case OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS:
909 link_info.non_contiguous_regions_warnings = true;
910 break;
911 case 'e':
912 lang_add_entry (optarg, true);
913 break;
914 case 'f':
915 if (command_line.auxiliary_filters == NULL)
916 {
917 command_line.auxiliary_filters = (char **)
918 xmalloc (2 * sizeof (char *));
919 command_line.auxiliary_filters[0] = optarg;
920 command_line.auxiliary_filters[1] = NULL;
921 }
922 else
923 {
924 int c;
925 char **p;
926
927 c = 0;
928 for (p = command_line.auxiliary_filters; *p != NULL; p++)
929 ++c;
930 command_line.auxiliary_filters = (char **)
931 xrealloc (command_line.auxiliary_filters,
932 (c + 2) * sizeof (char *));
933 command_line.auxiliary_filters[c] = optarg;
934 command_line.auxiliary_filters[c + 1] = NULL;
935 }
936 break;
937 case 'F':
938 command_line.filter_shlib = optarg;
939 break;
940 case OPTION_FORCE_EXE_SUFFIX:
941 command_line.force_exe_suffix = true;
942 break;
943 case 'G':
944 {
945 char *end;
946 g_switch_value = strtoul (optarg, &end, 0);
947 if (*end)
948 einfo (_("%F%P: invalid number `%s'\n"), optarg);
949 }
950 break;
951 case 'g':
952 /* Ignore. */
953 break;
954 case OPTION_GC_SECTIONS:
955 link_info.gc_sections = true;
956 break;
957 case OPTION_PRINT_GC_SECTIONS:
958 link_info.print_gc_sections = true;
959 break;
960 case OPTION_GC_KEEP_EXPORTED:
961 link_info.gc_keep_exported = true;
962 break;
963 case OPTION_HELP:
964 help ();
965 xexit (0);
966 break;
967 case 'L':
968 ldfile_add_library_path (optarg, true);
969 break;
970 case 'l':
971 lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL);
972 break;
973 case 'M':
974 config.map_filename = "-";
975 break;
976 case 'm':
977 /* Ignore. Was handled in a pre-parse. */
978 break;
979 case OPTION_MAP:
980 config.map_filename = optarg;
981 break;
982 case 'N':
983 config.text_read_only = false;
984 config.magic_demand_paged = false;
985 input_flags.dynamic = false;
986 break;
987 case OPTION_NO_OMAGIC:
988 config.text_read_only = true;
989 config.magic_demand_paged = true;
990 /* NB/ Does not set input_flags.dynamic to TRUE.
991 Use --call-shared or -Bdynamic for this. */
992 break;
993 case 'n':
994 config.text_read_only = true;
995 config.magic_demand_paged = false;
996 input_flags.dynamic = false;
997 break;
998 case OPTION_NO_DEFINE_COMMON:
999 link_info.inhibit_common_definition = true;
1000 break;
1001 case OPTION_NO_DEMANGLE:
1002 demangling = false;
1003 break;
1004 case OPTION_NO_GC_SECTIONS:
1005 link_info.gc_sections = false;
1006 break;
1007 case OPTION_NO_PRINT_GC_SECTIONS:
1008 link_info.print_gc_sections = false;
1009 break;
1010 case OPTION_NO_KEEP_MEMORY:
1011 link_info.keep_memory = false;
1012 break;
1013 case OPTION_NO_UNDEFINED:
1014 link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
1015 break;
1016 case OPTION_ALLOW_SHLIB_UNDEFINED:
1017 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1018 break;
1019 case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
1020 link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
1021 break;
1022 case OPTION_UNRESOLVED_SYMBOLS:
1023 if (strcmp (optarg, "ignore-all") == 0)
1024 {
1025 link_info.unresolved_syms_in_objects = RM_IGNORE;
1026 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1027 }
1028 else if (strcmp (optarg, "report-all") == 0)
1029 {
1030 link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
1031 link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
1032 }
1033 else if (strcmp (optarg, "ignore-in-object-files") == 0)
1034 {
1035 link_info.unresolved_syms_in_objects = RM_IGNORE;
1036 link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
1037 }
1038 else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
1039 {
1040 link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
1041 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1042 }
1043 else
1044 einfo (_("%F%P: bad --unresolved-symbols option: %s\n"), optarg);
1045 break;
1046 case OPTION_WARN_UNRESOLVED_SYMBOLS:
1047 link_info.warn_unresolved_syms = true;
1048 break;
1049 case OPTION_ERROR_UNRESOLVED_SYMBOLS:
1050 link_info.warn_unresolved_syms = false;
1051 break;
1052 case OPTION_ALLOW_MULTIPLE_DEFINITION:
1053 link_info.allow_multiple_definition = true;
1054 break;
1055
1056 #if SUPPORT_ERROR_HANDLING_SCRIPT
1057 case OPTION_ERROR_HANDLING_SCRIPT:
1058 /* FIXME: Should we warn if the script is being overridden by another ?
1059 Or maybe they should be chained together ? */
1060 error_handling_script = optarg;
1061 break;
1062 #endif
1063
1064 case OPTION_NO_UNDEFINED_VERSION:
1065 link_info.allow_undefined_version = false;
1066 break;
1067 case OPTION_DEFAULT_SYMVER:
1068 link_info.create_default_symver = true;
1069 break;
1070 case OPTION_DEFAULT_IMPORTED_SYMVER:
1071 link_info.default_imported_symver = true;
1072 break;
1073 case OPTION_NO_WARN_MISMATCH:
1074 command_line.warn_mismatch = false;
1075 break;
1076 case OPTION_NO_WARN_SEARCH_MISMATCH:
1077 command_line.warn_search_mismatch = false;
1078 break;
1079 case OPTION_NOINHIBIT_EXEC:
1080 force_make_executable = true;
1081 break;
1082 case OPTION_NOSTDLIB:
1083 config.only_cmd_line_lib_dirs = true;
1084 break;
1085 case OPTION_NO_WHOLE_ARCHIVE:
1086 input_flags.whole_archive = false;
1087 break;
1088 case 'O':
1089 /* FIXME "-O<non-digits> <value>" used to set the address of
1090 section <non-digits>. Was this for compatibility with
1091 something, or can we create a new option to do that
1092 (with a syntax similar to -defsym)?
1093 getopt can't handle two args to an option without kludges. */
1094
1095 /* Enable optimizations of output files. */
1096 link_info.optimize = strtoul (optarg, NULL, 0) != 0;
1097 break;
1098 case 'o':
1099 lang_add_output (optarg, 0);
1100 break;
1101 case OPTION_OFORMAT:
1102 lang_add_output_format (optarg, NULL, NULL, 0);
1103 break;
1104 case OPTION_OUT_IMPLIB:
1105 command_line.out_implib_filename = xstrdup (optarg);
1106 break;
1107 case OPTION_PRINT_SYSROOT:
1108 if (*ld_sysroot)
1109 puts (ld_sysroot);
1110 xexit (0);
1111 break;
1112 case OPTION_PRINT_OUTPUT_FORMAT:
1113 command_line.print_output_format = true;
1114 break;
1115 #if BFD_SUPPORTS_PLUGINS
1116 case OPTION_PLUGIN:
1117 plugin_opt_plugin (optarg);
1118 break;
1119 case OPTION_PLUGIN_OPT:
1120 if (plugin_opt_plugin_arg (optarg))
1121 einfo (_("%F%P: bad -plugin-opt option\n"));
1122 break;
1123 #endif /* BFD_SUPPORTS_PLUGINS */
1124 case 'q':
1125 link_info.emitrelocations = true;
1126 break;
1127 case 'i':
1128 case 'r':
1129 if (optind == last_optind)
1130 /* This can happen if the user put "-rpath,a" on the command
1131 line. (Or something similar. The comma is important).
1132 Getopt becomes confused and thinks that this is a -r option
1133 but it cannot parse the text after the -r so it refuses to
1134 increment the optind counter. Detect this case and issue
1135 an error message here. We cannot just make this a warning,
1136 increment optind, and continue because getopt is too confused
1137 and will seg-fault the next time around. */
1138 einfo(_("%F%P: unrecognised option: %s\n"), argv[optind]);
1139
1140 if (bfd_link_pic (&link_info))
1141 einfo (_("%F%P: -r and %s may not be used together\n"),
1142 bfd_link_dll (&link_info) ? "-shared" : "-pie");
1143
1144 link_info.type = type_relocatable;
1145 config.build_constructors = false;
1146 config.magic_demand_paged = false;
1147 config.text_read_only = false;
1148 input_flags.dynamic = false;
1149 break;
1150 case 'R':
1151 /* The GNU linker traditionally uses -R to mean to include
1152 only the symbols from a file. The Solaris linker uses -R
1153 to set the path used by the runtime linker to find
1154 libraries. This is the GNU linker -rpath argument. We
1155 try to support both simultaneously by checking the file
1156 named. If it is a directory, rather than a regular file,
1157 we assume -rpath was meant. */
1158 {
1159 struct stat s;
1160
1161 if (stat (optarg, &s) >= 0
1162 && ! S_ISDIR (s.st_mode))
1163 {
1164 lang_add_input_file (optarg,
1165 lang_input_file_is_symbols_only_enum,
1166 NULL);
1167 break;
1168 }
1169 }
1170 /* Fall through. */
1171 case OPTION_RPATH:
1172 if (command_line.rpath == NULL)
1173 command_line.rpath = xstrdup (optarg);
1174 else
1175 {
1176 size_t rpath_len = strlen (command_line.rpath);
1177 size_t optarg_len = strlen (optarg);
1178 char *buf;
1179 char *cp = command_line.rpath;
1180
1181 /* First see whether OPTARG is already in the path. */
1182 do
1183 {
1184 if (strncmp (optarg, cp, optarg_len) == 0
1185 && (cp[optarg_len] == 0
1186 || cp[optarg_len] == config.rpath_separator))
1187 /* We found it. */
1188 break;
1189
1190 /* Not yet found. */
1191 cp = strchr (cp, config.rpath_separator);
1192 if (cp != NULL)
1193 ++cp;
1194 }
1195 while (cp != NULL);
1196
1197 if (cp == NULL)
1198 {
1199 buf = (char *) xmalloc (rpath_len + optarg_len + 2);
1200 sprintf (buf, "%s%c%s", command_line.rpath,
1201 config.rpath_separator, optarg);
1202 free (command_line.rpath);
1203 command_line.rpath = buf;
1204 }
1205 }
1206 break;
1207 case OPTION_RPATH_LINK:
1208 if (command_line.rpath_link == NULL)
1209 command_line.rpath_link = xstrdup (optarg);
1210 else
1211 {
1212 char *buf;
1213
1214 buf = (char *) xmalloc (strlen (command_line.rpath_link)
1215 + strlen (optarg)
1216 + 2);
1217 sprintf (buf, "%s%c%s", command_line.rpath_link,
1218 config.rpath_separator, optarg);
1219 free (command_line.rpath_link);
1220 command_line.rpath_link = buf;
1221 }
1222 break;
1223 case OPTION_NO_RELAX:
1224 DISABLE_RELAXATION;
1225 break;
1226 case OPTION_RELAX:
1227 ENABLE_RELAXATION;
1228 break;
1229 case OPTION_RETAIN_SYMBOLS_FILE:
1230 add_keepsyms_file (optarg);
1231 break;
1232 case 'S':
1233 link_info.strip = strip_debugger;
1234 break;
1235 case 's':
1236 link_info.strip = strip_all;
1237 break;
1238 case OPTION_STRIP_DISCARDED:
1239 link_info.strip_discarded = true;
1240 break;
1241 case OPTION_NO_STRIP_DISCARDED:
1242 link_info.strip_discarded = false;
1243 break;
1244 case OPTION_DISABLE_MULTIPLE_DEFS_ABS:
1245 link_info.prohibit_multiple_definition_absolute = true;
1246 break;
1247 case OPTION_SHARED:
1248 if (config.has_shared)
1249 {
1250 if (bfd_link_relocatable (&link_info))
1251 einfo (_("%F%P: -r and %s may not be used together\n"),
1252 "-shared");
1253
1254 link_info.type = type_dll;
1255 /* When creating a shared library, the default
1256 behaviour is to ignore any unresolved references. */
1257 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1258 link_info.unresolved_syms_in_objects = RM_IGNORE;
1259 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1260 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1261 }
1262 else
1263 einfo (_("%F%P: -shared not supported\n"));
1264 break;
1265 case OPTION_PIE:
1266 if (config.has_shared)
1267 {
1268 if (bfd_link_relocatable (&link_info))
1269 einfo (_("%F%P: -r and %s may not be used together\n"), "-pie");
1270
1271 link_info.type = type_pie;
1272 }
1273 else
1274 einfo (_("%F%P: -pie not supported\n"));
1275 break;
1276 case 'h': /* Used on Solaris. */
1277 case OPTION_SONAME:
1278 if (optarg[0] == '\0' && command_line.soname
1279 && command_line.soname[0])
1280 einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
1281 else
1282 command_line.soname = optarg;
1283 break;
1284 case OPTION_SORT_COMMON:
1285 if (optarg == NULL
1286 || strcmp (optarg, N_("descending")) == 0)
1287 config.sort_common = sort_descending;
1288 else if (strcmp (optarg, N_("ascending")) == 0)
1289 config.sort_common = sort_ascending;
1290 else
1291 einfo (_("%F%P: invalid common section sorting option: %s\n"),
1292 optarg);
1293 break;
1294 case OPTION_SORT_SECTION:
1295 if (strcmp (optarg, N_("name")) == 0)
1296 sort_section = by_name;
1297 else if (strcmp (optarg, N_("alignment")) == 0)
1298 sort_section = by_alignment;
1299 else
1300 einfo (_("%F%P: invalid section sorting option: %s\n"),
1301 optarg);
1302 break;
1303 case OPTION_STATS:
1304 config.stats = true;
1305 break;
1306 case OPTION_NO_SYMBOLIC:
1307 opt_symbolic = symbolic_unset;
1308 break;
1309 case OPTION_SYMBOLIC:
1310 opt_symbolic = symbolic;
1311 break;
1312 case OPTION_SYMBOLIC_FUNCTIONS:
1313 opt_symbolic = symbolic_functions;
1314 break;
1315 case 't':
1316 ++trace_files;
1317 break;
1318 case 'T':
1319 previous_script_handle = saved_script_handle;
1320 ldfile_open_script_file (optarg);
1321 parser_input = input_script;
1322 yyparse ();
1323 previous_script_handle = NULL;
1324 break;
1325 case OPTION_DEFAULT_SCRIPT:
1326 command_line.default_script = optarg;
1327 break;
1328 case OPTION_SECTION_START:
1329 {
1330 char *optarg2;
1331 char *sec_name;
1332 int len;
1333
1334 /* Check for <something>=<somthing>... */
1335 optarg2 = strchr (optarg, '=');
1336 if (optarg2 == NULL)
1337 einfo (_("%F%P: invalid argument to option"
1338 " \"--section-start\"\n"));
1339
1340 optarg2++;
1341
1342 /* So far so good. Are all the args present? */
1343 if ((*optarg == '\0') || (*optarg2 == '\0'))
1344 einfo (_("%F%P: missing argument(s) to option"
1345 " \"--section-start\"\n"));
1346
1347 /* We must copy the section name as set_section_start
1348 doesn't do it for us. */
1349 len = optarg2 - optarg;
1350 sec_name = (char *) xmalloc (len);
1351 memcpy (sec_name, optarg, len - 1);
1352 sec_name[len - 1] = 0;
1353
1354 /* Then set it... */
1355 set_section_start (sec_name, optarg2);
1356 }
1357 break;
1358 case OPTION_TARGET_HELP:
1359 /* Mention any target specific options. */
1360 ldemul_list_emulation_options (stdout);
1361 exit (0);
1362 case OPTION_TBSS:
1363 set_segment_start (".bss", optarg);
1364 break;
1365 case OPTION_TDATA:
1366 set_segment_start (".data", optarg);
1367 break;
1368 case OPTION_TTEXT:
1369 set_segment_start (".text", optarg);
1370 break;
1371 case OPTION_TTEXT_SEGMENT:
1372 set_segment_start (".text-segment", optarg);
1373 break;
1374 case OPTION_TRODATA_SEGMENT:
1375 set_segment_start (".rodata-segment", optarg);
1376 break;
1377 case OPTION_TLDATA_SEGMENT:
1378 set_segment_start (".ldata-segment", optarg);
1379 break;
1380 case OPTION_TRADITIONAL_FORMAT:
1381 link_info.traditional_format = true;
1382 break;
1383 case OPTION_TASK_LINK:
1384 link_info.task_link = true;
1385 /* Fall through. */
1386 case OPTION_UR:
1387 if (bfd_link_pic (&link_info))
1388 einfo (_("%F%P: -r and %s may not be used together\n"),
1389 bfd_link_dll (&link_info) ? "-shared" : "-pie");
1390
1391 link_info.type = type_relocatable;
1392 config.build_constructors = true;
1393 config.magic_demand_paged = false;
1394 config.text_read_only = false;
1395 input_flags.dynamic = false;
1396 break;
1397 case 'u':
1398 ldlang_add_undef (optarg, true);
1399 break;
1400 case OPTION_REQUIRE_DEFINED_SYMBOL:
1401 ldlang_add_require_defined (optarg);
1402 break;
1403 case OPTION_UNIQUE:
1404 if (optarg != NULL)
1405 lang_add_unique (optarg);
1406 else
1407 config.unique_orphan_sections = true;
1408 break;
1409 case OPTION_VERBOSE:
1410 ldversion (1);
1411 version_printed = true;
1412 verbose = true;
1413 overflow_cutoff_limit = -2;
1414 if (optarg != NULL)
1415 {
1416 char *end;
1417 int level ATTRIBUTE_UNUSED = strtoul (optarg, &end, 0);
1418 if (*end)
1419 einfo (_("%F%P: invalid number `%s'\n"), optarg);
1420 #if BFD_SUPPORTS_PLUGINS
1421 report_plugin_symbols = level > 1;
1422 #endif /* BFD_SUPPORTS_PLUGINS */
1423 }
1424 break;
1425 case 'v':
1426 ldversion (0);
1427 version_printed = true;
1428 break;
1429 case 'V':
1430 ldversion (1);
1431 version_printed = true;
1432 break;
1433 case OPTION_VERSION:
1434 ldversion (2);
1435 xexit (0);
1436 break;
1437 case OPTION_VERSION_SCRIPT:
1438 /* This option indicates a small script that only specifies
1439 version information. Read it, but don't assume that
1440 we've seen a linker script. */
1441 {
1442 FILE *hold_script_handle;
1443
1444 hold_script_handle = saved_script_handle;
1445 ldfile_open_command_file (optarg);
1446 saved_script_handle = hold_script_handle;
1447 parser_input = input_version_script;
1448 yyparse ();
1449 }
1450 break;
1451 case OPTION_VERSION_EXPORTS_SECTION:
1452 /* This option records a version symbol to be applied to the
1453 symbols listed for export to be found in the object files
1454 .exports sections. */
1455 command_line.version_exports_section = optarg;
1456 break;
1457 case OPTION_DYNAMIC_LIST_DATA:
1458 opt_dynamic_list = dynamic_list_data;
1459 break;
1460 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
1461 lang_append_dynamic_list_cpp_typeinfo ();
1462 if (opt_dynamic_list != dynamic_list_data)
1463 opt_dynamic_list = dynamic_list;
1464 break;
1465 case OPTION_DYNAMIC_LIST_CPP_NEW:
1466 lang_append_dynamic_list_cpp_new ();
1467 if (opt_dynamic_list != dynamic_list_data)
1468 opt_dynamic_list = dynamic_list;
1469 break;
1470 case OPTION_DYNAMIC_LIST:
1471 /* This option indicates a small script that only specifies
1472 a dynamic list. Read it, but don't assume that we've
1473 seen a linker script. */
1474 {
1475 FILE *hold_script_handle;
1476
1477 hold_script_handle = saved_script_handle;
1478 ldfile_open_command_file (optarg);
1479 saved_script_handle = hold_script_handle;
1480 parser_input = input_dynamic_list;
1481 current_dynamic_list_p = &link_info.dynamic_list;
1482 yyparse ();
1483 }
1484 if (opt_dynamic_list != dynamic_list_data)
1485 opt_dynamic_list = dynamic_list;
1486 break;
1487 case OPTION_EXPORT_DYNAMIC_SYMBOL:
1488 {
1489 struct bfd_elf_version_expr *expr
1490 = lang_new_vers_pattern (NULL, xstrdup (optarg), NULL,
1491 false);
1492 lang_append_dynamic_list (&export_list, expr);
1493 }
1494 break;
1495 case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST:
1496 /* This option indicates a small script that only specifies
1497 an export list. Read it, but don't assume that we've
1498 seen a linker script. */
1499 {
1500 FILE *hold_script_handle;
1501
1502 hold_script_handle = saved_script_handle;
1503 ldfile_open_command_file (optarg);
1504 saved_script_handle = hold_script_handle;
1505 parser_input = input_dynamic_list;
1506 current_dynamic_list_p = &export_list;
1507 yyparse ();
1508 }
1509 break;
1510 case OPTION_WARN_COMMON:
1511 config.warn_common = true;
1512 break;
1513 case OPTION_WARN_CONSTRUCTORS:
1514 config.warn_constructors = true;
1515 break;
1516 case OPTION_WARN_FATAL:
1517 config.fatal_warnings = true;
1518 break;
1519 case OPTION_NO_WARN_FATAL:
1520 config.fatal_warnings = false;
1521 break;
1522 case OPTION_WARN_MULTIPLE_GP:
1523 config.warn_multiple_gp = true;
1524 break;
1525 case OPTION_WARN_ONCE:
1526 config.warn_once = true;
1527 break;
1528 case OPTION_WARN_SECTION_ALIGN:
1529 config.warn_section_align = true;
1530 break;
1531 case OPTION_WARN_TEXTREL:
1532 link_info.textrel_check = textrel_check_warning;
1533 break;
1534 case OPTION_WARN_ALTERNATE_EM:
1535 link_info.warn_alternate_em = true;
1536 break;
1537 case OPTION_WHOLE_ARCHIVE:
1538 input_flags.whole_archive = true;
1539 break;
1540 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC:
1541 input_flags.add_DT_NEEDED_for_dynamic = true;
1542 break;
1543 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC:
1544 input_flags.add_DT_NEEDED_for_dynamic = false;
1545 break;
1546 case OPTION_ADD_DT_NEEDED_FOR_REGULAR:
1547 input_flags.add_DT_NEEDED_for_regular = true;
1548 break;
1549 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR:
1550 input_flags.add_DT_NEEDED_for_regular = false;
1551 break;
1552 case OPTION_WRAP:
1553 add_wrap (optarg);
1554 break;
1555 case OPTION_IGNORE_UNRESOLVED_SYMBOL:
1556 add_ignoresym (&link_info, optarg);
1557 break;
1558 case OPTION_DISCARD_NONE:
1559 link_info.discard = discard_none;
1560 break;
1561 case 'X':
1562 link_info.discard = discard_l;
1563 break;
1564 case 'x':
1565 link_info.discard = discard_all;
1566 break;
1567 case 'Y':
1568 if (startswith (optarg, "P,"))
1569 optarg += 2;
1570 free (default_dirlist);
1571 default_dirlist = xstrdup (optarg);
1572 break;
1573 case 'y':
1574 add_ysym (optarg);
1575 break;
1576 case OPTION_SPARE_DYNAMIC_TAGS:
1577 link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0);
1578 break;
1579 case OPTION_SPLIT_BY_RELOC:
1580 if (optarg != NULL)
1581 config.split_by_reloc = strtoul (optarg, NULL, 0);
1582 else
1583 config.split_by_reloc = 32768;
1584 break;
1585 case OPTION_SPLIT_BY_FILE:
1586 if (optarg != NULL)
1587 config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
1588 else
1589 config.split_by_file = 1;
1590 break;
1591 case OPTION_CHECK_SECTIONS:
1592 command_line.check_section_addresses = 1;
1593 break;
1594 case OPTION_NO_CHECK_SECTIONS:
1595 command_line.check_section_addresses = 0;
1596 break;
1597 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
1598 command_line.accept_unknown_input_arch = true;
1599 break;
1600 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
1601 command_line.accept_unknown_input_arch = false;
1602 break;
1603 case '(':
1604 lang_enter_group ();
1605 ingroup++;
1606 break;
1607 case ')':
1608 if (! ingroup)
1609 einfo (_("%F%P: group ended before it began (--help for usage)\n"));
1610
1611 lang_leave_group ();
1612 ingroup--;
1613 break;
1614
1615 case OPTION_INIT:
1616 link_info.init_function = optarg;
1617 break;
1618
1619 case OPTION_FINI:
1620 link_info.fini_function = optarg;
1621 break;
1622
1623 case OPTION_REDUCE_MEMORY_OVERHEADS:
1624 link_info.reduce_memory_overheads = true;
1625 if (config.hash_table_size == 0)
1626 config.hash_table_size = 1021;
1627 break;
1628
1629 case OPTION_HASH_SIZE:
1630 {
1631 bfd_size_type new_size;
1632
1633 new_size = strtoul (optarg, NULL, 0);
1634 if (new_size)
1635 config.hash_table_size = new_size;
1636 else
1637 einfo (_("%X%P: --hash-size needs a numeric argument\n"));
1638 }
1639 break;
1640
1641 case OPTION_PUSH_STATE:
1642 input_flags.pushed = xmemdup (&input_flags,
1643 sizeof (input_flags),
1644 sizeof (input_flags));
1645 break;
1646
1647 case OPTION_POP_STATE:
1648 if (input_flags.pushed == NULL)
1649 einfo (_("%F%P: no state pushed before popping\n"));
1650 else
1651 {
1652 struct lang_input_statement_flags *oldp = input_flags.pushed;
1653 memcpy (&input_flags, oldp, sizeof (input_flags));
1654 free (oldp);
1655 }
1656 break;
1657
1658 case OPTION_PRINT_MEMORY_USAGE:
1659 command_line.print_memory_usage = true;
1660 break;
1661
1662 case OPTION_ORPHAN_HANDLING:
1663 if (strcasecmp (optarg, "place") == 0)
1664 config.orphan_handling = orphan_handling_place;
1665 else if (strcasecmp (optarg, "warn") == 0)
1666 config.orphan_handling = orphan_handling_warn;
1667 else if (strcasecmp (optarg, "error") == 0)
1668 config.orphan_handling = orphan_handling_error;
1669 else if (strcasecmp (optarg, "discard") == 0)
1670 config.orphan_handling = orphan_handling_discard;
1671 else
1672 einfo (_("%F%P: invalid argument to option"
1673 " \"--orphan-handling\"\n"));
1674 break;
1675
1676 case OPTION_NO_PRINT_MAP_DISCARDED:
1677 config.print_map_discarded = false;
1678 break;
1679
1680 case OPTION_PRINT_MAP_DISCARDED:
1681 config.print_map_discarded = true;
1682 break;
1683
1684 case OPTION_DEPENDENCY_FILE:
1685 config.dependency_file = optarg;
1686 break;
1687
1688 case OPTION_CTF_VARIABLES:
1689 config.ctf_variables = true;
1690 break;
1691
1692 case OPTION_NO_CTF_VARIABLES:
1693 config.ctf_variables = false;
1694 break;
1695
1696 case OPTION_CTF_SHARE_TYPES:
1697 if (strcmp (optarg, "share-unconflicted") == 0)
1698 config.ctf_share_duplicated = false;
1699 else if (strcmp (optarg, "share-duplicated") == 0)
1700 config.ctf_share_duplicated = true;
1701 else
1702 einfo (_("%F%P: bad --ctf-share-types option: %s\n"), optarg);
1703 break;
1704 }
1705 }
1706
1707 free (really_longopts);
1708 free (longopts);
1709 free (shortopts);
1710
1711 /* Run a couple of checks on the map filename. */
1712 if (config.map_filename)
1713 {
1714 char * new_name = NULL;
1715 char * percent;
1716 int res = 0;
1717
1718 if (config.map_filename[0] == 0)
1719 {
1720 einfo (_("%P: no file/directory name provided for map output; ignored\n"));
1721 config.map_filename = NULL;
1722 }
1723 else if (strcmp (config.map_filename, "-") == 0)
1724 ; /* Write to stdout. Handled in main(). */
1725 else if ((percent = strchr (config.map_filename, '%')) != NULL)
1726 {
1727 /* FIXME: Check for a second % character and issue an error ? */
1728
1729 /* Construct a map file by replacing the % character with the (full)
1730 output filename. If the % character was the last character in
1731 the original map filename then add a .map extension. */
1732 percent[0] = 0;
1733 res = asprintf (&new_name, "%s%s%s", config.map_filename,
1734 output_filename,
1735 percent[1] ? percent + 1 : ".map");
1736
1737 /* FIXME: Should we ensure that any directory components in new_name exist ? */
1738 }
1739 else
1740 {
1741 struct stat s;
1742
1743 /* If the map filename is actually a directory then create
1744 a file inside it, based upon the output filename. */
1745 if (stat (config.map_filename, &s) < 0)
1746 {
1747 if (errno != ENOENT)
1748 einfo (_("%P: cannot stat linker map file: %E\n"));
1749 }
1750 else if (S_ISDIR (s.st_mode))
1751 {
1752 char lastc = config.map_filename[strlen (config.map_filename) - 1];
1753 res = asprintf (&new_name, "%s%s%s.map",
1754 config.map_filename,
1755 IS_DIR_SEPARATOR (lastc) ? "" : "/",
1756 lbasename (output_filename));
1757 }
1758 else if (! S_ISREG (s.st_mode))
1759 {
1760 einfo (_("%P: linker map file is not a regular file\n"));
1761 config.map_filename = NULL;
1762 }
1763 /* else FIXME: Check write permission ? */
1764 }
1765
1766 if (res < 0)
1767 {
1768 /* If the asprintf failed then something is probably very
1769 wrong. Better to halt now rather than continue on
1770 into more problems. */
1771 einfo (_("%P%F: cannot create name for linker map file: %E\n"));
1772 }
1773 else if (new_name != NULL)
1774 {
1775 /* This is a trivial memory leak. */
1776 config.map_filename = new_name;
1777 }
1778 }
1779
1780 if (command_line.soname && command_line.soname[0] == '\0')
1781 {
1782 einfo (_("%P: SONAME must not be empty string; ignored\n"));
1783 command_line.soname = NULL;
1784 }
1785
1786 while (ingroup)
1787 {
1788 einfo (_("%P: missing --end-group; added as last command line option\n"));
1789 lang_leave_group ();
1790 ingroup--;
1791 }
1792
1793 if (default_dirlist != NULL)
1794 {
1795 set_default_dirlist (default_dirlist);
1796 free (default_dirlist);
1797 }
1798
1799 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1800 /* FIXME: Should we allow emulations a chance to set this ? */
1801 link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
1802
1803 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1804 /* FIXME: Should we allow emulations a chance to set this ? */
1805 link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
1806
1807 if (bfd_link_relocatable (&link_info)
1808 && command_line.check_section_addresses < 0)
1809 command_line.check_section_addresses = 0;
1810
1811 if (export_list)
1812 {
1813 struct bfd_elf_version_expr *head = export_list->head.list;
1814 struct bfd_elf_version_expr *next;
1815
1816 /* For --export-dynamic-symbol[-list]:
1817 1. When building executable, treat like --dynamic-list.
1818 2. When building shared object:
1819 a. If -Bsymbolic or --dynamic-list are used, treat like
1820 --dynamic-list.
1821 b. Otherwise, ignored.
1822 */
1823 if (!bfd_link_relocatable (&link_info)
1824 && (bfd_link_executable (&link_info)
1825 || opt_symbolic != symbolic_unset
1826 || opt_dynamic_list != dynamic_list_unset))
1827 {
1828 /* Append the export list to link_info.dynamic_list. */
1829 if (link_info.dynamic_list)
1830 {
1831 for (next = head; next->next != NULL; next = next->next)
1832 ;
1833 next->next = link_info.dynamic_list->head.list;
1834 link_info.dynamic_list->head.list = head;
1835 }
1836 else
1837 link_info.dynamic_list = export_list;
1838
1839 if (opt_dynamic_list != dynamic_list_data)
1840 opt_dynamic_list = dynamic_list;
1841 }
1842 else
1843 {
1844 /* Free the export list. */
1845 for (; head->next != NULL; head = next)
1846 {
1847 next = head->next;
1848 free (head);
1849 }
1850 free (export_list);
1851 }
1852 }
1853
1854 switch (opt_dynamic_list)
1855 {
1856 case dynamic_list_unset:
1857 break;
1858 case dynamic_list_data:
1859 link_info.dynamic_data = true;
1860 /* Fall through. */
1861 case dynamic_list:
1862 link_info.dynamic = true;
1863 opt_symbolic = symbolic_unset;
1864 break;
1865 }
1866
1867 /* -Bsymbolic and -Bsymbols-functions are for shared library output. */
1868 if (bfd_link_dll (&link_info))
1869 switch (opt_symbolic)
1870 {
1871 case symbolic_unset:
1872 break;
1873 case symbolic:
1874 link_info.symbolic = true;
1875 if (link_info.dynamic_list)
1876 {
1877 struct bfd_elf_version_expr *ent, *next;
1878 for (ent = link_info.dynamic_list->head.list; ent; ent = next)
1879 {
1880 next = ent->next;
1881 free (ent);
1882 }
1883 free (link_info.dynamic_list);
1884 link_info.dynamic_list = NULL;
1885 }
1886 break;
1887 case symbolic_functions:
1888 link_info.dynamic = true;
1889 link_info.dynamic_data = true;
1890 break;
1891 }
1892
1893 if (!bfd_link_dll (&link_info))
1894 {
1895 if (command_line.filter_shlib)
1896 einfo (_("%F%P: -F may not be used without -shared\n"));
1897 if (command_line.auxiliary_filters)
1898 einfo (_("%F%P: -f may not be used without -shared\n"));
1899 }
1900
1901 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
1902 don't see how else this can be handled, since in this case we
1903 must preserve all externally visible symbols. */
1904 if (bfd_link_relocatable (&link_info) && link_info.strip == strip_all)
1905 {
1906 link_info.strip = strip_debugger;
1907 if (link_info.discard == discard_sec_merge)
1908 link_info.discard = discard_all;
1909 }
1910 }
1911
1912 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1913 library search path. */
1914
1915 static void
1916 set_default_dirlist (char *dirlist_ptr)
1917 {
1918 char *p;
1919
1920 while (1)
1921 {
1922 p = strchr (dirlist_ptr, PATH_SEPARATOR);
1923 if (p != NULL)
1924 *p = '\0';
1925 if (*dirlist_ptr != '\0')
1926 ldfile_add_library_path (dirlist_ptr, true);
1927 if (p == NULL)
1928 break;
1929 dirlist_ptr = p + 1;
1930 }
1931 }
1932
1933 static void
1934 set_section_start (char *sect, char *valstr)
1935 {
1936 const char *end;
1937 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1938 if (*end)
1939 einfo (_("%F%P: invalid hex number `%s'\n"), valstr);
1940 lang_section_start (sect, exp_intop (val), NULL);
1941 }
1942
1943 static void
1944 set_segment_start (const char *section, char *valstr)
1945 {
1946 const char *name;
1947 const char *end;
1948 segment_type *seg;
1949
1950 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1951 if (*end)
1952 einfo (_("%F%P: invalid hex number `%s'\n"), valstr);
1953 /* If we already have an entry for this segment, update the existing
1954 value. */
1955 name = section + 1;
1956 for (seg = segments; seg; seg = seg->next)
1957 if (strcmp (seg->name, name) == 0)
1958 {
1959 seg->value = val;
1960 lang_section_start (section, exp_intop (val), seg);
1961 return;
1962 }
1963 /* There was no existing value so we must create a new segment
1964 entry. */
1965 seg = stat_alloc (sizeof (*seg));
1966 seg->name = name;
1967 seg->value = val;
1968 seg->used = false;
1969 /* Add it to the linked list of segments. */
1970 seg->next = segments;
1971 segments = seg;
1972 /* Historically, -Ttext and friends set the base address of a
1973 particular section. For backwards compatibility, we still do
1974 that. If a SEGMENT_START directive is seen, the section address
1975 assignment will be disabled. */
1976 lang_section_start (section, exp_intop (val), seg);
1977 }
1978
1979 static void
1980 elf_shlib_list_options (FILE *file)
1981 {
1982 fprintf (file, _("\
1983 --audit=AUDITLIB Specify a library to use for auditing\n"));
1984 fprintf (file, _("\
1985 -Bgroup Selects group name lookup rules for DSO\n"));
1986 fprintf (file, _("\
1987 --disable-new-dtags Disable new dynamic tags\n"));
1988 fprintf (file, _("\
1989 --enable-new-dtags Enable new dynamic tags\n"));
1990 fprintf (file, _("\
1991 --eh-frame-hdr Create .eh_frame_hdr section\n"));
1992 fprintf (file, _("\
1993 --no-eh-frame-hdr Do not create .eh_frame_hdr section\n"));
1994 fprintf (file, _("\
1995 --exclude-libs=LIBS Make all symbols in LIBS hidden\n"));
1996 fprintf (file, _("\
1997 --hash-style=STYLE Set hash style to sysv/gnu/both. Default: "));
1998 if (DEFAULT_EMIT_SYSV_HASH)
1999 {
2000 /* Note - these strings are not translated as
2001 they are keywords not descriptive text. */
2002 if (DEFAULT_EMIT_GNU_HASH)
2003 fprintf (file, "both\n");
2004 else
2005 fprintf (file, "sysv\n");
2006 }
2007 else
2008 {
2009 if (DEFAULT_EMIT_GNU_HASH)
2010 fprintf (file, "gnu\n");
2011 else
2012 /* FIXME: Can this happen ? */
2013 fprintf (file, "none\n");
2014 }
2015 fprintf (file, _("\
2016 -P AUDITLIB, --depaudit=AUDITLIB\n" "\
2017 Specify a library to use for auditing dependencies\n"));
2018 fprintf (file, _("\
2019 -z combreloc Merge dynamic relocs into one section and sort\n"));
2020 fprintf (file, _("\
2021 -z nocombreloc Don't merge dynamic relocs into one section\n"));
2022 fprintf (file, _("\
2023 -z global Make symbols in DSO available for subsequently\n\
2024 loaded objects\n"));
2025 fprintf (file, _("\
2026 -z initfirst Mark DSO to be initialized first at runtime\n"));
2027 fprintf (file, _("\
2028 -z interpose Mark object to interpose all DSOs but executable\n"));
2029 fprintf (file, _("\
2030 -z unique Mark DSO to be loaded at most once by default, and only in the main namespace\n"));
2031 fprintf (file, _("\
2032 -z nounique Don't mark DSO as a loadable at most once\n"));
2033 fprintf (file, _("\
2034 -z lazy Mark object lazy runtime binding (default)\n"));
2035 fprintf (file, _("\
2036 -z loadfltr Mark object requiring immediate process\n"));
2037 fprintf (file, _("\
2038 -z nocopyreloc Don't create copy relocs\n"));
2039 fprintf (file, _("\
2040 -z nodefaultlib Mark object not to use default search paths\n"));
2041 fprintf (file, _("\
2042 -z nodelete Mark DSO non-deletable at runtime\n"));
2043 fprintf (file, _("\
2044 -z nodlopen Mark DSO not available to dlopen\n"));
2045 fprintf (file, _("\
2046 -z nodump Mark DSO not available to dldump\n"));
2047 fprintf (file, _("\
2048 -z now Mark object non-lazy runtime binding\n"));
2049 fprintf (file, _("\
2050 -z origin Mark object requiring immediate $ORIGIN\n\
2051 processing at runtime\n"));
2052 #if DEFAULT_LD_Z_RELRO
2053 fprintf (file, _("\
2054 -z relro Create RELRO program header (default)\n"));
2055 fprintf (file, _("\
2056 -z norelro Don't create RELRO program header\n"));
2057 #else
2058 fprintf (file, _("\
2059 -z relro Create RELRO program header\n"));
2060 fprintf (file, _("\
2061 -z norelro Don't create RELRO program header (default)\n"));
2062 #endif
2063 #if DEFAULT_LD_Z_SEPARATE_CODE
2064 fprintf (file, _("\
2065 -z separate-code Create separate code program header (default)\n"));
2066 fprintf (file, _("\
2067 -z noseparate-code Don't create separate code program header\n"));
2068 #else
2069 fprintf (file, _("\
2070 -z separate-code Create separate code program header\n"));
2071 fprintf (file, _("\
2072 -z noseparate-code Don't create separate code program header (default)\n"));
2073 #endif
2074 fprintf (file, _("\
2075 -z common Generate common symbols with STT_COMMON type\n"));
2076 fprintf (file, _("\
2077 -z nocommon Generate common symbols with STT_OBJECT type\n"));
2078 if (link_info.textrel_check == textrel_check_error)
2079 fprintf (file, _("\
2080 -z text Treat DT_TEXTREL in output as error (default)\n"));
2081 else
2082 fprintf (file, _("\
2083 -z text Treat DT_TEXTREL in output as error\n"));
2084 if (link_info.textrel_check == textrel_check_none)
2085 {
2086 fprintf (file, _("\
2087 -z notext Don't treat DT_TEXTREL in output as error (default)\n"));
2088 fprintf (file, _("\
2089 -z textoff Don't treat DT_TEXTREL in output as error (default)\n"));
2090 }
2091 else
2092 {
2093 fprintf (file, _("\
2094 -z notext Don't treat DT_TEXTREL in output as error\n"));
2095 fprintf (file, _("\
2096 -z textoff Don't treat DT_TEXTREL in output as error\n"));
2097 }
2098 }
2099
2100 static void
2101 elf_static_list_options (FILE *file)
2102 {
2103 fprintf (file, _("\
2104 --build-id[=STYLE] Generate build ID note\n"));
2105 fprintf (file, _("\
2106 --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]\n\
2107 Compress DWARF debug sections using zlib\n"));
2108 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
2109 fprintf (file, _("\
2110 Default: zlib-gabi\n"));
2111 #else
2112 fprintf (file, _("\
2113 Default: none\n"));
2114 #endif
2115 fprintf (file, _("\
2116 -z common-page-size=SIZE Set common page size to SIZE\n"));
2117 fprintf (file, _("\
2118 -z max-page-size=SIZE Set maximum page size to SIZE\n"));
2119 fprintf (file, _("\
2120 -z defs Report unresolved symbols in object files\n"));
2121 fprintf (file, _("\
2122 -z undefs Ignore unresolved symbols in object files\n"));
2123 fprintf (file, _("\
2124 -z muldefs Allow multiple definitions\n"));
2125 fprintf (file, _("\
2126 -z stack-size=SIZE Set size of stack segment\n"));
2127 fprintf (file, _("\
2128 -z execstack Mark executable as requiring executable stack\n"));
2129 fprintf (file, _("\
2130 -z noexecstack Mark executable as not requiring executable stack\n"));
2131 fprintf (file, _("\
2132 -z unique-symbol Avoid duplicated local symbol names\n"));
2133 fprintf (file, _("\
2134 -z nounique-symbol Keep duplicated local symbol names (default)\n"));
2135 fprintf (file, _("\
2136 -z globalaudit Mark executable requiring global auditing\n"));
2137 fprintf (file, _("\
2138 -z start-stop-gc Enable garbage collection on __start/__stop\n"));
2139 fprintf (file, _("\
2140 -z nostart-stop-gc Don't garbage collect __start/__stop (default)\n"));
2141 fprintf (file, _("\
2142 -z start-stop-visibility=V Set visibility of built-in __start/__stop symbols\n\
2143 to DEFAULT, PROTECTED, HIDDEN or INTERNAL\n"));
2144 }
2145
2146 static void
2147 elf_plt_unwind_list_options (FILE *file)
2148 {
2149 fprintf (file, _("\
2150 --ld-generated-unwind-info Generate exception handling info for PLT\n"));
2151 fprintf (file, _("\
2152 --no-ld-generated-unwind-info\n\
2153 Don't generate exception handling info for PLT\n"));
2154 }
2155
2156 static void
2157 ld_list_options (FILE *file, bool elf, bool shlib, bool plt_unwind)
2158 {
2159 if (!elf)
2160 return;
2161 printf (_("ELF emulations:\n"));
2162 if (plt_unwind)
2163 elf_plt_unwind_list_options (file);
2164 elf_static_list_options (file);
2165 if (shlib)
2166 elf_shlib_list_options (file);
2167 }
2168
2169 \f
2170 /* Print help messages for the options. */
2171
2172 static void
2173 help (void)
2174 {
2175 unsigned i;
2176 const char **targets, **pp;
2177 int len;
2178
2179 printf (_("Usage: %s [options] file...\n"), program_name);
2180
2181 printf (_("Options:\n"));
2182 for (i = 0; i < OPTION_COUNT; i++)
2183 {
2184 if (ld_options[i].doc != NULL)
2185 {
2186 bool comma;
2187 unsigned j;
2188
2189 printf (" ");
2190
2191 comma = false;
2192 len = 2;
2193
2194 j = i;
2195 do
2196 {
2197 if (ld_options[j].shortopt != '\0'
2198 && ld_options[j].control != NO_HELP)
2199 {
2200 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
2201 len += (comma ? 2 : 0) + 2;
2202 if (ld_options[j].arg != NULL)
2203 {
2204 if (ld_options[j].opt.has_arg != optional_argument)
2205 {
2206 printf (" ");
2207 ++len;
2208 }
2209 printf ("%s", _(ld_options[j].arg));
2210 len += strlen (_(ld_options[j].arg));
2211 }
2212 comma = true;
2213 }
2214 ++j;
2215 }
2216 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
2217
2218 j = i;
2219 do
2220 {
2221 if (ld_options[j].opt.name != NULL
2222 && ld_options[j].control != NO_HELP)
2223 {
2224 int two_dashes =
2225 (ld_options[j].control == TWO_DASHES
2226 || ld_options[j].control == EXACTLY_TWO_DASHES);
2227
2228 printf ("%s-%s%s",
2229 comma ? ", " : "",
2230 two_dashes ? "-" : "",
2231 ld_options[j].opt.name);
2232 len += ((comma ? 2 : 0)
2233 + 1
2234 + (two_dashes ? 1 : 0)
2235 + strlen (ld_options[j].opt.name));
2236 if (ld_options[j].arg != NULL)
2237 {
2238 printf (" %s", _(ld_options[j].arg));
2239 len += 1 + strlen (_(ld_options[j].arg));
2240 }
2241 comma = true;
2242 }
2243 ++j;
2244 }
2245 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
2246
2247 if (len >= 30)
2248 {
2249 printf ("\n");
2250 len = 0;
2251 }
2252
2253 for (; len < 30; len++)
2254 putchar (' ');
2255
2256 printf ("%s\n", _(ld_options[i].doc));
2257 }
2258 }
2259 printf (_(" @FILE"));
2260 for (len = strlen (" @FILE"); len < 30; len++)
2261 putchar (' ');
2262 printf (_("Read options from FILE\n"));
2263
2264 /* Note: Various tools (such as libtool) depend upon the
2265 format of the listings below - do not change them. */
2266 /* xgettext:c-format */
2267 printf (_("%s: supported targets:"), program_name);
2268 targets = bfd_target_list ();
2269 for (pp = targets; *pp != NULL; pp++)
2270 printf (" %s", *pp);
2271 free (targets);
2272 printf ("\n");
2273
2274 /* xgettext:c-format */
2275 printf (_("%s: supported emulations: "), program_name);
2276 ldemul_list_emulations (stdout);
2277 printf ("\n");
2278
2279 /* xgettext:c-format */
2280 printf (_("%s: emulation specific options:\n"), program_name);
2281 ld_list_options (stdout, ELF_LIST_OPTIONS, ELF_SHLIB_LIST_OPTIONS,
2282 ELF_PLT_UNWIND_LIST_OPTIONS);
2283 ldemul_list_emulation_options (stdout);
2284 printf ("\n");
2285
2286 if (REPORT_BUGS_TO[0])
2287 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);
2288 }
This page took 0.083787 seconds and 4 git commands to generate.