]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/lexsup.c
PR ld/14357
[thirdparty/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 { {"unresolved-symbols=<method>", required_argument, NULL,
445 OPTION_UNRESOLVED_SYMBOLS},
446 '\0', NULL, N_("How to handle unresolved symbols. <method> is:\n"
447 " ignore-all, report-all, ignore-in-object-files,\n"
448 " ignore-in-shared-libs"),
449 TWO_DASHES },
450 { {"verbose", optional_argument, NULL, OPTION_VERBOSE},
451 '\0', N_("[=NUMBER]"),
452 N_("Output lots of information during link"), TWO_DASHES },
453 { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */
454 '\0', NULL, NULL, NO_HELP },
455 { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
456 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
457 { {"version-exports-section", required_argument, NULL,
458 OPTION_VERSION_EXPORTS_SECTION },
459 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
460 " SYMBOL as the version."),
461 TWO_DASHES },
462 { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
463 '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
464 { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
465 '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES },
466 { {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
467 '\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
468 { {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
469 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
470 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
471 '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
472 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
473 '\0', NULL, N_("Warn if global constructors/destructors are seen"),
474 TWO_DASHES },
475 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
476 '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
477 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
478 '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
479 { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
480 '\0', NULL, N_("Warn if start of section changes due to alignment"),
481 TWO_DASHES },
482 { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_SHARED_TEXTREL},
483 '\0', NULL, N_("Warn if shared object has DT_TEXTREL"),
484 TWO_DASHES },
485 { {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM},
486 '\0', NULL, N_("Warn if an object has alternate ELF machine code"),
487 TWO_DASHES },
488 { {"warn-unresolved-symbols", no_argument, NULL,
489 OPTION_WARN_UNRESOLVED_SYMBOLS},
490 '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
491 { {"error-unresolved-symbols", no_argument, NULL,
492 OPTION_ERROR_UNRESOLVED_SYMBOLS},
493 '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES },
494 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
495 '\0', NULL, N_("Include all objects from following archives"),
496 TWO_DASHES },
497 { {"wrap", required_argument, NULL, OPTION_WRAP},
498 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
499 };
500
501 #define OPTION_COUNT ARRAY_SIZE (ld_options)
502
503 void
504 parse_args (unsigned argc, char **argv)
505 {
506 unsigned i;
507 int is, il, irl;
508 int ingroup = 0;
509 char *default_dirlist = NULL;
510 char *shortopts;
511 struct option *longopts;
512 struct option *really_longopts;
513 int last_optind;
514 enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
515
516 shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
517 longopts = (struct option *)
518 xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
519 really_longopts = (struct option *)
520 malloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
521
522 /* Starting the short option string with '-' is for programs that
523 expect options and other ARGV-elements in any order and that care about
524 the ordering of the two. We describe each non-option ARGV-element
525 as if it were the argument of an option with character code 1. */
526 shortopts[0] = '-';
527 is = 1;
528 il = 0;
529 irl = 0;
530 for (i = 0; i < OPTION_COUNT; i++)
531 {
532 if (ld_options[i].shortopt != '\0')
533 {
534 shortopts[is] = ld_options[i].shortopt;
535 ++is;
536 if (ld_options[i].opt.has_arg == required_argument
537 || ld_options[i].opt.has_arg == optional_argument)
538 {
539 shortopts[is] = ':';
540 ++is;
541 if (ld_options[i].opt.has_arg == optional_argument)
542 {
543 shortopts[is] = ':';
544 ++is;
545 }
546 }
547 }
548 if (ld_options[i].opt.name != NULL)
549 {
550 if (ld_options[i].control == EXACTLY_TWO_DASHES)
551 {
552 really_longopts[irl] = ld_options[i].opt;
553 ++irl;
554 }
555 else
556 {
557 longopts[il] = ld_options[i].opt;
558 ++il;
559 }
560 }
561 }
562 shortopts[is] = '\0';
563 longopts[il].name = NULL;
564 really_longopts[irl].name = NULL;
565
566 ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
567
568 /* The -G option is ambiguous on different platforms. Sometimes it
569 specifies the largest data size to put into the small data
570 section. Sometimes it is equivalent to --shared. Unfortunately,
571 the first form takes an argument, while the second does not.
572
573 We need to permit the --shared form because on some platforms,
574 such as Solaris, gcc -shared will pass -G to the linker.
575
576 To permit either usage, we look through the argument list. If we
577 find -G not followed by a number, we change it into --shared.
578 This will work for most normal cases. */
579 for (i = 1; i < argc; i++)
580 if (strcmp (argv[i], "-G") == 0
581 && (i + 1 >= argc
582 || ! ISDIGIT (argv[i + 1][0])))
583 argv[i] = (char *) "--shared";
584
585 /* Because we permit long options to start with a single dash, and
586 we have a --library option, and the -l option is conventionally
587 used with an immediately following argument, we can have bad
588 results if somebody tries to use -l with a library whose name
589 happens to start with "ibrary", as in -li. We avoid problems by
590 simply turning -l into --library. This means that users will
591 have to use two dashes in order to use --library, which is OK
592 since that's how it is documented.
593
594 FIXME: It's possible that this problem can arise for other short
595 options as well, although the user does always have the recourse
596 of adding a space between the option and the argument. */
597 for (i = 1; i < argc; i++)
598 {
599 if (argv[i][0] == '-'
600 && argv[i][1] == 'l'
601 && argv[i][2] != '\0')
602 {
603 char *n;
604
605 n = (char *) xmalloc (strlen (argv[i]) + 20);
606 sprintf (n, "--library=%s", argv[i] + 2);
607 argv[i] = n;
608 }
609 }
610
611 last_optind = -1;
612 while (1)
613 {
614 int longind;
615 int optc;
616 static unsigned int defsym_count;
617
618 /* Using last_optind lets us avoid calling ldemul_parse_args
619 multiple times on a single option, which would lead to
620 confusion in the internal static variables maintained by
621 getopt. This could otherwise happen for an argument like
622 -nx, in which the -n is parsed as a single option, and we
623 loop around to pick up the -x. */
624 if (optind != last_optind)
625 if (ldemul_parse_args (argc, argv))
626 continue;
627
628 /* getopt_long_only is like getopt_long, but '-' as well as '--'
629 can indicate a long option. */
630 opterr = 0;
631 last_optind = optind;
632 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
633 if (optc == '?')
634 {
635 optind = last_optind;
636 optc = getopt_long (argc, argv, "-", really_longopts, &longind);
637 }
638
639 if (ldemul_handle_option (optc))
640 continue;
641
642 if (optc == -1)
643 break;
644
645 switch (optc)
646 {
647 case '?':
648 einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
649 /* Fall through. */
650
651 default:
652 einfo (_("%P%F: use the --help option for usage information\n"));
653
654 case 1: /* File name. */
655 lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL);
656 break;
657
658 case OPTION_IGNORE:
659 break;
660 case 'a':
661 /* For HP/UX compatibility. Actually -a shared should mean
662 ``use only shared libraries'' but, then, we don't
663 currently support shared libraries on HP/UX anyhow. */
664 if (strcmp (optarg, "archive") == 0)
665 input_flags.dynamic = FALSE;
666 else if (strcmp (optarg, "shared") == 0
667 || strcmp (optarg, "default") == 0)
668 input_flags.dynamic = TRUE;
669 else
670 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg);
671 break;
672 case OPTION_ASSERT:
673 /* FIXME: We just ignore these, but we should handle them. */
674 if (strcmp (optarg, "definitions") == 0)
675 ;
676 else if (strcmp (optarg, "nodefinitions") == 0)
677 ;
678 else if (strcmp (optarg, "nosymbolic") == 0)
679 ;
680 else if (strcmp (optarg, "pure-text") == 0)
681 ;
682 else
683 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg);
684 break;
685 case 'A':
686 ldfile_add_arch (optarg);
687 break;
688 case 'b':
689 lang_add_target (optarg);
690 break;
691 case 'c':
692 ldfile_open_command_file (optarg);
693 parser_input = input_mri_script;
694 yyparse ();
695 break;
696 case OPTION_CALL_SHARED:
697 input_flags.dynamic = TRUE;
698 break;
699 case OPTION_NON_SHARED:
700 input_flags.dynamic = FALSE;
701 break;
702 case OPTION_CREF:
703 command_line.cref = TRUE;
704 link_info.notice_all = TRUE;
705 break;
706 case 'd':
707 command_line.force_common_definition = TRUE;
708 break;
709 case OPTION_DEFSYM:
710 lex_string = optarg;
711 lex_redirect (optarg, "--defsym", ++defsym_count);
712 parser_input = input_defsym;
713 yyparse ();
714 lex_string = NULL;
715 break;
716 case OPTION_DEMANGLE:
717 demangling = TRUE;
718 if (optarg != NULL)
719 {
720 enum demangling_styles style;
721
722 style = cplus_demangle_name_to_style (optarg);
723 if (style == unknown_demangling)
724 einfo (_("%F%P: unknown demangling style `%s'\n"),
725 optarg);
726
727 cplus_demangle_set_style (style);
728 }
729 break;
730 case 'I': /* Used on Solaris. */
731 case OPTION_DYNAMIC_LINKER:
732 command_line.interpreter = optarg;
733 break;
734 case OPTION_SYSROOT:
735 /* Already handled in ldmain.c. */
736 break;
737 case OPTION_EB:
738 command_line.endian = ENDIAN_BIG;
739 break;
740 case OPTION_EL:
741 command_line.endian = ENDIAN_LITTLE;
742 break;
743 case OPTION_EMBEDDED_RELOCS:
744 command_line.embedded_relocs = TRUE;
745 break;
746 case OPTION_EXPORT_DYNAMIC:
747 case 'E': /* HP/UX compatibility. */
748 link_info.export_dynamic = TRUE;
749 break;
750 case OPTION_NO_EXPORT_DYNAMIC:
751 link_info.export_dynamic = FALSE;
752 break;
753 case 'e':
754 lang_add_entry (optarg, TRUE);
755 break;
756 case 'f':
757 if (command_line.auxiliary_filters == NULL)
758 {
759 command_line.auxiliary_filters = (char **)
760 xmalloc (2 * sizeof (char *));
761 command_line.auxiliary_filters[0] = optarg;
762 command_line.auxiliary_filters[1] = NULL;
763 }
764 else
765 {
766 int c;
767 char **p;
768
769 c = 0;
770 for (p = command_line.auxiliary_filters; *p != NULL; p++)
771 ++c;
772 command_line.auxiliary_filters = (char **)
773 xrealloc (command_line.auxiliary_filters,
774 (c + 2) * sizeof (char *));
775 command_line.auxiliary_filters[c] = optarg;
776 command_line.auxiliary_filters[c + 1] = NULL;
777 }
778 break;
779 case 'F':
780 command_line.filter_shlib = optarg;
781 break;
782 case OPTION_FORCE_EXE_SUFFIX:
783 command_line.force_exe_suffix = TRUE;
784 break;
785 case 'G':
786 {
787 char *end;
788 g_switch_value = strtoul (optarg, &end, 0);
789 if (*end)
790 einfo (_("%P%F: invalid number `%s'\n"), optarg);
791 }
792 break;
793 case 'g':
794 /* Ignore. */
795 break;
796 case OPTION_GC_SECTIONS:
797 link_info.gc_sections = TRUE;
798 break;
799 case OPTION_PRINT_GC_SECTIONS:
800 link_info.print_gc_sections = TRUE;
801 break;
802 case OPTION_HELP:
803 help ();
804 xexit (0);
805 break;
806 case 'L':
807 ldfile_add_library_path (optarg, TRUE);
808 break;
809 case 'l':
810 lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL);
811 break;
812 case 'M':
813 config.map_filename = "-";
814 break;
815 case 'm':
816 /* Ignore. Was handled in a pre-parse. */
817 break;
818 case OPTION_MAP:
819 config.map_filename = optarg;
820 break;
821 case 'N':
822 config.text_read_only = FALSE;
823 config.magic_demand_paged = FALSE;
824 input_flags.dynamic = FALSE;
825 break;
826 case OPTION_NO_OMAGIC:
827 config.text_read_only = TRUE;
828 config.magic_demand_paged = TRUE;
829 /* NB/ Does not set input_flags.dynamic to TRUE.
830 Use --call-shared or -Bdynamic for this. */
831 break;
832 case 'n':
833 config.magic_demand_paged = FALSE;
834 input_flags.dynamic = FALSE;
835 break;
836 case OPTION_NO_DEFINE_COMMON:
837 command_line.inhibit_common_definition = TRUE;
838 break;
839 case OPTION_NO_DEMANGLE:
840 demangling = FALSE;
841 break;
842 case OPTION_NO_GC_SECTIONS:
843 link_info.gc_sections = FALSE;
844 break;
845 case OPTION_NO_PRINT_GC_SECTIONS:
846 link_info.print_gc_sections = FALSE;
847 break;
848 case OPTION_NO_KEEP_MEMORY:
849 link_info.keep_memory = FALSE;
850 break;
851 case OPTION_NO_UNDEFINED:
852 link_info.unresolved_syms_in_objects
853 = how_to_report_unresolved_symbols;
854 break;
855 case OPTION_ALLOW_SHLIB_UNDEFINED:
856 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
857 break;
858 case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
859 link_info.unresolved_syms_in_shared_libs
860 = how_to_report_unresolved_symbols;
861 break;
862 case OPTION_UNRESOLVED_SYMBOLS:
863 if (strcmp (optarg, "ignore-all") == 0)
864 {
865 link_info.unresolved_syms_in_objects = RM_IGNORE;
866 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
867 }
868 else if (strcmp (optarg, "report-all") == 0)
869 {
870 link_info.unresolved_syms_in_objects
871 = how_to_report_unresolved_symbols;
872 link_info.unresolved_syms_in_shared_libs
873 = how_to_report_unresolved_symbols;
874 }
875 else if (strcmp (optarg, "ignore-in-object-files") == 0)
876 {
877 link_info.unresolved_syms_in_objects = RM_IGNORE;
878 link_info.unresolved_syms_in_shared_libs
879 = how_to_report_unresolved_symbols;
880 }
881 else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
882 {
883 link_info.unresolved_syms_in_objects
884 = how_to_report_unresolved_symbols;
885 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
886 }
887 else
888 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg);
889 break;
890 case OPTION_WARN_UNRESOLVED_SYMBOLS:
891 how_to_report_unresolved_symbols = RM_GENERATE_WARNING;
892 if (link_info.unresolved_syms_in_objects == RM_GENERATE_ERROR)
893 link_info.unresolved_syms_in_objects = RM_GENERATE_WARNING;
894 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
895 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_WARNING;
896 break;
897
898 case OPTION_ERROR_UNRESOLVED_SYMBOLS:
899 how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
900 if (link_info.unresolved_syms_in_objects == RM_GENERATE_WARNING)
901 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
902 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_WARNING)
903 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
904 break;
905 case OPTION_ALLOW_MULTIPLE_DEFINITION:
906 link_info.allow_multiple_definition = TRUE;
907 break;
908 case OPTION_NO_UNDEFINED_VERSION:
909 link_info.allow_undefined_version = FALSE;
910 break;
911 case OPTION_DEFAULT_SYMVER:
912 link_info.create_default_symver = TRUE;
913 break;
914 case OPTION_DEFAULT_IMPORTED_SYMVER:
915 link_info.default_imported_symver = TRUE;
916 break;
917 case OPTION_NO_WARN_MISMATCH:
918 command_line.warn_mismatch = FALSE;
919 break;
920 case OPTION_NO_WARN_SEARCH_MISMATCH:
921 command_line.warn_search_mismatch = FALSE;
922 break;
923 case OPTION_NOINHIBIT_EXEC:
924 force_make_executable = TRUE;
925 break;
926 case OPTION_NOSTDLIB:
927 config.only_cmd_line_lib_dirs = TRUE;
928 break;
929 case OPTION_NO_WHOLE_ARCHIVE:
930 input_flags.whole_archive = FALSE;
931 break;
932 case 'O':
933 /* FIXME "-O<non-digits> <value>" used to set the address of
934 section <non-digits>. Was this for compatibility with
935 something, or can we create a new option to do that
936 (with a syntax similar to -defsym)?
937 getopt can't handle two args to an option without kludges. */
938
939 /* Enable optimizations of output files. */
940 link_info.optimize = strtoul (optarg, NULL, 0) ? TRUE : FALSE;
941 break;
942 case 'o':
943 lang_add_output (optarg, 0);
944 break;
945 case OPTION_OFORMAT:
946 lang_add_output_format (optarg, NULL, NULL, 0);
947 break;
948 case OPTION_PRINT_OUTPUT_FORMAT:
949 command_line.print_output_format = TRUE;
950 break;
951 #ifdef ENABLE_PLUGINS
952 case OPTION_PLUGIN:
953 if (plugin_opt_plugin (optarg))
954 einfo (_("%P%F: %s: error loading plugin\n"),
955 plugin_error_plugin ());
956 break;
957 case OPTION_PLUGIN_OPT:
958 if (plugin_opt_plugin_arg (optarg))
959 einfo(_("%P%F: bad -plugin-opt option\n"));
960 break;
961 #endif /* ENABLE_PLUGINS */
962 case 'q':
963 link_info.emitrelocations = TRUE;
964 break;
965 case 'i':
966 case 'r':
967 if (optind == last_optind)
968 /* This can happen if the user put "-rpath,a" on the command
969 line. (Or something similar. The comma is important).
970 Getopt becomes confused and thinks that this is a -r option
971 but it cannot parse the text after the -r so it refuses to
972 increment the optind counter. Detect this case and issue
973 an error message here. We cannot just make this a warning,
974 increment optind, and continue because getopt is too confused
975 and will seg-fault the next time around. */
976 einfo(_("%P%F: bad -rpath option\n"));
977
978 link_info.relocatable = TRUE;
979 config.build_constructors = FALSE;
980 config.magic_demand_paged = FALSE;
981 config.text_read_only = FALSE;
982 input_flags.dynamic = FALSE;
983 break;
984 case 'R':
985 /* The GNU linker traditionally uses -R to mean to include
986 only the symbols from a file. The Solaris linker uses -R
987 to set the path used by the runtime linker to find
988 libraries. This is the GNU linker -rpath argument. We
989 try to support both simultaneously by checking the file
990 named. If it is a directory, rather than a regular file,
991 we assume -rpath was meant. */
992 {
993 struct stat s;
994
995 if (stat (optarg, &s) >= 0
996 && ! S_ISDIR (s.st_mode))
997 {
998 lang_add_input_file (optarg,
999 lang_input_file_is_symbols_only_enum,
1000 NULL);
1001 break;
1002 }
1003 }
1004 /* Fall through. */
1005 case OPTION_RPATH:
1006 if (command_line.rpath == NULL)
1007 command_line.rpath = xstrdup (optarg);
1008 else
1009 {
1010 size_t rpath_len = strlen (command_line.rpath);
1011 size_t optarg_len = strlen (optarg);
1012 char *buf;
1013 char *cp = command_line.rpath;
1014
1015 /* First see whether OPTARG is already in the path. */
1016 do
1017 {
1018 if (strncmp (optarg, cp, optarg_len) == 0
1019 && (cp[optarg_len] == 0
1020 || cp[optarg_len] == config.rpath_separator))
1021 /* We found it. */
1022 break;
1023
1024 /* Not yet found. */
1025 cp = strchr (cp, config.rpath_separator);
1026 if (cp != NULL)
1027 ++cp;
1028 }
1029 while (cp != NULL);
1030
1031 if (cp == NULL)
1032 {
1033 buf = (char *) xmalloc (rpath_len + optarg_len + 2);
1034 sprintf (buf, "%s%c%s", command_line.rpath,
1035 config.rpath_separator, optarg);
1036 free (command_line.rpath);
1037 command_line.rpath = buf;
1038 }
1039 }
1040 break;
1041 case OPTION_RPATH_LINK:
1042 if (command_line.rpath_link == NULL)
1043 command_line.rpath_link = xstrdup (optarg);
1044 else
1045 {
1046 char *buf;
1047
1048 buf = (char *) xmalloc (strlen (command_line.rpath_link)
1049 + strlen (optarg)
1050 + 2);
1051 sprintf (buf, "%s%c%s", command_line.rpath_link,
1052 config.rpath_separator, optarg);
1053 free (command_line.rpath_link);
1054 command_line.rpath_link = buf;
1055 }
1056 break;
1057 case OPTION_NO_RELAX:
1058 DISABLE_RELAXATION;
1059 break;
1060 case OPTION_RELAX:
1061 ENABLE_RELAXATION;
1062 break;
1063 case OPTION_RETAIN_SYMBOLS_FILE:
1064 add_keepsyms_file (optarg);
1065 break;
1066 case 'S':
1067 link_info.strip = strip_debugger;
1068 break;
1069 case 's':
1070 link_info.strip = strip_all;
1071 break;
1072 case OPTION_STRIP_DISCARDED:
1073 link_info.strip_discarded = TRUE;
1074 break;
1075 case OPTION_NO_STRIP_DISCARDED:
1076 link_info.strip_discarded = FALSE;
1077 break;
1078 case OPTION_SHARED:
1079 if (config.has_shared)
1080 {
1081 link_info.shared = TRUE;
1082 /* When creating a shared library, the default
1083 behaviour is to ignore any unresolved references. */
1084 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1085 link_info.unresolved_syms_in_objects = RM_IGNORE;
1086 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1087 link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1088 }
1089 else
1090 einfo (_("%P%F: -shared not supported\n"));
1091 break;
1092 case OPTION_PIE:
1093 if (config.has_shared)
1094 {
1095 link_info.shared = TRUE;
1096 link_info.pie = TRUE;
1097 }
1098 else
1099 einfo (_("%P%F: -pie not supported\n"));
1100 break;
1101 case 'h': /* Used on Solaris. */
1102 case OPTION_SONAME:
1103 command_line.soname = optarg;
1104 break;
1105 case OPTION_SORT_COMMON:
1106 if (optarg == NULL
1107 || strcmp (optarg, N_("descending")) == 0)
1108 config.sort_common = sort_descending;
1109 else if (strcmp (optarg, N_("ascending")) == 0)
1110 config.sort_common = sort_ascending;
1111 else
1112 einfo (_("%P%F: invalid common section sorting option: %s\n"),
1113 optarg);
1114 break;
1115 case OPTION_SORT_SECTION:
1116 if (strcmp (optarg, N_("name")) == 0)
1117 sort_section = by_name;
1118 else if (strcmp (optarg, N_("alignment")) == 0)
1119 sort_section = by_alignment;
1120 else
1121 einfo (_("%P%F: invalid section sorting option: %s\n"),
1122 optarg);
1123 break;
1124 case OPTION_STATS:
1125 config.stats = TRUE;
1126 break;
1127 case OPTION_SYMBOLIC:
1128 command_line.symbolic = symbolic;
1129 break;
1130 case OPTION_SYMBOLIC_FUNCTIONS:
1131 command_line.symbolic = symbolic_functions;
1132 break;
1133 case 't':
1134 trace_files = TRUE;
1135 break;
1136 case 'T':
1137 previous_script_handle = saved_script_handle;
1138 ldfile_open_command_file (optarg);
1139 parser_input = input_script;
1140 yyparse ();
1141 previous_script_handle = NULL;
1142 break;
1143 case OPTION_DEFAULT_SCRIPT:
1144 command_line.default_script = optarg;
1145 break;
1146 case OPTION_SECTION_START:
1147 {
1148 char *optarg2;
1149 char *sec_name;
1150 int len;
1151
1152 /* Check for <something>=<somthing>... */
1153 optarg2 = strchr (optarg, '=');
1154 if (optarg2 == NULL)
1155 einfo (_("%P%F: invalid argument to option"
1156 " \"--section-start\"\n"));
1157
1158 optarg2++;
1159
1160 /* So far so good. Are all the args present? */
1161 if ((*optarg == '\0') || (*optarg2 == '\0'))
1162 einfo (_("%P%F: missing argument(s) to option"
1163 " \"--section-start\"\n"));
1164
1165 /* We must copy the section name as set_section_start
1166 doesn't do it for us. */
1167 len = optarg2 - optarg;
1168 sec_name = (char *) xmalloc (len);
1169 memcpy (sec_name, optarg, len - 1);
1170 sec_name[len - 1] = 0;
1171
1172 /* Then set it... */
1173 set_section_start (sec_name, optarg2);
1174 }
1175 break;
1176 case OPTION_TARGET_HELP:
1177 /* Mention any target specific options. */
1178 ldemul_list_emulation_options (stdout);
1179 exit (0);
1180 case OPTION_TBSS:
1181 set_segment_start (".bss", optarg);
1182 break;
1183 case OPTION_TDATA:
1184 set_segment_start (".data", optarg);
1185 break;
1186 case OPTION_TTEXT:
1187 set_segment_start (".text", optarg);
1188 break;
1189 case OPTION_TTEXT_SEGMENT:
1190 set_segment_start (".text-segment", optarg);
1191 break;
1192 case OPTION_TRADITIONAL_FORMAT:
1193 link_info.traditional_format = TRUE;
1194 break;
1195 case OPTION_TASK_LINK:
1196 link_info.task_link = TRUE;
1197 /* Fall through - do an implied -r option. */
1198 case OPTION_UR:
1199 link_info.relocatable = TRUE;
1200 config.build_constructors = TRUE;
1201 config.magic_demand_paged = FALSE;
1202 config.text_read_only = FALSE;
1203 input_flags.dynamic = FALSE;
1204 break;
1205 case 'u':
1206 ldlang_add_undef (optarg, TRUE);
1207 break;
1208 case OPTION_UNIQUE:
1209 if (optarg != NULL)
1210 lang_add_unique (optarg);
1211 else
1212 config.unique_orphan_sections = TRUE;
1213 break;
1214 case OPTION_VERBOSE:
1215 ldversion (1);
1216 version_printed = TRUE;
1217 verbose = TRUE;
1218 overflow_cutoff_limit = -2;
1219 if (optarg != NULL)
1220 {
1221 char *end;
1222 int level ATTRIBUTE_UNUSED = strtoul (optarg, &end, 0);
1223 if (*end)
1224 einfo (_("%P%F: invalid number `%s'\n"), optarg);
1225 #ifdef ENABLE_PLUGINS
1226 report_plugin_symbols = level > 1;
1227 #endif /* ENABLE_PLUGINS */
1228 }
1229 break;
1230 case 'v':
1231 ldversion (0);
1232 version_printed = TRUE;
1233 break;
1234 case 'V':
1235 ldversion (1);
1236 version_printed = TRUE;
1237 break;
1238 case OPTION_VERSION:
1239 ldversion (2);
1240 xexit (0);
1241 break;
1242 case OPTION_VERSION_SCRIPT:
1243 /* This option indicates a small script that only specifies
1244 version information. Read it, but don't assume that
1245 we've seen a linker script. */
1246 {
1247 FILE *hold_script_handle;
1248
1249 hold_script_handle = saved_script_handle;
1250 ldfile_open_command_file (optarg);
1251 saved_script_handle = hold_script_handle;
1252 parser_input = input_version_script;
1253 yyparse ();
1254 }
1255 break;
1256 case OPTION_VERSION_EXPORTS_SECTION:
1257 /* This option records a version symbol to be applied to the
1258 symbols listed for export to be found in the object files
1259 .exports sections. */
1260 command_line.version_exports_section = optarg;
1261 break;
1262 case OPTION_DYNAMIC_LIST_DATA:
1263 command_line.dynamic_list = dynamic_list_data;
1264 if (command_line.symbolic == symbolic)
1265 command_line.symbolic = symbolic_unset;
1266 break;
1267 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
1268 lang_append_dynamic_list_cpp_typeinfo ();
1269 if (command_line.dynamic_list != dynamic_list_data)
1270 command_line.dynamic_list = dynamic_list;
1271 if (command_line.symbolic == symbolic)
1272 command_line.symbolic = symbolic_unset;
1273 break;
1274 case OPTION_DYNAMIC_LIST_CPP_NEW:
1275 lang_append_dynamic_list_cpp_new ();
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:
1282 /* This option indicates a small script that only specifies
1283 a dynamic list. Read it, but don't assume that we've
1284 seen a linker script. */
1285 {
1286 FILE *hold_script_handle;
1287
1288 hold_script_handle = saved_script_handle;
1289 ldfile_open_command_file (optarg);
1290 saved_script_handle = hold_script_handle;
1291 parser_input = input_dynamic_list;
1292 yyparse ();
1293 }
1294 if (command_line.dynamic_list != dynamic_list_data)
1295 command_line.dynamic_list = dynamic_list;
1296 if (command_line.symbolic == symbolic)
1297 command_line.symbolic = symbolic_unset;
1298 break;
1299 case OPTION_WARN_COMMON:
1300 config.warn_common = TRUE;
1301 break;
1302 case OPTION_WARN_CONSTRUCTORS:
1303 config.warn_constructors = TRUE;
1304 break;
1305 case OPTION_WARN_FATAL:
1306 config.fatal_warnings = TRUE;
1307 break;
1308 case OPTION_NO_WARN_FATAL:
1309 config.fatal_warnings = FALSE;
1310 break;
1311 case OPTION_WARN_MULTIPLE_GP:
1312 config.warn_multiple_gp = TRUE;
1313 break;
1314 case OPTION_WARN_ONCE:
1315 config.warn_once = TRUE;
1316 break;
1317 case OPTION_WARN_SECTION_ALIGN:
1318 config.warn_section_align = TRUE;
1319 break;
1320 case OPTION_WARN_SHARED_TEXTREL:
1321 link_info.warn_shared_textrel = TRUE;
1322 break;
1323 case OPTION_WARN_ALTERNATE_EM:
1324 link_info.warn_alternate_em = TRUE;
1325 break;
1326 case OPTION_WHOLE_ARCHIVE:
1327 input_flags.whole_archive = TRUE;
1328 break;
1329 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC:
1330 input_flags.add_DT_NEEDED_for_dynamic = TRUE;
1331 break;
1332 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC:
1333 input_flags.add_DT_NEEDED_for_dynamic = FALSE;
1334 break;
1335 case OPTION_ADD_DT_NEEDED_FOR_REGULAR:
1336 input_flags.add_DT_NEEDED_for_regular = TRUE;
1337 break;
1338 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR:
1339 input_flags.add_DT_NEEDED_for_regular = FALSE;
1340 break;
1341 case OPTION_WRAP:
1342 add_wrap (optarg);
1343 break;
1344 case OPTION_DISCARD_NONE:
1345 link_info.discard = discard_none;
1346 break;
1347 case 'X':
1348 link_info.discard = discard_l;
1349 break;
1350 case 'x':
1351 link_info.discard = discard_all;
1352 break;
1353 case 'Y':
1354 if (CONST_STRNEQ (optarg, "P,"))
1355 optarg += 2;
1356 if (default_dirlist != NULL)
1357 free (default_dirlist);
1358 default_dirlist = xstrdup (optarg);
1359 break;
1360 case 'y':
1361 add_ysym (optarg);
1362 break;
1363 case OPTION_SPARE_DYNAMIC_TAGS:
1364 link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0);
1365 break;
1366 case OPTION_SPLIT_BY_RELOC:
1367 if (optarg != NULL)
1368 config.split_by_reloc = strtoul (optarg, NULL, 0);
1369 else
1370 config.split_by_reloc = 32768;
1371 break;
1372 case OPTION_SPLIT_BY_FILE:
1373 if (optarg != NULL)
1374 config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
1375 else
1376 config.split_by_file = 1;
1377 break;
1378 case OPTION_CHECK_SECTIONS:
1379 command_line.check_section_addresses = 1;
1380 break;
1381 case OPTION_NO_CHECK_SECTIONS:
1382 command_line.check_section_addresses = 0;
1383 break;
1384 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
1385 command_line.accept_unknown_input_arch = TRUE;
1386 break;
1387 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
1388 command_line.accept_unknown_input_arch = FALSE;
1389 break;
1390 case '(':
1391 lang_enter_group ();
1392 ingroup++;
1393 break;
1394 case ')':
1395 if (! ingroup)
1396 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1397
1398 lang_leave_group ();
1399 ingroup--;
1400 break;
1401
1402 case OPTION_INIT:
1403 link_info.init_function = optarg;
1404 break;
1405
1406 case OPTION_FINI:
1407 link_info.fini_function = optarg;
1408 break;
1409
1410 case OPTION_REDUCE_MEMORY_OVERHEADS:
1411 link_info.reduce_memory_overheads = TRUE;
1412 if (config.hash_table_size == 0)
1413 config.hash_table_size = 1021;
1414 break;
1415
1416 case OPTION_HASH_SIZE:
1417 {
1418 bfd_size_type new_size;
1419
1420 new_size = strtoul (optarg, NULL, 0);
1421 if (new_size)
1422 config.hash_table_size = new_size;
1423 else
1424 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1425 }
1426 break;
1427 }
1428 }
1429
1430 while (ingroup)
1431 {
1432 lang_leave_group ();
1433 ingroup--;
1434 }
1435
1436 if (default_dirlist != NULL)
1437 {
1438 set_default_dirlist (default_dirlist);
1439 free (default_dirlist);
1440 }
1441
1442 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1443 /* FIXME: Should we allow emulations a chance to set this ? */
1444 link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
1445
1446 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1447 /* FIXME: Should we allow emulations a chance to set this ? */
1448 link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
1449
1450 if (link_info.relocatable)
1451 {
1452 if (command_line.check_section_addresses < 0)
1453 command_line.check_section_addresses = 0;
1454 if (link_info.shared)
1455 einfo (_("%P%F: -r and -shared may not be used together\n"));
1456 }
1457
1458 /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data,
1459 --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and
1460 --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are
1461 for shared libraries. -Bsymbolic overrides all others and vice
1462 versa. */
1463 switch (command_line.symbolic)
1464 {
1465 case symbolic_unset:
1466 break;
1467 case symbolic:
1468 /* -Bsymbolic is for shared library only. */
1469 if (link_info.shared)
1470 {
1471 link_info.symbolic = TRUE;
1472 /* Should we free the unused memory? */
1473 link_info.dynamic_list = NULL;
1474 command_line.dynamic_list = dynamic_list_unset;
1475 }
1476 break;
1477 case symbolic_functions:
1478 /* -Bsymbolic-functions is for shared library only. */
1479 if (link_info.shared)
1480 command_line.dynamic_list = dynamic_list_data;
1481 break;
1482 }
1483
1484 switch (command_line.dynamic_list)
1485 {
1486 case dynamic_list_unset:
1487 break;
1488 case dynamic_list_data:
1489 link_info.dynamic_data = TRUE;
1490 case dynamic_list:
1491 link_info.dynamic = TRUE;
1492 break;
1493 }
1494
1495 if (! link_info.shared)
1496 {
1497 if (command_line.filter_shlib)
1498 einfo (_("%P%F: -F may not be used without -shared\n"));
1499 if (command_line.auxiliary_filters)
1500 einfo (_("%P%F: -f may not be used without -shared\n"));
1501 }
1502
1503 if (! link_info.shared || link_info.pie)
1504 link_info.executable = TRUE;
1505
1506 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
1507 don't see how else this can be handled, since in this case we
1508 must preserve all externally visible symbols. */
1509 if (link_info.relocatable && link_info.strip == strip_all)
1510 {
1511 link_info.strip = strip_debugger;
1512 if (link_info.discard == discard_sec_merge)
1513 link_info.discard = discard_all;
1514 }
1515 }
1516
1517 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1518 library search path. */
1519
1520 static void
1521 set_default_dirlist (char *dirlist_ptr)
1522 {
1523 char *p;
1524
1525 while (1)
1526 {
1527 p = strchr (dirlist_ptr, PATH_SEPARATOR);
1528 if (p != NULL)
1529 *p = '\0';
1530 if (*dirlist_ptr != '\0')
1531 ldfile_add_library_path (dirlist_ptr, TRUE);
1532 if (p == NULL)
1533 break;
1534 dirlist_ptr = p + 1;
1535 }
1536 }
1537
1538 static void
1539 set_section_start (char *sect, char *valstr)
1540 {
1541 const char *end;
1542 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1543 if (*end)
1544 einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
1545 lang_section_start (sect, exp_intop (val), NULL);
1546 }
1547
1548 static void
1549 set_segment_start (const char *section, char *valstr)
1550 {
1551 const char *name;
1552 const char *end;
1553 segment_type *seg;
1554
1555 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1556 if (*end)
1557 einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
1558 /* If we already have an entry for this segment, update the existing
1559 value. */
1560 name = section + 1;
1561 for (seg = segments; seg; seg = seg->next)
1562 if (strcmp (seg->name, name) == 0)
1563 {
1564 seg->value = val;
1565 return;
1566 }
1567 /* There was no existing value so we must create a new segment
1568 entry. */
1569 seg = (segment_type *) stat_alloc (sizeof (*seg));
1570 seg->name = name;
1571 seg->value = val;
1572 seg->used = FALSE;
1573 /* Add it to the linked list of segments. */
1574 seg->next = segments;
1575 segments = seg;
1576 /* Historically, -Ttext and friends set the base address of a
1577 particular section. For backwards compatibility, we still do
1578 that. If a SEGMENT_START directive is seen, the section address
1579 assignment will be disabled. */
1580 lang_section_start (section, exp_intop (val), seg);
1581 }
1582
1583 \f
1584 /* Print help messages for the options. */
1585
1586 static void
1587 help (void)
1588 {
1589 unsigned i;
1590 const char **targets, **pp;
1591 int len;
1592
1593 printf (_("Usage: %s [options] file...\n"), program_name);
1594
1595 printf (_("Options:\n"));
1596 for (i = 0; i < OPTION_COUNT; i++)
1597 {
1598 if (ld_options[i].doc != NULL)
1599 {
1600 bfd_boolean comma;
1601 unsigned j;
1602
1603 printf (" ");
1604
1605 comma = FALSE;
1606 len = 2;
1607
1608 j = i;
1609 do
1610 {
1611 if (ld_options[j].shortopt != '\0'
1612 && ld_options[j].control != NO_HELP)
1613 {
1614 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
1615 len += (comma ? 2 : 0) + 2;
1616 if (ld_options[j].arg != NULL)
1617 {
1618 if (ld_options[j].opt.has_arg != optional_argument)
1619 {
1620 printf (" ");
1621 ++len;
1622 }
1623 printf ("%s", _(ld_options[j].arg));
1624 len += strlen (_(ld_options[j].arg));
1625 }
1626 comma = TRUE;
1627 }
1628 ++j;
1629 }
1630 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1631
1632 j = i;
1633 do
1634 {
1635 if (ld_options[j].opt.name != NULL
1636 && ld_options[j].control != NO_HELP)
1637 {
1638 int two_dashes =
1639 (ld_options[j].control == TWO_DASHES
1640 || ld_options[j].control == EXACTLY_TWO_DASHES);
1641
1642 printf ("%s-%s%s",
1643 comma ? ", " : "",
1644 two_dashes ? "-" : "",
1645 ld_options[j].opt.name);
1646 len += ((comma ? 2 : 0)
1647 + 1
1648 + (two_dashes ? 1 : 0)
1649 + strlen (ld_options[j].opt.name));
1650 if (ld_options[j].arg != NULL)
1651 {
1652 printf (" %s", _(ld_options[j].arg));
1653 len += 1 + strlen (_(ld_options[j].arg));
1654 }
1655 comma = TRUE;
1656 }
1657 ++j;
1658 }
1659 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1660
1661 if (len >= 30)
1662 {
1663 printf ("\n");
1664 len = 0;
1665 }
1666
1667 for (; len < 30; len++)
1668 putchar (' ');
1669
1670 printf ("%s\n", _(ld_options[i].doc));
1671 }
1672 }
1673 printf (_(" @FILE"));
1674 for (len = strlen (" @FILE"); len < 30; len++)
1675 putchar (' ');
1676 printf (_("Read options from FILE\n"));
1677
1678 /* Note: Various tools (such as libtool) depend upon the
1679 format of the listings below - do not change them. */
1680 /* xgettext:c-format */
1681 printf (_("%s: supported targets:"), program_name);
1682 targets = bfd_target_list ();
1683 for (pp = targets; *pp != NULL; pp++)
1684 printf (" %s", *pp);
1685 free (targets);
1686 printf ("\n");
1687
1688 /* xgettext:c-format */
1689 printf (_("%s: supported emulations: "), program_name);
1690 ldemul_list_emulations (stdout);
1691 printf ("\n");
1692
1693 /* xgettext:c-format */
1694 printf (_("%s: emulation specific options:\n"), program_name);
1695 ldemul_list_emulation_options (stdout);
1696 printf ("\n");
1697
1698 if (REPORT_BUGS_TO[0])
1699 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);
1700 }