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