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