ld/
[deliverable/binutils-gdb.git] / ld / lexsup.c
1 /* Parse options for the GNU linker.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012
4 Free Software Foundation, Inc.
5
6 This file is part of the GNU Binutils.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
22
23 #include "sysdep.h"
24 #include "bfd.h"
25 #include "bfdver.h"
26 #include "libiberty.h"
27 #include <stdio.h>
28 #include <string.h>
29 #include "safe-ctype.h"
30 #include "getopt.h"
31 #include "bfdlink.h"
32 #include "ld.h"
33 #include "ldmain.h"
34 #include "ldmisc.h"
35 #include "ldexp.h"
36 #include "ldlang.h"
37 #include <ldgram.h>
38 #include "ldlex.h"
39 #include "ldfile.h"
40 #include "ldver.h"
41 #include "ldemul.h"
42 #include "demangle.h"
43 #ifdef ENABLE_PLUGINS
44 #include "plugin.h"
45 #endif /* ENABLE_PLUGINS */
46
47 #ifndef PATH_SEPARATOR
48 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
49 #define PATH_SEPARATOR ';'
50 #else
51 #define PATH_SEPARATOR ':'
52 #endif
53 #endif
54
55 /* Somewhere above, sys/stat.h got included . . . . */
56 #if !defined(S_ISDIR) && defined(S_IFDIR)
57 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
58 #endif
59
60 static void set_default_dirlist (char *);
61 static void set_section_start (char *, char *);
62 static void set_segment_start (const char *, char *);
63 static void help (void);
64
65 /* The long options. This structure is used for both the option
66 parsing and the help text. */
67
68 enum control_enum {
69 /* Use one dash before long option name. */
70 ONE_DASH,
71 /* Use two dashes before long option name. */
72 TWO_DASHES,
73 /* Only accept two dashes before the long option name.
74 This is an overloading of the use of this enum, since originally it
75 was only intended to tell the --help display function how to display
76 the long option name. This feature was added in order to resolve
77 the confusion about the -omagic command line switch. Is it setting
78 the output file name to "magic" or is it setting the NMAGIC flag on
79 the output ? It has been decided that it is setting the output file
80 name, and that if you want to set the NMAGIC flag you should use -N
81 or --omagic. */
82 EXACTLY_TWO_DASHES,
83 /* Don't mention this option in --help output. */
84 NO_HELP
85 };
86
87 struct ld_option
88 {
89 /* The long option information. */
90 struct option opt;
91 /* The short option with the same meaning ('\0' if none). */
92 char shortopt;
93 /* The name of the argument (NULL if none). */
94 const char *arg;
95 /* The documentation string. If this is NULL, this is a synonym for
96 the previous option. */
97 const char *doc;
98 enum control_enum control;
99 };
100
101 static const struct ld_option ld_options[] =
102 {
103 { {NULL, required_argument, NULL, '\0'},
104 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
105 ONE_DASH },
106 { {"architecture", required_argument, NULL, 'A'},
107 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES },
108 { {"format", required_argument, NULL, 'b'},
109 'b', N_("TARGET"), N_("Specify target for following input files"),
110 TWO_DASHES },
111 { {"mri-script", required_argument, NULL, 'c'},
112 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES },
113 { {"dc", no_argument, NULL, 'd'},
114 'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
115 { {"dp", no_argument, NULL, 'd'},
116 '\0', NULL, NULL, ONE_DASH },
117 { {"entry", required_argument, NULL, 'e'},
118 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
119 { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
120 'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
121 { {"no-export-dynamic", no_argument, NULL, OPTION_NO_EXPORT_DYNAMIC},
122 '\0', NULL, N_("Undo the effect of --export-dynamic"), TWO_DASHES },
123 { {"EB", no_argument, NULL, OPTION_EB},
124 '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
125 { {"EL", no_argument, NULL, OPTION_EL},
126 '\0', NULL, N_("Link little-endian objects"), ONE_DASH },
127 { {"auxiliary", required_argument, NULL, 'f'},
128 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
129 TWO_DASHES },
130 { {"filter", required_argument, NULL, 'F'},
131 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
132 TWO_DASHES },
133 { {NULL, no_argument, NULL, '\0'},
134 'g', NULL, N_("Ignored"), ONE_DASH },
135 { {"gpsize", required_argument, NULL, 'G'},
136 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
137 TWO_DASHES },
138 { {"soname", required_argument, NULL, OPTION_SONAME},
139 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
140 { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
141 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
142 TWO_DASHES },
143 { {"library", required_argument, NULL, 'l'},
144 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
145 { {"library-path", required_argument, NULL, 'L'},
146 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
147 TWO_DASHES },
148 { {"sysroot=<DIRECTORY>", required_argument, NULL, OPTION_SYSROOT},
149 '\0', NULL, N_("Override the default sysroot location"), TWO_DASHES },
150 { {NULL, required_argument, NULL, '\0'},
151 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH },
152 { {"print-map", no_argument, NULL, 'M'},
153 'M', NULL, N_("Print map file on standard output"), TWO_DASHES },
154 { {"nmagic", no_argument, NULL, 'n'},
155 'n', NULL, N_("Do not page align data"), TWO_DASHES },
156 { {"omagic", no_argument, NULL, 'N'},
157 'N', NULL, N_("Do not page align data, do not make text readonly"),
158 EXACTLY_TWO_DASHES },
159 { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC},
160 '\0', NULL, N_("Page align data, make text readonly"),
161 EXACTLY_TWO_DASHES },
162 { {"output", required_argument, NULL, 'o'},
163 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES },
164 { {NULL, required_argument, NULL, '\0'},
165 'O', NULL, N_("Optimize output file"), ONE_DASH },
166 #ifdef ENABLE_PLUGINS
167 { {"plugin", required_argument, NULL, OPTION_PLUGIN},
168 '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
169 { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
170 '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
171 { {"flto", optional_argument, NULL, OPTION_IGNORE},
172 '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
173 ONE_DASH },
174 { {"flto-partition=", required_argument, NULL, OPTION_IGNORE},
175 '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
176 ONE_DASH },
177 #endif /* ENABLE_PLUGINS */
178 { {"Qy", no_argument, NULL, OPTION_IGNORE},
179 '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
180 { {"emit-relocs", no_argument, NULL, 'q'},
181 'q', NULL, "Generate relocations in final output", TWO_DASHES },
182 { {"relocatable", no_argument, NULL, 'r'},
183 'r', NULL, N_("Generate relocatable output"), TWO_DASHES },
184 { {NULL, no_argument, NULL, '\0'},
185 'i', NULL, NULL, ONE_DASH },
186 { {"just-symbols", required_argument, NULL, 'R'},
187 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
188 TWO_DASHES },
189 { {"strip-all", no_argument, NULL, 's'},
190 's', NULL, N_("Strip all symbols"), TWO_DASHES },
191 { {"strip-debug", no_argument, NULL, 'S'},
192 'S', NULL, N_("Strip debugging symbols"), TWO_DASHES },
193 { {"strip-discarded", no_argument, NULL, OPTION_STRIP_DISCARDED},
194 '\0', NULL, N_("Strip symbols in discarded sections"), TWO_DASHES },
195 { {"no-strip-discarded", no_argument, NULL, OPTION_NO_STRIP_DISCARDED},
196 '\0', NULL, N_("Do not strip symbols in discarded sections"), TWO_DASHES },
197 { {"trace", no_argument, NULL, 't'},
198 't', NULL, N_("Trace file opens"), TWO_DASHES },
199 { {"script", required_argument, NULL, 'T'},
200 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
201 { {"default-script", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
202 '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES },
203 { {"dT", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
204 '\0', NULL, NULL, ONE_DASH },
205 { {"undefined", required_argument, NULL, 'u'},
206 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
207 TWO_DASHES },
208 { {"unique", optional_argument, NULL, OPTION_UNIQUE},
209 '\0', N_("[=SECTION]"),
210 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
211 { {"Ur", no_argument, NULL, OPTION_UR},
212 '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
213 { {"version", no_argument, NULL, OPTION_VERSION},
214 'v', NULL, N_("Print version information"), TWO_DASHES },
215 { {NULL, no_argument, NULL, '\0'},
216 'V', NULL, N_("Print version and emulation information"), ONE_DASH },
217 { {"discard-all", no_argument, NULL, 'x'},
218 'x', NULL, N_("Discard all local symbols"), TWO_DASHES },
219 { {"discard-locals", no_argument, NULL, 'X'},
220 'X', NULL, N_("Discard temporary local symbols (default)"), TWO_DASHES },
221 { {"discard-none", no_argument, NULL, OPTION_DISCARD_NONE},
222 '\0', NULL, N_("Don't discard any local symbols"), TWO_DASHES },
223 { {"trace-symbol", required_argument, NULL, 'y'},
224 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
225 { {NULL, required_argument, NULL, '\0'},
226 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
227 ONE_DASH },
228 { {"start-group", no_argument, NULL, '('},
229 '(', NULL, N_("Start a group"), TWO_DASHES },
230 { {"end-group", no_argument, NULL, ')'},
231 ')', NULL, N_("End a group"), TWO_DASHES },
232 { {"accept-unknown-input-arch", no_argument, NULL,
233 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH},
234 '\0', NULL,
235 N_("Accept input files whose architecture cannot be determined"),
236 TWO_DASHES },
237 { {"no-accept-unknown-input-arch", no_argument, NULL,
238 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
239 '\0', NULL, N_("Reject input files whose architecture is unknown"),
240 TWO_DASHES },
241
242 /* The next two options are deprecated because of their similarity to
243 --as-needed and --no-as-needed. They have been replaced by
244 --copy-dt-needed-entries and --no-copy-dt-needed-entries. */
245 { {"add-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
246 '\0', NULL, NULL, NO_HELP },
247 { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
248 '\0', NULL, NULL, NO_HELP },
249
250 { {"as-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_REGULAR},
251 '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
252 TWO_DASHES },
253 { {"no-as-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR},
254 '\0', NULL, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
255 " the command line"),
256 TWO_DASHES },
257 { {"assert", required_argument, NULL, OPTION_ASSERT},
258 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
259 { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
260 '\0', NULL, N_("Link against shared libraries"), ONE_DASH },
261 { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
262 '\0', NULL, NULL, ONE_DASH },
263 { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
264 '\0', NULL, NULL, ONE_DASH },
265 { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
266 '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
267 { {"dn", no_argument, NULL, OPTION_NON_SHARED},
268 '\0', NULL, NULL, ONE_DASH },
269 { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
270 '\0', NULL, NULL, ONE_DASH },
271 { {"static", no_argument, NULL, OPTION_NON_SHARED},
272 '\0', NULL, NULL, ONE_DASH },
273 { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
274 '\0', NULL, N_("Bind global references locally"), ONE_DASH },
275 { {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS},
276 '\0', NULL, N_("Bind global function references locally"), ONE_DASH },
277 { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
278 '\0', NULL, N_("Check section addresses for overlaps (default)"),
279 TWO_DASHES },
280 { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
281 '\0', NULL, N_("Do not check section addresses for overlaps"),
282 TWO_DASHES },
283 { {"copy-dt-needed-entries", no_argument, NULL,
284 OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
285 '\0', NULL, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
286 TWO_DASHES },
287 { {"no-copy-dt-needed-entries", no_argument, NULL,
288 OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
289 '\0', NULL, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
290 TWO_DASHES },
291
292 { {"cref", no_argument, NULL, OPTION_CREF},
293 '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
294 { {"defsym", required_argument, NULL, OPTION_DEFSYM},
295 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
296 { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
297 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
298 TWO_DASHES },
299 { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
300 '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
301 { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
302 '\0', NULL, N_("Treat warnings as errors"),
303 TWO_DASHES },
304 { {"no-fatal-warnings", no_argument, NULL, OPTION_NO_WARN_FATAL},
305 '\0', NULL, N_("Do not treat warnings as errors (default)"),
306 TWO_DASHES },
307 { {"fini", required_argument, NULL, OPTION_FINI},
308 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
309 { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
310 '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
311 { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
312 '\0', NULL, N_("Remove unused sections (on some targets)"),
313 TWO_DASHES },
314 { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
315 '\0', NULL, N_("Don't remove unused sections (default)"),
316 TWO_DASHES },
317 { {"print-gc-sections", no_argument, NULL, OPTION_PRINT_GC_SECTIONS},
318 '\0', NULL, N_("List removed unused sections on stderr"),
319 TWO_DASHES },
320 { {"no-print-gc-sections", no_argument, NULL, OPTION_NO_PRINT_GC_SECTIONS},
321 '\0', NULL, N_("Do not list removed unused sections"),
322 TWO_DASHES },
323 { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
324 '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
325 TWO_DASHES },
326 { {"help", no_argument, NULL, OPTION_HELP},
327 '\0', NULL, N_("Print option help"), TWO_DASHES },
328 { {"init", required_argument, NULL, OPTION_INIT},
329 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
330 { {"Map", required_argument, NULL, OPTION_MAP},
331 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH },
332 { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
333 '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
334 { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
335 '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
336 { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
337 '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES },
338 { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
339 '\0', NULL, N_("Do not allow unresolved references in object files"),
340 TWO_DASHES },
341 { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED},
342 '\0', NULL, N_("Allow unresolved references in shared libraries"),
343 TWO_DASHES },
344 { {"no-allow-shlib-undefined", no_argument, NULL,
345 OPTION_NO_ALLOW_SHLIB_UNDEFINED},
346 '\0', NULL, N_("Do not allow unresolved references in shared libs"),
347 TWO_DASHES },
348 { {"allow-multiple-definition", no_argument, NULL,
349 OPTION_ALLOW_MULTIPLE_DEFINITION},
350 '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES },
351 { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
352 '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
353 { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER},
354 '\0', NULL, N_("Create default symbol version"), TWO_DASHES },
355 { {"default-imported-symver", no_argument, NULL,
356 OPTION_DEFAULT_IMPORTED_SYMVER},
357 '\0', NULL, N_("Create default symbol version for imported symbols"),
358 TWO_DASHES },
359 { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
360 '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
361 { {"no-warn-search-mismatch", no_argument, NULL,
362 OPTION_NO_WARN_SEARCH_MISMATCH},
363 '\0', NULL, N_("Don't warn on finding an incompatible library"),
364 TWO_DASHES},
365 { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
366 '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
367 { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
368 '\0', NULL, N_("Create an output file even if errors occur"),
369 TWO_DASHES },
370 { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
371 '\0', NULL, NULL, NO_HELP },
372 { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB},
373 '\0', NULL, N_("Only use library directories specified on\n"
374 " the command line"),
375 ONE_DASH },
376 { {"oformat", required_argument, NULL, OPTION_OFORMAT},
377 '\0', N_("TARGET"), N_("Specify target of output file"),
378 EXACTLY_TWO_DASHES },
379 { {"print-output-format", no_argument, NULL, OPTION_PRINT_OUTPUT_FORMAT},
380 '\0', NULL, N_("Print default output format"), TWO_DASHES },
381 { {"qmagic", no_argument, NULL, OPTION_IGNORE},
382 '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
383 { {"reduce-memory-overheads", no_argument, NULL,
384 OPTION_REDUCE_MEMORY_OVERHEADS},
385 '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
386 TWO_DASHES },
387 { {"relax", no_argument, NULL, OPTION_RELAX},
388 '\0', NULL, N_("Reduce code size by using target specific optimizations"), TWO_DASHES },
389 { {"no-relax", no_argument, NULL, OPTION_NO_RELAX},
390 '\0', NULL, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES },
391 { {"retain-symbols-file", required_argument, NULL,
392 OPTION_RETAIN_SYMBOLS_FILE},
393 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
394 { {"rpath", required_argument, NULL, OPTION_RPATH},
395 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH },
396 { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
397 '\0', N_("PATH"), N_("Set link time shared library search path"),
398 ONE_DASH },
399 { {"shared", no_argument, NULL, OPTION_SHARED},
400 '\0', NULL, N_("Create a shared library"), ONE_DASH },
401 { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */
402 '\0', NULL, NULL, ONE_DASH },
403 { {"pie", no_argument, NULL, OPTION_PIE},
404 '\0', NULL, N_("Create a position independent executable"), ONE_DASH },
405 { {"pic-executable", no_argument, NULL, OPTION_PIE},
406 '\0', NULL, NULL, TWO_DASHES },
407 { {"sort-common", optional_argument, NULL, OPTION_SORT_COMMON},
408 '\0', N_("[=ascending|descending]"),
409 N_("Sort common symbols by alignment [in specified order]"),
410 TWO_DASHES },
411 { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
412 '\0', NULL, NULL, NO_HELP },
413 { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
414 '\0', N_("name|alignment"),
415 N_("Sort sections by name or maximum alignment"), TWO_DASHES },
416 { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
417 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
418 TWO_DASHES },
419 { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE},
420 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
421 TWO_DASHES },
422 { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC},
423 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
424 TWO_DASHES },
425 { {"stats", no_argument, NULL, OPTION_STATS},
426 '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
427 { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
428 '\0', NULL, N_("Display target specific options"), TWO_DASHES },
429 { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
430 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
431 { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
432 '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
433 { {"section-start", required_argument, NULL, OPTION_SECTION_START},
434 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
435 TWO_DASHES },
436 { {"Tbss", required_argument, NULL, OPTION_TBSS},
437 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
438 { {"Tdata", required_argument, NULL, OPTION_TDATA},
439 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
440 { {"Ttext", required_argument, NULL, OPTION_TTEXT},
441 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
442 { {"Ttext-segment", required_argument, NULL, OPTION_TTEXT_SEGMENT},
443 '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH },
444 { {"Trodata-segment", required_argument, NULL, OPTION_TRODATA_SEGMENT},
445 '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH },
446 { {"unresolved-symbols=<method>", required_argument, NULL,
447 OPTION_UNRESOLVED_SYMBOLS},
448 '\0', NULL, N_("How to handle unresolved symbols. <method> is:\n"
449 " ignore-all, report-all, ignore-in-object-files,\n"
450 " ignore-in-shared-libs"),
451 TWO_DASHES },
452 { {"verbose", optional_argument, NULL, OPTION_VERBOSE},
453 '\0', N_("[=NUMBER]"),
454 N_("Output lots of information during link"), TWO_DASHES },
455 { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */
456 '\0', NULL, NULL, NO_HELP },
457 { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
458 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
459 { {"version-exports-section", required_argument, NULL,
460 OPTION_VERSION_EXPORTS_SECTION },
461 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
462 " SYMBOL as the version."),
463 TWO_DASHES },
464 { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
465 '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
466 { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
467 '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES },
468 { {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
469 '\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
470 { {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
471 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
472 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
473 '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
474 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
475 '\0', NULL, N_("Warn if global constructors/destructors are seen"),
476 TWO_DASHES },
477 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
478 '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
479 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
480 '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
481 { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
482 '\0', NULL, N_("Warn if start of section changes due to alignment"),
483 TWO_DASHES },
484 { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_SHARED_TEXTREL},
485 '\0', NULL, N_("Warn if shared object has DT_TEXTREL"),
486 TWO_DASHES },
487 { {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM},
488 '\0', NULL, N_("Warn if an object has alternate ELF machine code"),
489 TWO_DASHES },
490 { {"warn-unresolved-symbols", no_argument, NULL,
491 OPTION_WARN_UNRESOLVED_SYMBOLS},
492 '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
493 { {"error-unresolved-symbols", no_argument, NULL,
494 OPTION_ERROR_UNRESOLVED_SYMBOLS},
495 '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES },
496 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
497 '\0', NULL, N_("Include all objects from following archives"),
498 TWO_DASHES },
499 { {"wrap", required_argument, NULL, OPTION_WRAP},
500 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
501 { {"ignore-unresolved-symbol", required_argument, NULL,
502 OPTION_IGNORE_UNRESOLVED_SYMBOL},
503 '\0', N_("SYMBOL"),
504 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
505 };
506
507 #define OPTION_COUNT ARRAY_SIZE (ld_options)
508
509 void
510 parse_args (unsigned argc, char **argv)
511 {
512 unsigned i;
513 int is, il, irl;
514 int ingroup = 0;
515 char *default_dirlist = NULL;
516 char *shortopts;
517 struct option *longopts;
518 struct option *really_longopts;
519 int last_optind;
520 enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
521
522 shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
523 longopts = (struct option *)
524 xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
525 really_longopts = (struct option *)
526 malloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
527
528 /* Starting the short option string with '-' is for programs that
529 expect options and other ARGV-elements in any order and that care about
530 the ordering of the two. We describe each non-option ARGV-element
531 as if it were the argument of an option with character code 1. */
532 shortopts[0] = '-';
533 is = 1;
534 il = 0;
535 irl = 0;
536 for (i = 0; i < OPTION_COUNT; i++)
537 {
538 if (ld_options[i].shortopt != '\0')
539 {
540 shortopts[is] = ld_options[i].shortopt;
541 ++is;
542 if (ld_options[i].opt.has_arg == required_argument
543 || ld_options[i].opt.has_arg == optional_argument)
544 {
545 shortopts[is] = ':';
546 ++is;
547 if (ld_options[i].opt.has_arg == optional_argument)
548 {
549 shortopts[is] = ':';
550 ++is;
551 }
552 }
553 }
554 if (ld_options[i].opt.name != NULL)
555 {
556 if (ld_options[i].control == EXACTLY_TWO_DASHES)
557 {
558 really_longopts[irl] = ld_options[i].opt;
559 ++irl;
560 }
561 else
562 {
563 longopts[il] = ld_options[i].opt;
564 ++il;
565 }
566 }
567 }
568 shortopts[is] = '\0';
569 longopts[il].name = NULL;
570 really_longopts[irl].name = NULL;
571
572 ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
573
574 /* The -G option is ambiguous on different platforms. Sometimes it
575 specifies the largest data size to put into the small data
576 section. Sometimes it is equivalent to --shared. Unfortunately,
577 the first form takes an argument, while the second does not.
578
579 We need to permit the --shared form because on some platforms,
580 such as Solaris, gcc -shared will pass -G to the linker.
581
582 To permit either usage, we look through the argument list. If we
583 find -G not followed by a number, we change it into --shared.
584 This will work for most normal cases. */
585 for (i = 1; i < argc; i++)
586 if (strcmp (argv[i], "-G") == 0
587 && (i + 1 >= argc
588 || ! ISDIGIT (argv[i + 1][0])))
589 argv[i] = (char *) "--shared";
590
591 /* Because we permit long options to start with a single dash, and
592 we have a --library option, and the -l option is conventionally
593 used with an immediately following argument, we can have bad
594 results if somebody tries to use -l with a library whose name
595 happens to start with "ibrary", as in -li. We avoid problems by
596 simply turning -l into --library. This means that users will
597 have to use two dashes in order to use --library, which is OK
598 since that's how it is documented.
599
600 FIXME: It's possible that this problem can arise for other short
601 options as well, although the user does always have the recourse
602 of adding a space between the option and the argument. */
603 for (i = 1; i < argc; i++)
604 {
605 if (argv[i][0] == '-'
606 && argv[i][1] == 'l'
607 && argv[i][2] != '\0')
608 {
609 char *n;
610
611 n = (char *) xmalloc (strlen (argv[i]) + 20);
612 sprintf (n, "--library=%s", argv[i] + 2);
613 argv[i] = n;
614 }
615 }
616
617 last_optind = -1;
618 while (1)
619 {
620 int longind;
621 int optc;
622 static unsigned int defsym_count;
623
624 /* Using last_optind lets us avoid calling ldemul_parse_args
625 multiple times on a single option, which would lead to
626 confusion in the internal static variables maintained by
627 getopt. This could otherwise happen for an argument like
628 -nx, in which the -n is parsed as a single option, and we
629 loop around to pick up the -x. */
630 if (optind != last_optind)
631 if (ldemul_parse_args (argc, argv))
632 continue;
633
634 /* getopt_long_only is like getopt_long, but '-' as well as '--'
635 can indicate a long option. */
636 opterr = 0;
637 last_optind = optind;
638 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
639 if (optc == '?')
640 {
641 optind = last_optind;
642 optc = getopt_long (argc, argv, "-", really_longopts, &longind);
643 }
644
645 if (ldemul_handle_option (optc))
646 continue;
647
648 if (optc == -1)
649 break;
650
651 switch (optc)
652 {
653 case '?':
654 einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
655 /* Fall through. */
656
657 default:
658 einfo (_("%P%F: use the --help option for usage information\n"));
659
660 case 1: /* File name. */
661 lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL);
662 break;
663
664 case OPTION_IGNORE:
665 break;
666 case 'a':
667 /* For HP/UX compatibility. Actually -a shared should mean
668 ``use only shared libraries'' but, then, we don't
669 currently support shared libraries on HP/UX anyhow. */
670 if (strcmp (optarg, "archive") == 0)
671 input_flags.dynamic = FALSE;
672 else if (strcmp (optarg, "shared") == 0
673 || strcmp (optarg, "default") == 0)
674 input_flags.dynamic = TRUE;
675 else
676 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg);
677 break;
678 case OPTION_ASSERT:
679 /* FIXME: We just ignore these, but we should handle them. */
680 if (strcmp (optarg, "definitions") == 0)
681 ;
682 else if (strcmp (optarg, "nodefinitions") == 0)
683 ;
684 else if (strcmp (optarg, "nosymbolic") == 0)
685 ;
686 else if (strcmp (optarg, "pure-text") == 0)
687 ;
688 else
689 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg);
690 break;
691 case 'A':
692 ldfile_add_arch (optarg);
693 break;
694 case 'b':
695 lang_add_target (optarg);
696 break;
697 case 'c':
698 ldfile_open_command_file (optarg);
699 parser_input = input_mri_script;
700 yyparse ();
701 break;
702 case OPTION_CALL_SHARED:
703 input_flags.dynamic = TRUE;
704 break;
705 case OPTION_NON_SHARED:
706 input_flags.dynamic = FALSE;
707 break;
708 case OPTION_CREF:
709 command_line.cref = TRUE;
710 link_info.notice_all = TRUE;
711 break;
712 case 'd':
713 command_line.force_common_definition = TRUE;
714 break;
715 case OPTION_DEFSYM:
716 lex_string = optarg;
717 lex_redirect (optarg, "--defsym", ++defsym_count);
718 parser_input = input_defsym;
719 yyparse ();
720 lex_string = NULL;
721 break;
722 case OPTION_DEMANGLE:
723 demangling = TRUE;
724 if (optarg != NULL)
725 {
726 enum demangling_styles style;
727
728 style = cplus_demangle_name_to_style (optarg);
729 if (style == unknown_demangling)
730 einfo (_("%F%P: unknown demangling style `%s'\n"),
731 optarg);
732
733 cplus_demangle_set_style (style);
734 }
735 break;
736 case 'I': /* Used on Solaris. */
737 case OPTION_DYNAMIC_LINKER:
738 command_line.interpreter = optarg;
739 break;
740 case OPTION_SYSROOT:
741 /* Already handled in ldmain.c. */
742 break;
743 case OPTION_EB:
744 command_line.endian = ENDIAN_BIG;
745 break;
746 case OPTION_EL:
747 command_line.endian = ENDIAN_LITTLE;
748 break;
749 case OPTION_EMBEDDED_RELOCS:
750 command_line.embedded_relocs = TRUE;
751 break;
752 case OPTION_EXPORT_DYNAMIC:
753 case 'E': /* HP/UX compatibility. */
754 link_info.export_dynamic = TRUE;
755 break;
756 case OPTION_NO_EXPORT_DYNAMIC:
757 link_info.export_dynamic = FALSE;
758 break;
759 case 'e':
760 lang_add_entry (optarg, TRUE);
761 break;
762 case 'f':
763 if (command_line.auxiliary_filters == NULL)
764 {
765 command_line.auxiliary_filters = (char **)
766 xmalloc (2 * sizeof (char *));
767 command_line.auxiliary_filters[0] = optarg;
768 command_line.auxiliary_filters[1] = NULL;
769 }
770 else
771 {
772 int c;
773 char **p;
774
775 c = 0;
776 for (p = command_line.auxiliary_filters; *p != NULL; p++)
777 ++c;
778 command_line.auxiliary_filters = (char **)
779 xrealloc (command_line.auxiliary_filters,
780 (c + 2) * sizeof (char *));
781 command_line.auxiliary_filters[c] = optarg;
782 command_line.auxiliary_filters[c + 1] = NULL;
783 }
784 break;
785 case 'F':
786 command_line.filter_shlib = optarg;
787 break;
788 case OPTION_FORCE_EXE_SUFFIX:
789 command_line.force_exe_suffix = TRUE;
790 break;
791 case 'G':
792 {
793 char *end;
794 g_switch_value = strtoul (optarg, &end, 0);
795 if (*end)
796 einfo (_("%P%F: invalid number `%s'\n"), optarg);
797 }
798 break;
799 case 'g':
800 /* Ignore. */
801 break;
802 case OPTION_GC_SECTIONS:
803 link_info.gc_sections = TRUE;
804 break;
805 case OPTION_PRINT_GC_SECTIONS:
806 link_info.print_gc_sections = TRUE;
807 break;
808 case OPTION_HELP:
809 help ();
810 xexit (0);
811 break;
812 case 'L':
813 ldfile_add_library_path (optarg, TRUE);
814 break;
815 case 'l':
816 lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL);
817 break;
818 case 'M':
819 config.map_filename = "-";
820 break;
821 case 'm':
822 /* Ignore. Was handled in a pre-parse. */
823 break;
824 case OPTION_MAP:
825 config.map_filename = optarg;
826 break;
827 case 'N':
828 config.text_read_only = FALSE;
829 config.magic_demand_paged = FALSE;
830 input_flags.dynamic = FALSE;
831 break;
832 case OPTION_NO_OMAGIC:
833 config.text_read_only = TRUE;
834 config.magic_demand_paged = TRUE;
835 /* NB/ Does not set input_flags.dynamic to TRUE.
836 Use --call-shared or -Bdynamic for this. */
837 break;
838 case 'n':
839 config.magic_demand_paged = FALSE;
840 input_flags.dynamic = FALSE;
841 break;
842 case OPTION_NO_DEFINE_COMMON:
843 command_line.inhibit_common_definition = TRUE;
844 break;
845 case OPTION_NO_DEMANGLE:
846 demangling = FALSE;
847 break;
848 case OPTION_NO_GC_SECTIONS:
849 link_info.gc_sections = FALSE;
850 break;
851 case OPTION_NO_PRINT_GC_SECTIONS:
852 link_info.print_gc_sections = FALSE;
853 break;
854 case OPTION_NO_KEEP_MEMORY:
855 link_info.keep_memory = FALSE;
856 break;
857 case OPTION_NO_UNDEFINED:
858 link_info.unresolved_syms_in_objects
859 = how_to_report_unresolved_symbols;
860 break;
861 case OPTION_ALLOW_SHLIB_UNDEFINED:
862 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
863 break;
864 case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
865 link_info.unresolved_syms_in_shared_libs
866 = how_to_report_unresolved_symbols;
867 break;
868 case OPTION_UNRESOLVED_SYMBOLS:
869 if (strcmp (optarg, "ignore-all") == 0)
870 {
871 link_info.unresolved_syms_in_objects = RM_IGNORE;
872 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
873 }
874 else if (strcmp (optarg, "report-all") == 0)
875 {
876 link_info.unresolved_syms_in_objects
877 = how_to_report_unresolved_symbols;
878 link_info.unresolved_syms_in_shared_libs
879 = how_to_report_unresolved_symbols;
880 }
881 else if (strcmp (optarg, "ignore-in-object-files") == 0)
882 {
883 link_info.unresolved_syms_in_objects = RM_IGNORE;
884 link_info.unresolved_syms_in_shared_libs
885 = how_to_report_unresolved_symbols;
886 }
887 else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
888 {
889 link_info.unresolved_syms_in_objects
890 = how_to_report_unresolved_symbols;
891 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
892 }
893 else
894 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg);
895 break;
896 case OPTION_WARN_UNRESOLVED_SYMBOLS:
897 how_to_report_unresolved_symbols = RM_GENERATE_WARNING;
898 if (link_info.unresolved_syms_in_objects == RM_GENERATE_ERROR)
899 link_info.unresolved_syms_in_objects = RM_GENERATE_WARNING;
900 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
901 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_WARNING;
902 break;
903
904 case OPTION_ERROR_UNRESOLVED_SYMBOLS:
905 how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
906 if (link_info.unresolved_syms_in_objects == RM_GENERATE_WARNING)
907 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
908 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_WARNING)
909 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
910 break;
911 case OPTION_ALLOW_MULTIPLE_DEFINITION:
912 link_info.allow_multiple_definition = TRUE;
913 break;
914 case OPTION_NO_UNDEFINED_VERSION:
915 link_info.allow_undefined_version = FALSE;
916 break;
917 case OPTION_DEFAULT_SYMVER:
918 link_info.create_default_symver = TRUE;
919 break;
920 case OPTION_DEFAULT_IMPORTED_SYMVER:
921 link_info.default_imported_symver = TRUE;
922 break;
923 case OPTION_NO_WARN_MISMATCH:
924 command_line.warn_mismatch = FALSE;
925 break;
926 case OPTION_NO_WARN_SEARCH_MISMATCH:
927 command_line.warn_search_mismatch = FALSE;
928 break;
929 case OPTION_NOINHIBIT_EXEC:
930 force_make_executable = TRUE;
931 break;
932 case OPTION_NOSTDLIB:
933 config.only_cmd_line_lib_dirs = TRUE;
934 break;
935 case OPTION_NO_WHOLE_ARCHIVE:
936 input_flags.whole_archive = FALSE;
937 break;
938 case 'O':
939 /* FIXME "-O<non-digits> <value>" used to set the address of
940 section <non-digits>. Was this for compatibility with
941 something, or can we create a new option to do that
942 (with a syntax similar to -defsym)?
943 getopt can't handle two args to an option without kludges. */
944
945 /* Enable optimizations of output files. */
946 link_info.optimize = strtoul (optarg, NULL, 0) ? TRUE : FALSE;
947 break;
948 case 'o':
949 lang_add_output (optarg, 0);
950 break;
951 case OPTION_OFORMAT:
952 lang_add_output_format (optarg, NULL, NULL, 0);
953 break;
954 case OPTION_PRINT_OUTPUT_FORMAT:
955 command_line.print_output_format = TRUE;
956 break;
957 #ifdef ENABLE_PLUGINS
958 case OPTION_PLUGIN:
959 plugin_opt_plugin (optarg);
960 break;
961 case OPTION_PLUGIN_OPT:
962 if (plugin_opt_plugin_arg (optarg))
963 einfo(_("%P%F: bad -plugin-opt option\n"));
964 break;
965 #endif /* ENABLE_PLUGINS */
966 case 'q':
967 link_info.emitrelocations = TRUE;
968 break;
969 case 'i':
970 case 'r':
971 if (optind == last_optind)
972 /* This can happen if the user put "-rpath,a" on the command
973 line. (Or something similar. The comma is important).
974 Getopt becomes confused and thinks that this is a -r option
975 but it cannot parse the text after the -r so it refuses to
976 increment the optind counter. Detect this case and issue
977 an error message here. We cannot just make this a warning,
978 increment optind, and continue because getopt is too confused
979 and will seg-fault the next time around. */
980 einfo(_("%P%F: bad -rpath option\n"));
981
982 link_info.relocatable = TRUE;
983 config.build_constructors = FALSE;
984 config.magic_demand_paged = FALSE;
985 config.text_read_only = FALSE;
986 input_flags.dynamic = FALSE;
987 break;
988 case 'R':
989 /* The GNU linker traditionally uses -R to mean to include
990 only the symbols from a file. The Solaris linker uses -R
991 to set the path used by the runtime linker to find
992 libraries. This is the GNU linker -rpath argument. We
993 try to support both simultaneously by checking the file
994 named. If it is a directory, rather than a regular file,
995 we assume -rpath was meant. */
996 {
997 struct stat s;
998
999 if (stat (optarg, &s) >= 0
1000 && ! S_ISDIR (s.st_mode))
1001 {
1002 lang_add_input_file (optarg,
1003 lang_input_file_is_symbols_only_enum,
1004 NULL);
1005 break;
1006 }
1007 }
1008 /* Fall through. */
1009 case OPTION_RPATH:
1010 if (command_line.rpath == NULL)
1011 command_line.rpath = xstrdup (optarg);
1012 else
1013 {
1014 size_t rpath_len = strlen (command_line.rpath);
1015 size_t optarg_len = strlen (optarg);
1016 char *buf;
1017 char *cp = command_line.rpath;
1018
1019 /* First see whether OPTARG is already in the path. */
1020 do
1021 {
1022 if (strncmp (optarg, cp, optarg_len) == 0
1023 && (cp[optarg_len] == 0
1024 || cp[optarg_len] == config.rpath_separator))
1025 /* We found it. */
1026 break;
1027
1028 /* Not yet found. */
1029 cp = strchr (cp, config.rpath_separator);
1030 if (cp != NULL)
1031 ++cp;
1032 }
1033 while (cp != NULL);
1034
1035 if (cp == NULL)
1036 {
1037 buf = (char *) xmalloc (rpath_len + optarg_len + 2);
1038 sprintf (buf, "%s%c%s", command_line.rpath,
1039 config.rpath_separator, optarg);
1040 free (command_line.rpath);
1041 command_line.rpath = buf;
1042 }
1043 }
1044 break;
1045 case OPTION_RPATH_LINK:
1046 if (command_line.rpath_link == NULL)
1047 command_line.rpath_link = xstrdup (optarg);
1048 else
1049 {
1050 char *buf;
1051
1052 buf = (char *) xmalloc (strlen (command_line.rpath_link)
1053 + strlen (optarg)
1054 + 2);
1055 sprintf (buf, "%s%c%s", command_line.rpath_link,
1056 config.rpath_separator, optarg);
1057 free (command_line.rpath_link);
1058 command_line.rpath_link = buf;
1059 }
1060 break;
1061 case OPTION_NO_RELAX:
1062 DISABLE_RELAXATION;
1063 break;
1064 case OPTION_RELAX:
1065 ENABLE_RELAXATION;
1066 break;
1067 case OPTION_RETAIN_SYMBOLS_FILE:
1068 add_keepsyms_file (optarg);
1069 break;
1070 case 'S':
1071 link_info.strip = strip_debugger;
1072 break;
1073 case 's':
1074 link_info.strip = strip_all;
1075 break;
1076 case OPTION_STRIP_DISCARDED:
1077 link_info.strip_discarded = TRUE;
1078 break;
1079 case OPTION_NO_STRIP_DISCARDED:
1080 link_info.strip_discarded = FALSE;
1081 break;
1082 case OPTION_SHARED:
1083 if (config.has_shared)
1084 {
1085 link_info.shared = TRUE;
1086 /* When creating a shared library, the default
1087 behaviour is to ignore any unresolved references. */
1088 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1089 link_info.unresolved_syms_in_objects = RM_IGNORE;
1090 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1091 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1092 }
1093 else
1094 einfo (_("%P%F: -shared not supported\n"));
1095 break;
1096 case OPTION_PIE:
1097 if (config.has_shared)
1098 {
1099 link_info.shared = TRUE;
1100 link_info.pie = TRUE;
1101 }
1102 else
1103 einfo (_("%P%F: -pie not supported\n"));
1104 break;
1105 case 'h': /* Used on Solaris. */
1106 case OPTION_SONAME:
1107 command_line.soname = optarg;
1108 break;
1109 case OPTION_SORT_COMMON:
1110 if (optarg == NULL
1111 || strcmp (optarg, N_("descending")) == 0)
1112 config.sort_common = sort_descending;
1113 else if (strcmp (optarg, N_("ascending")) == 0)
1114 config.sort_common = sort_ascending;
1115 else
1116 einfo (_("%P%F: invalid common section sorting option: %s\n"),
1117 optarg);
1118 break;
1119 case OPTION_SORT_SECTION:
1120 if (strcmp (optarg, N_("name")) == 0)
1121 sort_section = by_name;
1122 else if (strcmp (optarg, N_("alignment")) == 0)
1123 sort_section = by_alignment;
1124 else
1125 einfo (_("%P%F: invalid section sorting option: %s\n"),
1126 optarg);
1127 break;
1128 case OPTION_STATS:
1129 config.stats = TRUE;
1130 break;
1131 case OPTION_SYMBOLIC:
1132 command_line.symbolic = symbolic;
1133 break;
1134 case OPTION_SYMBOLIC_FUNCTIONS:
1135 command_line.symbolic = symbolic_functions;
1136 break;
1137 case 't':
1138 trace_files = TRUE;
1139 break;
1140 case 'T':
1141 previous_script_handle = saved_script_handle;
1142 ldfile_open_command_file (optarg);
1143 parser_input = input_script;
1144 yyparse ();
1145 previous_script_handle = NULL;
1146 break;
1147 case OPTION_DEFAULT_SCRIPT:
1148 command_line.default_script = optarg;
1149 break;
1150 case OPTION_SECTION_START:
1151 {
1152 char *optarg2;
1153 char *sec_name;
1154 int len;
1155
1156 /* Check for <something>=<somthing>... */
1157 optarg2 = strchr (optarg, '=');
1158 if (optarg2 == NULL)
1159 einfo (_("%P%F: invalid argument to option"
1160 " \"--section-start\"\n"));
1161
1162 optarg2++;
1163
1164 /* So far so good. Are all the args present? */
1165 if ((*optarg == '\0') || (*optarg2 == '\0'))
1166 einfo (_("%P%F: missing argument(s) to option"
1167 " \"--section-start\"\n"));
1168
1169 /* We must copy the section name as set_section_start
1170 doesn't do it for us. */
1171 len = optarg2 - optarg;
1172 sec_name = (char *) xmalloc (len);
1173 memcpy (sec_name, optarg, len - 1);
1174 sec_name[len - 1] = 0;
1175
1176 /* Then set it... */
1177 set_section_start (sec_name, optarg2);
1178 }
1179 break;
1180 case OPTION_TARGET_HELP:
1181 /* Mention any target specific options. */
1182 ldemul_list_emulation_options (stdout);
1183 exit (0);
1184 case OPTION_TBSS:
1185 set_segment_start (".bss", optarg);
1186 break;
1187 case OPTION_TDATA:
1188 set_segment_start (".data", optarg);
1189 break;
1190 case OPTION_TTEXT:
1191 set_segment_start (".text", optarg);
1192 break;
1193 case OPTION_TTEXT_SEGMENT:
1194 set_segment_start (".text-segment", optarg);
1195 break;
1196 case OPTION_TRODATA_SEGMENT:
1197 set_segment_start (".rodata-segment", optarg);
1198 break;
1199 case OPTION_TRADITIONAL_FORMAT:
1200 link_info.traditional_format = TRUE;
1201 break;
1202 case OPTION_TASK_LINK:
1203 link_info.task_link = TRUE;
1204 /* Fall through - do an implied -r option. */
1205 case OPTION_UR:
1206 link_info.relocatable = TRUE;
1207 config.build_constructors = TRUE;
1208 config.magic_demand_paged = FALSE;
1209 config.text_read_only = FALSE;
1210 input_flags.dynamic = FALSE;
1211 break;
1212 case 'u':
1213 ldlang_add_undef (optarg, TRUE);
1214 break;
1215 case OPTION_UNIQUE:
1216 if (optarg != NULL)
1217 lang_add_unique (optarg);
1218 else
1219 config.unique_orphan_sections = TRUE;
1220 break;
1221 case OPTION_VERBOSE:
1222 ldversion (1);
1223 version_printed = TRUE;
1224 verbose = TRUE;
1225 overflow_cutoff_limit = -2;
1226 if (optarg != NULL)
1227 {
1228 char *end;
1229 int level ATTRIBUTE_UNUSED = strtoul (optarg, &end, 0);
1230 if (*end)
1231 einfo (_("%P%F: invalid number `%s'\n"), optarg);
1232 #ifdef ENABLE_PLUGINS
1233 report_plugin_symbols = level > 1;
1234 #endif /* ENABLE_PLUGINS */
1235 }
1236 break;
1237 case 'v':
1238 ldversion (0);
1239 version_printed = TRUE;
1240 break;
1241 case 'V':
1242 ldversion (1);
1243 version_printed = TRUE;
1244 break;
1245 case OPTION_VERSION:
1246 ldversion (2);
1247 xexit (0);
1248 break;
1249 case OPTION_VERSION_SCRIPT:
1250 /* This option indicates a small script that only specifies
1251 version information. Read it, but don't assume that
1252 we've seen a linker script. */
1253 {
1254 FILE *hold_script_handle;
1255
1256 hold_script_handle = saved_script_handle;
1257 ldfile_open_command_file (optarg);
1258 saved_script_handle = hold_script_handle;
1259 parser_input = input_version_script;
1260 yyparse ();
1261 }
1262 break;
1263 case OPTION_VERSION_EXPORTS_SECTION:
1264 /* This option records a version symbol to be applied to the
1265 symbols listed for export to be found in the object files
1266 .exports sections. */
1267 command_line.version_exports_section = optarg;
1268 break;
1269 case OPTION_DYNAMIC_LIST_DATA:
1270 command_line.dynamic_list = dynamic_list_data;
1271 if (command_line.symbolic == symbolic)
1272 command_line.symbolic = symbolic_unset;
1273 break;
1274 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
1275 lang_append_dynamic_list_cpp_typeinfo ();
1276 if (command_line.dynamic_list != dynamic_list_data)
1277 command_line.dynamic_list = dynamic_list;
1278 if (command_line.symbolic == symbolic)
1279 command_line.symbolic = symbolic_unset;
1280 break;
1281 case OPTION_DYNAMIC_LIST_CPP_NEW:
1282 lang_append_dynamic_list_cpp_new ();
1283 if (command_line.dynamic_list != dynamic_list_data)
1284 command_line.dynamic_list = dynamic_list;
1285 if (command_line.symbolic == symbolic)
1286 command_line.symbolic = symbolic_unset;
1287 break;
1288 case OPTION_DYNAMIC_LIST:
1289 /* This option indicates a small script that only specifies
1290 a dynamic list. Read it, but don't assume that we've
1291 seen a linker script. */
1292 {
1293 FILE *hold_script_handle;
1294
1295 hold_script_handle = saved_script_handle;
1296 ldfile_open_command_file (optarg);
1297 saved_script_handle = hold_script_handle;
1298 parser_input = input_dynamic_list;
1299 yyparse ();
1300 }
1301 if (command_line.dynamic_list != dynamic_list_data)
1302 command_line.dynamic_list = dynamic_list;
1303 if (command_line.symbolic == symbolic)
1304 command_line.symbolic = symbolic_unset;
1305 break;
1306 case OPTION_WARN_COMMON:
1307 config.warn_common = TRUE;
1308 break;
1309 case OPTION_WARN_CONSTRUCTORS:
1310 config.warn_constructors = TRUE;
1311 break;
1312 case OPTION_WARN_FATAL:
1313 config.fatal_warnings = TRUE;
1314 break;
1315 case OPTION_NO_WARN_FATAL:
1316 config.fatal_warnings = FALSE;
1317 break;
1318 case OPTION_WARN_MULTIPLE_GP:
1319 config.warn_multiple_gp = TRUE;
1320 break;
1321 case OPTION_WARN_ONCE:
1322 config.warn_once = TRUE;
1323 break;
1324 case OPTION_WARN_SECTION_ALIGN:
1325 config.warn_section_align = TRUE;
1326 break;
1327 case OPTION_WARN_SHARED_TEXTREL:
1328 link_info.warn_shared_textrel = TRUE;
1329 break;
1330 case OPTION_WARN_ALTERNATE_EM:
1331 link_info.warn_alternate_em = TRUE;
1332 break;
1333 case OPTION_WHOLE_ARCHIVE:
1334 input_flags.whole_archive = TRUE;
1335 break;
1336 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC:
1337 input_flags.add_DT_NEEDED_for_dynamic = TRUE;
1338 break;
1339 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC:
1340 input_flags.add_DT_NEEDED_for_dynamic = FALSE;
1341 break;
1342 case OPTION_ADD_DT_NEEDED_FOR_REGULAR:
1343 input_flags.add_DT_NEEDED_for_regular = TRUE;
1344 break;
1345 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR:
1346 input_flags.add_DT_NEEDED_for_regular = FALSE;
1347 break;
1348 case OPTION_WRAP:
1349 add_wrap (optarg);
1350 break;
1351 case OPTION_IGNORE_UNRESOLVED_SYMBOL:
1352 add_ignoresym (&link_info, optarg);
1353 break;
1354 case OPTION_DISCARD_NONE:
1355 link_info.discard = discard_none;
1356 break;
1357 case 'X':
1358 link_info.discard = discard_l;
1359 break;
1360 case 'x':
1361 link_info.discard = discard_all;
1362 break;
1363 case 'Y':
1364 if (CONST_STRNEQ (optarg, "P,"))
1365 optarg += 2;
1366 if (default_dirlist != NULL)
1367 free (default_dirlist);
1368 default_dirlist = xstrdup (optarg);
1369 break;
1370 case 'y':
1371 add_ysym (optarg);
1372 break;
1373 case OPTION_SPARE_DYNAMIC_TAGS:
1374 link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0);
1375 break;
1376 case OPTION_SPLIT_BY_RELOC:
1377 if (optarg != NULL)
1378 config.split_by_reloc = strtoul (optarg, NULL, 0);
1379 else
1380 config.split_by_reloc = 32768;
1381 break;
1382 case OPTION_SPLIT_BY_FILE:
1383 if (optarg != NULL)
1384 config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
1385 else
1386 config.split_by_file = 1;
1387 break;
1388 case OPTION_CHECK_SECTIONS:
1389 command_line.check_section_addresses = 1;
1390 break;
1391 case OPTION_NO_CHECK_SECTIONS:
1392 command_line.check_section_addresses = 0;
1393 break;
1394 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
1395 command_line.accept_unknown_input_arch = TRUE;
1396 break;
1397 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
1398 command_line.accept_unknown_input_arch = FALSE;
1399 break;
1400 case '(':
1401 lang_enter_group ();
1402 ingroup++;
1403 break;
1404 case ')':
1405 if (! ingroup)
1406 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1407
1408 lang_leave_group ();
1409 ingroup--;
1410 break;
1411
1412 case OPTION_INIT:
1413 link_info.init_function = optarg;
1414 break;
1415
1416 case OPTION_FINI:
1417 link_info.fini_function = optarg;
1418 break;
1419
1420 case OPTION_REDUCE_MEMORY_OVERHEADS:
1421 link_info.reduce_memory_overheads = TRUE;
1422 if (config.hash_table_size == 0)
1423 config.hash_table_size = 1021;
1424 break;
1425
1426 case OPTION_HASH_SIZE:
1427 {
1428 bfd_size_type new_size;
1429
1430 new_size = strtoul (optarg, NULL, 0);
1431 if (new_size)
1432 config.hash_table_size = new_size;
1433 else
1434 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1435 }
1436 break;
1437 }
1438 }
1439
1440 while (ingroup)
1441 {
1442 lang_leave_group ();
1443 ingroup--;
1444 }
1445
1446 if (default_dirlist != NULL)
1447 {
1448 set_default_dirlist (default_dirlist);
1449 free (default_dirlist);
1450 }
1451
1452 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1453 /* FIXME: Should we allow emulations a chance to set this ? */
1454 link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
1455
1456 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1457 /* FIXME: Should we allow emulations a chance to set this ? */
1458 link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
1459
1460 if (link_info.relocatable)
1461 {
1462 if (command_line.check_section_addresses < 0)
1463 command_line.check_section_addresses = 0;
1464 if (link_info.shared)
1465 einfo (_("%P%F: -r and -shared may not be used together\n"));
1466 }
1467
1468 /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data,
1469 --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and
1470 --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are
1471 for shared libraries. -Bsymbolic overrides all others and vice
1472 versa. */
1473 switch (command_line.symbolic)
1474 {
1475 case symbolic_unset:
1476 break;
1477 case symbolic:
1478 /* -Bsymbolic is for shared library only. */
1479 if (link_info.shared)
1480 {
1481 link_info.symbolic = TRUE;
1482 /* Should we free the unused memory? */
1483 link_info.dynamic_list = NULL;
1484 command_line.dynamic_list = dynamic_list_unset;
1485 }
1486 break;
1487 case symbolic_functions:
1488 /* -Bsymbolic-functions is for shared library only. */
1489 if (link_info.shared)
1490 command_line.dynamic_list = dynamic_list_data;
1491 break;
1492 }
1493
1494 switch (command_line.dynamic_list)
1495 {
1496 case dynamic_list_unset:
1497 break;
1498 case dynamic_list_data:
1499 link_info.dynamic_data = TRUE;
1500 case dynamic_list:
1501 link_info.dynamic = TRUE;
1502 break;
1503 }
1504
1505 if (! link_info.shared)
1506 {
1507 if (command_line.filter_shlib)
1508 einfo (_("%P%F: -F may not be used without -shared\n"));
1509 if (command_line.auxiliary_filters)
1510 einfo (_("%P%F: -f may not be used without -shared\n"));
1511 }
1512
1513 if (! link_info.shared || link_info.pie)
1514 link_info.executable = TRUE;
1515
1516 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
1517 don't see how else this can be handled, since in this case we
1518 must preserve all externally visible symbols. */
1519 if (link_info.relocatable && link_info.strip == strip_all)
1520 {
1521 link_info.strip = strip_debugger;
1522 if (link_info.discard == discard_sec_merge)
1523 link_info.discard = discard_all;
1524 }
1525 }
1526
1527 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1528 library search path. */
1529
1530 static void
1531 set_default_dirlist (char *dirlist_ptr)
1532 {
1533 char *p;
1534
1535 while (1)
1536 {
1537 p = strchr (dirlist_ptr, PATH_SEPARATOR);
1538 if (p != NULL)
1539 *p = '\0';
1540 if (*dirlist_ptr != '\0')
1541 ldfile_add_library_path (dirlist_ptr, TRUE);
1542 if (p == NULL)
1543 break;
1544 dirlist_ptr = p + 1;
1545 }
1546 }
1547
1548 static void
1549 set_section_start (char *sect, char *valstr)
1550 {
1551 const char *end;
1552 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1553 if (*end)
1554 einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
1555 lang_section_start (sect, exp_intop (val), NULL);
1556 }
1557
1558 static void
1559 set_segment_start (const char *section, char *valstr)
1560 {
1561 const char *name;
1562 const char *end;
1563 segment_type *seg;
1564
1565 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1566 if (*end)
1567 einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
1568 /* If we already have an entry for this segment, update the existing
1569 value. */
1570 name = section + 1;
1571 for (seg = segments; seg; seg = seg->next)
1572 if (strcmp (seg->name, name) == 0)
1573 {
1574 seg->value = val;
1575 return;
1576 }
1577 /* There was no existing value so we must create a new segment
1578 entry. */
1579 seg = (segment_type *) stat_alloc (sizeof (*seg));
1580 seg->name = name;
1581 seg->value = val;
1582 seg->used = FALSE;
1583 /* Add it to the linked list of segments. */
1584 seg->next = segments;
1585 segments = seg;
1586 /* Historically, -Ttext and friends set the base address of a
1587 particular section. For backwards compatibility, we still do
1588 that. If a SEGMENT_START directive is seen, the section address
1589 assignment will be disabled. */
1590 lang_section_start (section, exp_intop (val), seg);
1591 }
1592
1593 \f
1594 /* Print help messages for the options. */
1595
1596 static void
1597 help (void)
1598 {
1599 unsigned i;
1600 const char **targets, **pp;
1601 int len;
1602
1603 printf (_("Usage: %s [options] file...\n"), program_name);
1604
1605 printf (_("Options:\n"));
1606 for (i = 0; i < OPTION_COUNT; i++)
1607 {
1608 if (ld_options[i].doc != NULL)
1609 {
1610 bfd_boolean comma;
1611 unsigned j;
1612
1613 printf (" ");
1614
1615 comma = FALSE;
1616 len = 2;
1617
1618 j = i;
1619 do
1620 {
1621 if (ld_options[j].shortopt != '\0'
1622 && ld_options[j].control != NO_HELP)
1623 {
1624 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
1625 len += (comma ? 2 : 0) + 2;
1626 if (ld_options[j].arg != NULL)
1627 {
1628 if (ld_options[j].opt.has_arg != optional_argument)
1629 {
1630 printf (" ");
1631 ++len;
1632 }
1633 printf ("%s", _(ld_options[j].arg));
1634 len += strlen (_(ld_options[j].arg));
1635 }
1636 comma = TRUE;
1637 }
1638 ++j;
1639 }
1640 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1641
1642 j = i;
1643 do
1644 {
1645 if (ld_options[j].opt.name != NULL
1646 && ld_options[j].control != NO_HELP)
1647 {
1648 int two_dashes =
1649 (ld_options[j].control == TWO_DASHES
1650 || ld_options[j].control == EXACTLY_TWO_DASHES);
1651
1652 printf ("%s-%s%s",
1653 comma ? ", " : "",
1654 two_dashes ? "-" : "",
1655 ld_options[j].opt.name);
1656 len += ((comma ? 2 : 0)
1657 + 1
1658 + (two_dashes ? 1 : 0)
1659 + strlen (ld_options[j].opt.name));
1660 if (ld_options[j].arg != NULL)
1661 {
1662 printf (" %s", _(ld_options[j].arg));
1663 len += 1 + strlen (_(ld_options[j].arg));
1664 }
1665 comma = TRUE;
1666 }
1667 ++j;
1668 }
1669 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1670
1671 if (len >= 30)
1672 {
1673 printf ("\n");
1674 len = 0;
1675 }
1676
1677 for (; len < 30; len++)
1678 putchar (' ');
1679
1680 printf ("%s\n", _(ld_options[i].doc));
1681 }
1682 }
1683 printf (_(" @FILE"));
1684 for (len = strlen (" @FILE"); len < 30; len++)
1685 putchar (' ');
1686 printf (_("Read options from FILE\n"));
1687
1688 /* Note: Various tools (such as libtool) depend upon the
1689 format of the listings below - do not change them. */
1690 /* xgettext:c-format */
1691 printf (_("%s: supported targets:"), program_name);
1692 targets = bfd_target_list ();
1693 for (pp = targets; *pp != NULL; pp++)
1694 printf (" %s", *pp);
1695 free (targets);
1696 printf ("\n");
1697
1698 /* xgettext:c-format */
1699 printf (_("%s: supported emulations: "), program_name);
1700 ldemul_list_emulations (stdout);
1701 printf ("\n");
1702
1703 /* xgettext:c-format */
1704 printf (_("%s: emulation specific options:\n"), program_name);
1705 ldemul_list_emulation_options (stdout);
1706 printf ("\n");
1707
1708 if (REPORT_BUGS_TO[0])
1709 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);
1710 }
This page took 0.068958 seconds and 5 git commands to generate.