Add optional style argument to --demangle switch.
[deliverable/binutils-gdb.git] / ld / lexsup.c
1 /* Parse options for the GNU linker.
2 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000
3 Free Software Foundation, Inc.
4
5 This file is part of GLD, the Gnu Linker.
6
7 GLD is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GLD is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GLD; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "libiberty.h"
25 #include <stdio.h>
26 #include <string.h>
27 #include <ctype.h>
28 #include "getopt.h"
29 #include "bfdlink.h"
30 #include "ld.h"
31 #include "ldmain.h"
32 #include "ldmisc.h"
33 #include "ldexp.h"
34 #include "ldlang.h"
35 #include "ldgram.h"
36 #include "ldlex.h"
37 #include "ldfile.h"
38 #include "ldver.h"
39 #include "ldemul.h"
40 #include "demangle.h"
41
42 #ifndef PATH_SEPARATOR
43 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
44 #define PATH_SEPARATOR ';'
45 #else
46 #define PATH_SEPARATOR ':'
47 #endif
48 #endif
49
50 /* Somewhere above, sys/stat.h got included . . . . */
51 #if !defined(S_ISDIR) && defined(S_IFDIR)
52 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
53 #endif
54
55 /* Omit args to avoid the possibility of clashing with a system header
56 that might disagree about consts. */
57 unsigned long strtoul ();
58
59 static int is_num PARAMS ((const char *, int, int, int));
60 static void set_default_dirlist PARAMS ((char *dirlist_ptr));
61 static void set_section_start PARAMS ((char *sect, char *valstr));
62 static void help PARAMS ((void));
63
64 /* Non-zero if we are processing a --defsym from the command line. */
65 int parsing_defsym = 0;
66
67 /* Codes used for the long options with no short synonyms. 150 isn't
68 special; it's just an arbitrary non-ASCII char value. */
69
70 #define OPTION_ASSERT 150
71 #define OPTION_CALL_SHARED (OPTION_ASSERT + 1)
72 #define OPTION_CREF (OPTION_CALL_SHARED + 1)
73 #define OPTION_DEFSYM (OPTION_CREF + 1)
74 #define OPTION_DEMANGLE (OPTION_DEFSYM + 1)
75 #define OPTION_DYNAMIC_LINKER (OPTION_DEMANGLE + 1)
76 #define OPTION_EB (OPTION_DYNAMIC_LINKER + 1)
77 #define OPTION_EL (OPTION_EB + 1)
78 #define OPTION_EMBEDDED_RELOCS (OPTION_EL + 1)
79 #define OPTION_EXPORT_DYNAMIC (OPTION_EMBEDDED_RELOCS + 1)
80 #define OPTION_HELP (OPTION_EXPORT_DYNAMIC + 1)
81 #define OPTION_IGNORE (OPTION_HELP + 1)
82 #define OPTION_MAP (OPTION_IGNORE + 1)
83 #define OPTION_NO_DEMANGLE (OPTION_MAP + 1)
84 #define OPTION_NO_KEEP_MEMORY (OPTION_NO_DEMANGLE + 1)
85 #define OPTION_NO_WARN_MISMATCH (OPTION_NO_KEEP_MEMORY + 1)
86 #define OPTION_NOINHIBIT_EXEC (OPTION_NO_WARN_MISMATCH + 1)
87 #define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1)
88 #define OPTION_NO_WHOLE_ARCHIVE (OPTION_NON_SHARED + 1)
89 #define OPTION_OFORMAT (OPTION_NO_WHOLE_ARCHIVE + 1)
90 #define OPTION_RELAX (OPTION_OFORMAT + 1)
91 #define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1)
92 #define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1)
93 #define OPTION_RPATH_LINK (OPTION_RPATH + 1)
94 #define OPTION_SHARED (OPTION_RPATH_LINK + 1)
95 #define OPTION_SONAME (OPTION_SHARED + 1)
96 #define OPTION_SORT_COMMON (OPTION_SONAME + 1)
97 #define OPTION_STATS (OPTION_SORT_COMMON + 1)
98 #define OPTION_SYMBOLIC (OPTION_STATS + 1)
99 #define OPTION_TASK_LINK (OPTION_SYMBOLIC + 1)
100 #define OPTION_TBSS (OPTION_TASK_LINK + 1)
101 #define OPTION_TDATA (OPTION_TBSS + 1)
102 #define OPTION_TTEXT (OPTION_TDATA + 1)
103 #define OPTION_TRADITIONAL_FORMAT (OPTION_TTEXT + 1)
104 #define OPTION_UR (OPTION_TRADITIONAL_FORMAT + 1)
105 #define OPTION_VERBOSE (OPTION_UR + 1)
106 #define OPTION_VERSION (OPTION_VERBOSE + 1)
107 #define OPTION_VERSION_SCRIPT (OPTION_VERSION + 1)
108 #define OPTION_VERSION_EXPORTS_SECTION (OPTION_VERSION_SCRIPT + 1)
109 #define OPTION_WARN_COMMON (OPTION_VERSION_EXPORTS_SECTION + 1)
110 #define OPTION_WARN_CONSTRUCTORS (OPTION_WARN_COMMON + 1)
111 #define OPTION_WARN_MULTIPLE_GP (OPTION_WARN_CONSTRUCTORS + 1)
112 #define OPTION_WARN_ONCE (OPTION_WARN_MULTIPLE_GP + 1)
113 #define OPTION_WARN_SECTION_ALIGN (OPTION_WARN_ONCE + 1)
114 #define OPTION_SPLIT_BY_RELOC (OPTION_WARN_SECTION_ALIGN + 1)
115 #define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1)
116 #define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
117 #define OPTION_WRAP (OPTION_WHOLE_ARCHIVE + 1)
118 #define OPTION_FORCE_EXE_SUFFIX (OPTION_WRAP + 1)
119 #define OPTION_GC_SECTIONS (OPTION_FORCE_EXE_SUFFIX + 1)
120 #define OPTION_NO_GC_SECTIONS (OPTION_GC_SECTIONS + 1)
121 #define OPTION_CHECK_SECTIONS (OPTION_NO_GC_SECTIONS + 1)
122 #define OPTION_NO_CHECK_SECTIONS (OPTION_CHECK_SECTIONS + 1)
123 #define OPTION_MPC860C0 (OPTION_NO_CHECK_SECTIONS + 1)
124 #define OPTION_NO_UNDEFINED (OPTION_MPC860C0 + 1)
125 #define OPTION_INIT (OPTION_NO_UNDEFINED + 1)
126 #define OPTION_FINI (OPTION_INIT + 1)
127 #define OPTION_SECTION_START (OPTION_FINI + 1)
128
129 /* The long options. This structure is used for both the option
130 parsing and the help text. */
131
132 struct ld_option
133 {
134 /* The long option information. */
135 struct option opt;
136 /* The short option with the same meaning ('\0' if none). */
137 char shortopt;
138 /* The name of the argument (NULL if none). */
139 const char *arg;
140 /* The documentation string. If this is NULL, this is a synonym for
141 the previous option. */
142 const char *doc;
143 enum
144 {
145 /* Use one dash before long option name. */
146 ONE_DASH,
147 /* Use two dashes before long option name. */
148 TWO_DASHES,
149 /* Don't mention this option in --help output. */
150 NO_HELP
151 } control;
152 };
153
154 static const struct ld_option ld_options[] =
155 {
156 { {NULL, required_argument, NULL, '\0'},
157 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
158 ONE_DASH },
159 { {"architecture", required_argument, NULL, 'A'},
160 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES },
161 { {"format", required_argument, NULL, 'b'},
162 'b', N_("TARGET"), N_("Specify target for following input files"), TWO_DASHES },
163 { {"mri-script", required_argument, NULL, 'c'},
164 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES },
165 { {"dc", no_argument, NULL, 'd'},
166 'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
167 { {"dp", no_argument, NULL, 'd'},
168 '\0', NULL, NULL, ONE_DASH },
169 { {"entry", required_argument, NULL, 'e'},
170 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
171 { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
172 'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
173 { {"EB", no_argument, NULL, OPTION_EB},
174 '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
175 { {"EL", no_argument, NULL, OPTION_EL},
176 '\0', NULL, N_("Link little-endian objects"), ONE_DASH },
177 { {"auxiliary", required_argument, NULL, 'f'},
178 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
179 TWO_DASHES },
180 { {"filter", required_argument, NULL, 'F'},
181 'F', N_("SHLIB"), N_("Filter for shared object symbol table"), TWO_DASHES },
182 { {NULL, no_argument, NULL, '\0'},
183 'g', NULL, N_("Ignored"), ONE_DASH },
184 { {"gpsize", required_argument, NULL, 'G'},
185 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
186 TWO_DASHES },
187 { {"soname", required_argument, NULL, OPTION_SONAME},
188 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
189 { {"library", required_argument, NULL, 'l'},
190 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
191 { {"library-path", required_argument, NULL, 'L'},
192 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"), TWO_DASHES },
193 { {NULL, required_argument, NULL, '\0'},
194 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH },
195 { {"print-map", no_argument, NULL, 'M'},
196 'M', NULL, N_("Print map file on standard output"), TWO_DASHES },
197 { {"nmagic", no_argument, NULL, 'n'},
198 'n', NULL, N_("Do not page align data"), TWO_DASHES },
199 { {"omagic", no_argument, NULL, 'N'},
200 'N', NULL, N_("Do not page align data, do not make text readonly"),
201 TWO_DASHES },
202 { {"output", required_argument, NULL, 'o'},
203 'o', N_("FILE"), N_("Set output file name"), TWO_DASHES },
204 { {NULL, required_argument, NULL, '\0'},
205 'O', NULL, N_("Optimize output file"), ONE_DASH },
206 { {"Qy", no_argument, NULL, OPTION_IGNORE},
207 '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
208 { {"emit-relocs", no_argument, NULL, 'q'},
209 'q', NULL, "Generate relocations in final output", TWO_DASHES },
210 { {"relocateable", no_argument, NULL, 'r'},
211 'r', NULL, N_("Generate relocateable output"), TWO_DASHES },
212 { {NULL, no_argument, NULL, '\0'},
213 'i', NULL, NULL, ONE_DASH },
214 { {"just-symbols", required_argument, NULL, 'R'},
215 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
216 TWO_DASHES },
217 { {"strip-all", no_argument, NULL, 's'},
218 's', NULL, N_("Strip all symbols"), TWO_DASHES },
219 { {"strip-debug", no_argument, NULL, 'S'},
220 'S', NULL, N_("Strip debugging symbols"), TWO_DASHES },
221 { {"trace", no_argument, NULL, 't'},
222 't', NULL, N_("Trace file opens"), TWO_DASHES },
223 { {"script", required_argument, NULL, 'T'},
224 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
225 { {"undefined", required_argument, NULL, 'u'},
226 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), TWO_DASHES },
227 { {"Ur", no_argument, NULL, OPTION_UR},
228 '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
229 { {"version", no_argument, NULL, OPTION_VERSION},
230 'v', NULL, N_("Print version information"), TWO_DASHES },
231 { {NULL, no_argument, NULL, '\0'},
232 'V', NULL, N_("Print version and emulation information"), ONE_DASH },
233 { {"discard-all", no_argument, NULL, 'x'},
234 'x', NULL, N_("Discard all local symbols"), TWO_DASHES },
235 { {"discard-locals", no_argument, NULL, 'X'},
236 'X', NULL, N_("Discard temporary local symbols"), TWO_DASHES },
237 { {"trace-symbol", required_argument, NULL, 'y'},
238 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
239 { {NULL, required_argument, NULL, '\0'},
240 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), ONE_DASH },
241 #if 0
242 { {NULL, required_argument, NULL, '\0'},
243 'z', N_("KEYWORD"), N_("Ignored for Solaris compatibility"), ONE_DASH },
244 #endif
245 { {"start-group", no_argument, NULL, '('},
246 '(', NULL, N_("Start a group"), TWO_DASHES },
247 { {"end-group", no_argument, NULL, ')'},
248 ')', NULL, N_("End a group"), TWO_DASHES },
249 { {"assert", required_argument, NULL, OPTION_ASSERT},
250 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
251 { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
252 '\0', NULL, N_("Link against shared libraries"), ONE_DASH },
253 { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
254 '\0', NULL, NULL, ONE_DASH },
255 { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
256 '\0', NULL, NULL, ONE_DASH },
257 { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
258 '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
259 { {"dn", no_argument, NULL, OPTION_NON_SHARED},
260 '\0', NULL, NULL, ONE_DASH },
261 { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
262 '\0', NULL, NULL, ONE_DASH },
263 { {"static", no_argument, NULL, OPTION_NON_SHARED},
264 '\0', NULL, NULL, ONE_DASH },
265 { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
266 '\0', NULL, N_("Bind global references locally"), ONE_DASH },
267 { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
268 '\0', NULL, N_("Check section addresses for overlaps (default)"), TWO_DASHES },
269 { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
270 '\0', NULL, N_("Do not check section addresses for overlaps"),
271 TWO_DASHES },
272 { {"cref", no_argument, NULL, OPTION_CREF},
273 '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
274 { {"defsym", required_argument, NULL, OPTION_DEFSYM},
275 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
276 { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
277 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), TWO_DASHES },
278 { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
279 '\0', N_("PROGRAM"), N_("Set the dynamic linker to use"), TWO_DASHES },
280 { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
281 '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
282 { {"fini", required_argument, NULL, OPTION_FINI},
283 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
284 { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
285 '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
286 { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
287 '\0', NULL, N_("Remove unused sections (on some targets)"),
288 TWO_DASHES },
289 { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
290 '\0', NULL, N_("Don't remove unused sections (default)"),
291 TWO_DASHES },
292 { {"help", no_argument, NULL, OPTION_HELP},
293 '\0', NULL, N_("Print option help"), TWO_DASHES },
294 { {"init", required_argument, NULL, OPTION_INIT},
295 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
296 { {"Map", required_argument, NULL, OPTION_MAP},
297 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH },
298 { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
299 '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
300 { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
301 '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES },
302 { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
303 '\0', NULL, N_("Allow no undefined symbols"), TWO_DASHES },
304 { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
305 '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
306 { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
307 '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
308 { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
309 '\0', NULL, N_("Create an output file even if errors occur"), TWO_DASHES },
310 { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
311 '\0', NULL, NULL, NO_HELP },
312 { {"oformat", required_argument, NULL, OPTION_OFORMAT},
313 '\0', N_("TARGET"), N_("Specify target of output file"), TWO_DASHES },
314 { {"qmagic", no_argument, NULL, OPTION_IGNORE},
315 '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
316 { {"relax", no_argument, NULL, OPTION_RELAX},
317 '\0', NULL, N_("Relax branches on certain targets"), TWO_DASHES },
318 { {"retain-symbols-file", required_argument, NULL,
319 OPTION_RETAIN_SYMBOLS_FILE},
320 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
321 { {"rpath", required_argument, NULL, OPTION_RPATH},
322 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH },
323 { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
324 '\0', N_("PATH"), N_("Set link time shared library search path"), ONE_DASH },
325 { {"shared", no_argument, NULL, OPTION_SHARED},
326 '\0', NULL, N_("Create a shared library"), ONE_DASH },
327 { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */
328 '\0', NULL, NULL, ONE_DASH },
329 { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
330 '\0', NULL, N_("Sort common symbols by size"), TWO_DASHES },
331 { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
332 '\0', NULL, NULL, NO_HELP },
333 { {"split-by-file", no_argument, NULL, OPTION_SPLIT_BY_FILE},
334 '\0', NULL, N_("Split output sections for each file"), TWO_DASHES },
335 { {"split-by-reloc", required_argument, NULL, OPTION_SPLIT_BY_RELOC},
336 '\0', N_("COUNT"), N_("Split output sections every COUNT relocs"), TWO_DASHES },
337 { {"stats", no_argument, NULL, OPTION_STATS},
338 '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
339 { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
340 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
341 { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
342 '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
343 { {"section-start", required_argument, NULL, OPTION_SECTION_START},
344 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"), TWO_DASHES },
345 { {"Tbss", required_argument, NULL, OPTION_TBSS},
346 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
347 { {"Tdata", required_argument, NULL, OPTION_TDATA},
348 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
349 { {"Ttext", required_argument, NULL, OPTION_TTEXT},
350 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
351 { {"verbose", no_argument, NULL, OPTION_VERBOSE},
352 '\0', NULL, N_("Output lots of information during link"), TWO_DASHES },
353 { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */
354 '\0', NULL, NULL, NO_HELP },
355 { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
356 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
357 { {"version-exports-section", required_argument, NULL,
358 OPTION_VERSION_EXPORTS_SECTION },
359 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n\t\t\t\tSYMBOL as the version."),
360 TWO_DASHES },
361 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
362 '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
363 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
364 '\0', NULL, N_("Warn if global constructors/destructors are seen"),
365 TWO_DASHES },
366 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
367 '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
368 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
369 '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
370 { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
371 '\0', NULL, N_("Warn if start of section changes due to alignment"),
372 TWO_DASHES },
373 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
374 '\0', NULL, N_("Include all objects from following archives"), TWO_DASHES },
375 { {"wrap", required_argument, NULL, OPTION_WRAP},
376 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
377 { {"mpc860c0", optional_argument, NULL, OPTION_MPC860C0},
378 '\0', N_("[=WORDS]"), N_("Modify problematic branches in last WORDS (1-10,\n\t\t\t\tdefault 5) words of a page"), TWO_DASHES }
379 };
380
381 #define OPTION_COUNT ((int) (sizeof ld_options / sizeof ld_options[0]))
382
383 /* Test STRING for containing a string of digits that form a number
384 between MIN and MAX. The return value is the number or ERR. */
385
386 static int
387 is_num (string, min, max, err)
388 const char *string;
389 int min;
390 int max;
391 int err;
392 {
393 int result = 0;
394
395 for (; *string; ++string)
396 {
397 if (! isdigit (*string))
398 {
399 result = err;
400 break;
401 }
402 result = result * 10 + (*string - '0');
403 }
404 if (result < min || result > max)
405 result = err;
406
407 return result;
408 }
409
410 void
411 parse_args (argc, argv)
412 int argc;
413 char **argv;
414 {
415 int i, is, il;
416 int ingroup = 0;
417 char *default_dirlist = NULL;
418 char shortopts[OPTION_COUNT * 3 + 2];
419 struct option longopts[OPTION_COUNT + 1];
420 int last_optind;
421
422 /* Starting the short option string with '-' is for programs that
423 expect options and other ARGV-elements in any order and that care about
424 the ordering of the two. We describe each non-option ARGV-element
425 as if it were the argument of an option with character code 1. */
426 shortopts[0] = '-';
427 is = 1;
428 il = 0;
429 for (i = 0; i < OPTION_COUNT; i++)
430 {
431 if (ld_options[i].shortopt != '\0')
432 {
433 shortopts[is] = ld_options[i].shortopt;
434 ++is;
435 if (ld_options[i].opt.has_arg == required_argument
436 || ld_options[i].opt.has_arg == optional_argument)
437 {
438 shortopts[is] = ':';
439 ++is;
440 if (ld_options[i].opt.has_arg == optional_argument)
441 {
442 shortopts[is] = ':';
443 ++is;
444 }
445 }
446 }
447 if (ld_options[i].opt.name != NULL)
448 {
449 longopts[il] = ld_options[i].opt;
450 ++il;
451 }
452 }
453 shortopts[is] = '\0';
454 longopts[il].name = NULL;
455
456 /* The -G option is ambiguous on different platforms. Sometimes it
457 specifies the largest data size to put into the small data
458 section. Sometimes it is equivalent to --shared. Unfortunately,
459 the first form takes an argument, while the second does not.
460
461 We need to permit the --shared form because on some platforms,
462 such as Solaris, gcc -shared will pass -G to the linker.
463
464 To permit either usage, we look through the argument list. If we
465 find -G not followed by a number, we change it into --shared.
466 This will work for most normal cases. */
467 for (i = 1; i < argc; i++)
468 if (strcmp (argv[i], "-G") == 0
469 && (i + 1 >= argc
470 || ! isdigit ((unsigned char) argv[i + 1][0])))
471 argv[i] = (char *) "--shared";
472
473 /* Because we permit long options to start with a single dash, and
474 we have a --library option, and the -l option is conventionally
475 used with an immediately following argument, we can have bad
476 results if somebody tries to use -l with a library whose name
477 happens to start with "ibrary", as in -li. We avoid problems by
478 simply turning -l into --library. This means that users will
479 have to use two dashes in order to use --library, which is OK
480 since that's how it is documented.
481
482 FIXME: It's possible that this problem can arise for other short
483 options as well, although the user does always have the recourse
484 of adding a space between the option and the argument. */
485 for (i = 1; i < argc; i++)
486 {
487 if (argv[i][0] == '-'
488 && argv[i][1] == 'l'
489 && argv[i][2] != '\0')
490 {
491 char *n;
492
493 n = (char *) xmalloc (strlen (argv[i]) + 20);
494 sprintf (n, "--library=%s", argv[i] + 2);
495 argv[i] = n;
496 }
497 }
498
499 last_optind = -1;
500 while (1)
501 {
502 int longind;
503 int optc;
504
505 /* Using last_optind lets us avoid calling ldemul_parse_args
506 multiple times on a single option, which would lead to
507 confusion in the internal static variables maintained by
508 getopt. This could otherwise happen for an argument like
509 -nx, in which the -n is parsed as a single option, and we
510 loop around to pick up the -x. */
511 if (optind != last_optind)
512 {
513 if (ldemul_parse_args (argc, argv))
514 continue;
515 last_optind = optind;
516 }
517
518 /* getopt_long_only is like getopt_long, but '-' as well as '--'
519 can indicate a long option. */
520 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
521
522 if (optc == -1)
523 break;
524 switch (optc)
525 {
526 default:
527 fprintf (stderr,
528 _("%s: use the --help option for usage information\n"),
529 program_name);
530 xexit (1);
531 case 1: /* File name. */
532 lang_add_input_file (optarg, lang_input_file_is_file_enum,
533 (char *) NULL);
534 break;
535
536 case OPTION_IGNORE:
537 break;
538 case 'a':
539 /* For HP/UX compatibility. Actually -a shared should mean
540 ``use only shared libraries'' but, then, we don't
541 currently support shared libraries on HP/UX anyhow. */
542 if (strcmp (optarg, "archive") == 0)
543 config.dynamic_link = false;
544 else if (strcmp (optarg, "shared") == 0
545 || strcmp (optarg, "default") == 0)
546 config.dynamic_link = true;
547 else
548 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg);
549 break;
550 case OPTION_ASSERT:
551 /* FIXME: We just ignore these, but we should handle them. */
552 if (strcmp (optarg, "definitions") == 0)
553 ;
554 else if (strcmp (optarg, "nodefinitions") == 0)
555 ;
556 else if (strcmp (optarg, "nosymbolic") == 0)
557 ;
558 else if (strcmp (optarg, "pure-text") == 0)
559 ;
560 else
561 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg);
562 break;
563 case 'A':
564 ldfile_add_arch (optarg);
565 break;
566 case 'b':
567 lang_add_target (optarg);
568 break;
569 case 'c':
570 ldfile_open_command_file (optarg);
571 parser_input = input_mri_script;
572 yyparse ();
573 break;
574 case OPTION_CALL_SHARED:
575 config.dynamic_link = true;
576 break;
577 case OPTION_NON_SHARED:
578 config.dynamic_link = false;
579 break;
580 case OPTION_CREF:
581 command_line.cref = true;
582 link_info.notice_all = true;
583 break;
584 case 'd':
585 command_line.force_common_definition = true;
586 break;
587 case OPTION_DEFSYM:
588 lex_string = optarg;
589 lex_redirect (optarg);
590 parser_input = input_defsym;
591 parsing_defsym = 1;
592 yyparse ();
593 parsing_defsym = 0;
594 lex_string = NULL;
595 break;
596 case OPTION_DEMANGLE:
597 demangling = true;
598 if (optarg != NULL)
599 {
600 enum demangling_styles style;
601
602 style = cplus_demangle_name_to_style (optarg);
603 if (style == unknown_demangling)
604 einfo (_("%F%P: unknown demangling style `%s'"),
605 optarg);
606
607 cplus_demangle_set_style (style);
608 }
609 break;
610 case OPTION_DYNAMIC_LINKER:
611 command_line.interpreter = optarg;
612 break;
613 case OPTION_EB:
614 command_line.endian = ENDIAN_BIG;
615 break;
616 case OPTION_EL:
617 command_line.endian = ENDIAN_LITTLE;
618 break;
619 case OPTION_EMBEDDED_RELOCS:
620 command_line.embedded_relocs = true;
621 break;
622 case OPTION_EXPORT_DYNAMIC:
623 case 'E': /* HP/UX compatibility. */
624 command_line.export_dynamic = true;
625 break;
626 case 'e':
627 lang_add_entry (optarg, true);
628 break;
629 case 'f':
630 if (command_line.auxiliary_filters == NULL)
631 {
632 command_line.auxiliary_filters =
633 (char **) xmalloc (2 * sizeof (char *));
634 command_line.auxiliary_filters[0] = optarg;
635 command_line.auxiliary_filters[1] = NULL;
636 }
637 else
638 {
639 int c;
640 char **p;
641
642 c = 0;
643 for (p = command_line.auxiliary_filters; *p != NULL; p++)
644 ++c;
645 command_line.auxiliary_filters =
646 (char **) xrealloc (command_line.auxiliary_filters,
647 (c + 2) * sizeof (char *));
648 command_line.auxiliary_filters[c] = optarg;
649 command_line.auxiliary_filters[c + 1] = NULL;
650 }
651 break;
652 case 'F':
653 command_line.filter_shlib = optarg;
654 break;
655 case OPTION_FORCE_EXE_SUFFIX:
656 command_line.force_exe_suffix = true;
657 break;
658 case 'G':
659 {
660 char *end;
661 g_switch_value = strtoul (optarg, &end, 0);
662 if (*end)
663 einfo (_("%P%F: invalid number `%s'\n"), optarg);
664 }
665 break;
666 case 'g':
667 /* Ignore. */
668 break;
669 case OPTION_GC_SECTIONS:
670 command_line.gc_sections = true;
671 break;
672 case OPTION_HELP:
673 help ();
674 xexit (0);
675 break;
676 case 'L':
677 ldfile_add_library_path (optarg, true);
678 break;
679 case 'l':
680 lang_add_input_file (optarg, lang_input_file_is_l_enum,
681 (char *) NULL);
682 break;
683 case 'M':
684 config.map_filename = "-";
685 break;
686 case 'm':
687 /* Ignore. Was handled in a pre-parse. */
688 break;
689 case OPTION_MAP:
690 config.map_filename = optarg;
691 break;
692 case 'N':
693 config.text_read_only = false;
694 config.magic_demand_paged = false;
695 config.dynamic_link = false;
696 break;
697 case 'n':
698 config.magic_demand_paged = false;
699 config.dynamic_link = false;
700 break;
701 case OPTION_NO_DEMANGLE:
702 demangling = false;
703 break;
704 case OPTION_NO_GC_SECTIONS:
705 command_line.gc_sections = false;
706 break;
707 case OPTION_NO_KEEP_MEMORY:
708 link_info.keep_memory = false;
709 break;
710 case OPTION_NO_UNDEFINED:
711 link_info.no_undefined = true;
712 break;
713 case OPTION_NO_WARN_MISMATCH:
714 command_line.warn_mismatch = false;
715 break;
716 case OPTION_NOINHIBIT_EXEC:
717 force_make_executable = true;
718 break;
719 case OPTION_NO_WHOLE_ARCHIVE:
720 whole_archive = false;
721 break;
722 case 'O':
723 /* FIXME "-O<non-digits> <value>" used to set the address of
724 section <non-digits>. Was this for compatibility with
725 something, or can we create a new option to do that
726 (with a syntax similar to -defsym)?
727 getopt can't handle two args to an option without kludges. */
728
729 /* Enable optimizations of output files. */
730 link_info.optimize = strtoul (optarg, NULL, 0) ? true : false;
731 break;
732 case 'o':
733 lang_add_output (optarg, 0);
734 break;
735 case OPTION_OFORMAT:
736 lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
737 break;
738 case 'q':
739 link_info.emitrelocations = true;
740 break;
741 case 'i':
742 case 'r':
743 link_info.relocateable = true;
744 config.build_constructors = false;
745 config.magic_demand_paged = false;
746 config.text_read_only = false;
747 config.dynamic_link = false;
748 break;
749 case 'R':
750 /* The GNU linker traditionally uses -R to mean to include
751 only the symbols from a file. The Solaris linker uses -R
752 to set the path used by the runtime linker to find
753 libraries. This is the GNU linker -rpath argument. We
754 try to support both simultaneously by checking the file
755 named. If it is a directory, rather than a regular file,
756 we assume -rpath was meant. */
757 {
758 struct stat s;
759
760 if (stat (optarg, &s) >= 0
761 && ! S_ISDIR (s.st_mode))
762 {
763 lang_add_input_file (optarg,
764 lang_input_file_is_symbols_only_enum,
765 (char *) NULL);
766 break;
767 }
768 }
769 /* Fall through. */
770 case OPTION_RPATH:
771 if (command_line.rpath == NULL)
772 command_line.rpath = buystring (optarg);
773 else
774 {
775 size_t rpath_len = strlen (command_line.rpath);
776 size_t optarg_len = strlen (optarg);
777 char *buf;
778 char *cp = command_line.rpath;
779
780 /* First see whether OPTARG is already in the path. */
781 do
782 {
783 size_t idx = 0;
784 while (optarg[idx] != '\0' && optarg[idx] == cp[idx])
785 ++idx;
786 if (optarg[idx] == '\0'
787 && (cp[idx] == '\0' || cp[idx] == ':'))
788 /* We found it. */
789 break;
790
791 /* Not yet found. */
792 cp = strchr (cp, ':');
793 if (cp != NULL)
794 ++cp;
795 }
796 while (cp != NULL);
797
798 if (cp == NULL)
799 {
800 buf = xmalloc (rpath_len + optarg_len + 2);
801 sprintf (buf, "%s:%s", command_line.rpath, optarg);
802 free (command_line.rpath);
803 command_line.rpath = buf;
804 }
805 }
806 break;
807 case OPTION_RPATH_LINK:
808 if (command_line.rpath_link == NULL)
809 command_line.rpath_link = buystring (optarg);
810 else
811 {
812 char *buf;
813
814 buf = xmalloc (strlen (command_line.rpath_link)
815 + strlen (optarg)
816 + 2);
817 sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
818 free (command_line.rpath_link);
819 command_line.rpath_link = buf;
820 }
821 break;
822 case OPTION_RELAX:
823 command_line.relax = true;
824 break;
825 case OPTION_RETAIN_SYMBOLS_FILE:
826 add_keepsyms_file (optarg);
827 break;
828 case 'S':
829 link_info.strip = strip_debugger;
830 break;
831 case 's':
832 link_info.strip = strip_all;
833 break;
834 case OPTION_SHARED:
835 if (config.has_shared)
836 link_info.shared = true;
837 else
838 einfo (_("%P%F: -shared not supported\n"));
839 break;
840 case 'h': /* Used on Solaris. */
841 case OPTION_SONAME:
842 command_line.soname = optarg;
843 break;
844 case OPTION_SORT_COMMON:
845 config.sort_common = true;
846 break;
847 case OPTION_STATS:
848 config.stats = true;
849 break;
850 case OPTION_SYMBOLIC:
851 link_info.symbolic = true;
852 break;
853 case 't':
854 trace_files = true;
855 break;
856 case 'T':
857 ldfile_open_command_file (optarg);
858 parser_input = input_script;
859 yyparse ();
860 break;
861 case OPTION_SECTION_START:
862 {
863 char *optarg2;
864 char *sec_name;
865 int len;
866
867 /* Check for <something>=<somthing>... */
868 optarg2 = strchr (optarg, '=');
869 if (optarg2 == NULL)
870 {
871 fprintf (stderr,
872 _("%s: Invalid argument to option \"--section-start\"\n"),
873 program_name);
874 xexit (1);
875 }
876
877 optarg2 ++;
878
879 /* So far so good. Are all the args present? */
880 if ((*optarg == '\0') || (*optarg2 == '\0'))
881 {
882 fprintf (stderr,
883 _("%s: Missing argument(s) to option \"--section-start\"\n"),
884 program_name);
885 xexit (1);
886 }
887
888 /* We must copy the section name as set_section_start
889 doesn't do it for us. */
890 len = optarg2 - optarg;
891 sec_name = xmalloc (len);
892 memcpy (sec_name, optarg, len - 1);
893 sec_name[len - 1] = 0;
894
895 /* Then set it... */
896 set_section_start (sec_name, optarg2);
897 }
898 break;
899 case OPTION_TBSS:
900 set_section_start (".bss", optarg);
901 break;
902 case OPTION_TDATA:
903 set_section_start (".data", optarg);
904 break;
905 case OPTION_TTEXT:
906 set_section_start (".text", optarg);
907 break;
908 case OPTION_TRADITIONAL_FORMAT:
909 link_info.traditional_format = true;
910 break;
911 case OPTION_TASK_LINK:
912 link_info.task_link = true;
913 /* Fall through - do an implied -r option. */
914 case OPTION_UR:
915 link_info.relocateable = true;
916 config.build_constructors = true;
917 config.magic_demand_paged = false;
918 config.text_read_only = false;
919 config.dynamic_link = false;
920 break;
921 case 'u':
922 ldlang_add_undef (optarg);
923 break;
924 case OPTION_VERBOSE:
925 ldversion (1);
926 version_printed = true;
927 trace_file_tries = true;
928 break;
929 case 'v':
930 ldversion (0);
931 version_printed = true;
932 break;
933 case 'V':
934 ldversion (1);
935 version_printed = true;
936 break;
937 case OPTION_VERSION:
938 /* This output is intended to follow the GNU standards document. */
939 printf ("GNU ld %s\n", ld_program_version);
940 printf (_("Copyright 2000 Free Software Foundation, Inc.\n"));
941 printf (_("\
942 This program is free software; you may redistribute it under the terms of\n\
943 the GNU General Public License. This program has absolutely no warranty.\n"));
944 {
945 ld_emulation_xfer_type **ptr = ld_emulations;
946
947 printf (_(" Supported emulations:\n"));
948 while (*ptr)
949 {
950 printf (" %s\n", (*ptr)->emulation_name);
951 ptr++;
952 }
953 }
954 xexit (0);
955 break;
956 case OPTION_VERSION_SCRIPT:
957 /* This option indicates a small script that only specifies
958 version information. Read it, but don't assume that
959 we've seen a linker script. */
960 {
961 boolean hold_had_script;
962
963 hold_had_script = had_script;
964 ldfile_open_command_file (optarg);
965 had_script = hold_had_script;
966 parser_input = input_version_script;
967 yyparse ();
968 }
969 break;
970 case OPTION_VERSION_EXPORTS_SECTION:
971 /* This option records a version symbol to be applied to the
972 symbols listed for export to be found in the object files
973 .exports sections. */
974 command_line.version_exports_section = optarg;
975 break;
976 case OPTION_WARN_COMMON:
977 config.warn_common = true;
978 break;
979 case OPTION_WARN_CONSTRUCTORS:
980 config.warn_constructors = true;
981 break;
982 case OPTION_WARN_MULTIPLE_GP:
983 config.warn_multiple_gp = true;
984 break;
985 case OPTION_WARN_ONCE:
986 config.warn_once = true;
987 break;
988 case OPTION_WARN_SECTION_ALIGN:
989 config.warn_section_align = true;
990 break;
991 case OPTION_WHOLE_ARCHIVE:
992 whole_archive = true;
993 break;
994 case OPTION_WRAP:
995 add_wrap (optarg);
996 break;
997 case 'X':
998 link_info.discard = discard_l;
999 break;
1000 case 'x':
1001 link_info.discard = discard_all;
1002 break;
1003 case 'Y':
1004 if (strncmp (optarg, "P,", 2) == 0)
1005 optarg += 2;
1006 default_dirlist = xstrdup (optarg);
1007 break;
1008 case 'y':
1009 add_ysym (optarg);
1010 break;
1011 #if 0
1012 case 'z':
1013 /* We accept and ignore this option for Solaris
1014 compatibility. Actually, on Solaris, optarg is not
1015 ignored. Someday we should handle it correctly. FIXME. */
1016 break;
1017 #endif
1018 case OPTION_SPLIT_BY_RELOC:
1019 config.split_by_reloc = strtoul (optarg, NULL, 0);
1020 break;
1021 case OPTION_SPLIT_BY_FILE:
1022 config.split_by_file = true;
1023 break;
1024 case OPTION_CHECK_SECTIONS:
1025 command_line.check_section_addresses = true;
1026 break;
1027 case OPTION_NO_CHECK_SECTIONS:
1028 command_line.check_section_addresses = false;
1029 break;
1030 case '(':
1031 if (ingroup)
1032 {
1033 fprintf (stderr,
1034 _("%s: may not nest groups (--help for usage)\n"),
1035 program_name);
1036 xexit (1);
1037 }
1038 lang_enter_group ();
1039 ingroup = 1;
1040 break;
1041 case ')':
1042 if (! ingroup)
1043 {
1044 fprintf (stderr,
1045 _("%s: group ended before it began (--help for usage)\n"),
1046 program_name);
1047 xexit (1);
1048 }
1049 lang_leave_group ();
1050 ingroup = 0;
1051 break;
1052 case OPTION_MPC860C0:
1053 link_info.mpc860c0 = 20; /* default value (in bytes) */
1054 if (optarg)
1055 {
1056 unsigned words;
1057
1058 words = is_num (optarg, 1, 10, 0);
1059 if (words == 0)
1060 {
1061 fprintf (stderr,
1062 _("%s: Invalid argument to option \"mpc860c0\"\n"),
1063 program_name);
1064 xexit (1);
1065 }
1066 link_info.mpc860c0 = words * 4; /* convert words to bytes */
1067 }
1068 command_line.relax = true;
1069 break;
1070
1071 case OPTION_INIT:
1072 link_info.init_function = optarg;
1073 break;
1074
1075 case OPTION_FINI:
1076 link_info.fini_function = optarg;
1077 break;
1078 }
1079 }
1080
1081 if (ingroup)
1082 lang_leave_group ();
1083
1084 if (default_dirlist != NULL)
1085 set_default_dirlist (default_dirlist);
1086
1087 }
1088
1089 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1090 library search path. */
1091
1092 static void
1093 set_default_dirlist (dirlist_ptr)
1094 char *dirlist_ptr;
1095 {
1096 char *p;
1097
1098 while (1)
1099 {
1100 p = strchr (dirlist_ptr, PATH_SEPARATOR);
1101 if (p != NULL)
1102 *p = '\0';
1103 if (*dirlist_ptr != '\0')
1104 ldfile_add_library_path (dirlist_ptr, true);
1105 if (p == NULL)
1106 break;
1107 dirlist_ptr = p + 1;
1108 }
1109 }
1110
1111 static void
1112 set_section_start (sect, valstr)
1113 char *sect, *valstr;
1114 {
1115 const char *end;
1116 bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1117 if (*end)
1118 einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
1119 lang_section_start (sect, exp_intop (val));
1120 }
1121 \f
1122 /* Print help messages for the options. */
1123
1124 static void
1125 help ()
1126 {
1127 int i;
1128 const char **targets, **pp;
1129
1130 printf (_("Usage: %s [options] file...\n"), program_name);
1131
1132 printf (_("Options:\n"));
1133 for (i = 0; i < OPTION_COUNT; i++)
1134 {
1135 if (ld_options[i].doc != NULL)
1136 {
1137 boolean comma;
1138 int len;
1139 int j;
1140
1141 printf (" ");
1142
1143 comma = false;
1144 len = 2;
1145
1146 j = i;
1147 do
1148 {
1149 if (ld_options[j].shortopt != '\0'
1150 && ld_options[j].control != NO_HELP)
1151 {
1152 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
1153 len += (comma ? 2 : 0) + 2;
1154 if (ld_options[j].arg != NULL)
1155 {
1156 if (ld_options[j].opt.has_arg != optional_argument)
1157 {
1158 printf (" ");
1159 ++len;
1160 }
1161 printf ("%s", _(ld_options[j].arg));
1162 len += strlen (_(ld_options[j].arg));
1163 }
1164 comma = true;
1165 }
1166 ++j;
1167 }
1168 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1169
1170 j = i;
1171 do
1172 {
1173 if (ld_options[j].opt.name != NULL
1174 && ld_options[j].control != NO_HELP)
1175 {
1176 printf ("%s-%s%s",
1177 comma ? ", " : "",
1178 ld_options[j].control == TWO_DASHES ? "-" : "",
1179 ld_options[j].opt.name);
1180 len += ((comma ? 2 : 0)
1181 + 1
1182 + (ld_options[j].control == TWO_DASHES ? 1 : 0)
1183 + strlen (ld_options[j].opt.name));
1184 if (ld_options[j].arg != NULL)
1185 {
1186 printf (" %s", _(ld_options[j].arg));
1187 len += 1 + strlen (_(ld_options[j].arg));
1188 }
1189 comma = true;
1190 }
1191 ++j;
1192 }
1193 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
1194
1195 if (len >= 30)
1196 {
1197 printf ("\n");
1198 len = 0;
1199 }
1200
1201 for (; len < 30; len++)
1202 putchar (' ');
1203
1204 printf ("%s\n", _(ld_options[i].doc));
1205 }
1206 }
1207
1208 /* Note: Various tools (such as libtool) depend upon the
1209 format of the listings below - do not change them. */
1210 /* xgettext:c-format */
1211 printf (_("%s: supported targets:"), program_name);
1212 targets = bfd_target_list ();
1213 for (pp = targets; *pp != NULL; pp++)
1214 printf (" %s", *pp);
1215 free (targets);
1216 printf ("\n");
1217
1218 /* xgettext:c-format */
1219 printf (_("%s: supported emulations: "), program_name);
1220 ldemul_list_emulations (stdout);
1221 printf ("\n");
1222
1223 /* xgettext:c-format */
1224 printf (_("%s: emulation specific options:\n"), program_name);
1225 ldemul_list_emulation_options (stdout);
1226 printf ("\n");
1227
1228 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);
1229 }
This page took 0.091665 seconds and 5 git commands to generate.