OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [ld/] [lexsup.c] - Blame information for rev 300

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.