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