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