xref: /netbsd/external/gpl3/gdb.old/dist/ld/lexsup.c (revision 56bb7041)
1*56bb7041Schristos /* Parse options for the GNU linker.
2*56bb7041Schristos    Copyright (C) 1991-2020 Free Software Foundation, Inc.
3*56bb7041Schristos 
4*56bb7041Schristos    This file is part of the GNU Binutils.
5*56bb7041Schristos 
6*56bb7041Schristos    This program is free software; you can redistribute it and/or modify
7*56bb7041Schristos    it under the terms of the GNU General Public License as published by
8*56bb7041Schristos    the Free Software Foundation; either version 3 of the License, or
9*56bb7041Schristos    (at your option) any later version.
10*56bb7041Schristos 
11*56bb7041Schristos    This program is distributed in the hope that it will be useful,
12*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*56bb7041Schristos    GNU General Public License for more details.
15*56bb7041Schristos 
16*56bb7041Schristos    You should have received a copy of the GNU General Public License
17*56bb7041Schristos    along with this program; if not, write to the Free Software
18*56bb7041Schristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19*56bb7041Schristos    MA 02110-1301, USA.  */
20*56bb7041Schristos 
21*56bb7041Schristos #include "sysdep.h"
22*56bb7041Schristos #include "bfd.h"
23*56bb7041Schristos #include "bfdver.h"
24*56bb7041Schristos #include "libiberty.h"
25*56bb7041Schristos #include <stdio.h>
26*56bb7041Schristos #include <string.h>
27*56bb7041Schristos #include "safe-ctype.h"
28*56bb7041Schristos #include "getopt.h"
29*56bb7041Schristos #include "bfdlink.h"
30*56bb7041Schristos #include "ctf-api.h"
31*56bb7041Schristos #include "ld.h"
32*56bb7041Schristos #include "ldmain.h"
33*56bb7041Schristos #include "ldmisc.h"
34*56bb7041Schristos #include "ldexp.h"
35*56bb7041Schristos #include "ldlang.h"
36*56bb7041Schristos #include <ldgram.h>
37*56bb7041Schristos #include "ldlex.h"
38*56bb7041Schristos #include "ldfile.h"
39*56bb7041Schristos #include "ldver.h"
40*56bb7041Schristos #include "ldemul.h"
41*56bb7041Schristos #include "demangle.h"
42*56bb7041Schristos #if BFD_SUPPORTS_PLUGINS
43*56bb7041Schristos #include "plugin.h"
44*56bb7041Schristos #endif /* BFD_SUPPORTS_PLUGINS */
45*56bb7041Schristos 
46*56bb7041Schristos #ifndef PATH_SEPARATOR
47*56bb7041Schristos #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
48*56bb7041Schristos #define PATH_SEPARATOR ';'
49*56bb7041Schristos #else
50*56bb7041Schristos #define PATH_SEPARATOR ':'
51*56bb7041Schristos #endif
52*56bb7041Schristos #endif
53*56bb7041Schristos 
54*56bb7041Schristos /* Somewhere above, sys/stat.h got included . . . .  */
55*56bb7041Schristos #if !defined(S_ISDIR) && defined(S_IFDIR)
56*56bb7041Schristos #define	S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
57*56bb7041Schristos #endif
58*56bb7041Schristos 
59*56bb7041Schristos static void set_default_dirlist (char *);
60*56bb7041Schristos static void set_section_start (char *, char *);
61*56bb7041Schristos static void set_segment_start (const char *, char *);
62*56bb7041Schristos static void help (void);
63*56bb7041Schristos 
64*56bb7041Schristos /* The long options.  This structure is used for both the option
65*56bb7041Schristos    parsing and the help text.  */
66*56bb7041Schristos 
67*56bb7041Schristos enum control_enum {
68*56bb7041Schristos   /* Use one dash before long option name.  */
69*56bb7041Schristos   ONE_DASH = 1,
70*56bb7041Schristos   /* Use two dashes before long option name.  */
71*56bb7041Schristos   TWO_DASHES = 2,
72*56bb7041Schristos   /* Only accept two dashes before the long option name.
73*56bb7041Schristos      This is an overloading of the use of this enum, since originally it
74*56bb7041Schristos      was only intended to tell the --help display function how to display
75*56bb7041Schristos      the long option name.  This feature was added in order to resolve
76*56bb7041Schristos      the confusion about the -omagic command line switch.  Is it setting
77*56bb7041Schristos      the output file name to "magic" or is it setting the NMAGIC flag on
78*56bb7041Schristos      the output ?  It has been decided that it is setting the output file
79*56bb7041Schristos      name, and that if you want to set the NMAGIC flag you should use -N
80*56bb7041Schristos      or --omagic.  */
81*56bb7041Schristos   EXACTLY_TWO_DASHES,
82*56bb7041Schristos   /* Don't mention this option in --help output.  */
83*56bb7041Schristos   NO_HELP
84*56bb7041Schristos };
85*56bb7041Schristos 
86*56bb7041Schristos struct ld_option
87*56bb7041Schristos {
88*56bb7041Schristos   /* The long option information.  */
89*56bb7041Schristos   struct option opt;
90*56bb7041Schristos   /* The short option with the same meaning ('\0' if none).  */
91*56bb7041Schristos   char shortopt;
92*56bb7041Schristos   /* The name of the argument (NULL if none).  */
93*56bb7041Schristos   const char *arg;
94*56bb7041Schristos   /* The documentation string.  If this is NULL, this is a synonym for
95*56bb7041Schristos      the previous option.  */
96*56bb7041Schristos   const char *doc;
97*56bb7041Schristos   enum control_enum control;
98*56bb7041Schristos };
99*56bb7041Schristos 
100*56bb7041Schristos static const struct ld_option ld_options[] =
101*56bb7041Schristos {
102*56bb7041Schristos   { {NULL, required_argument, NULL, '\0'},
103*56bb7041Schristos     'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
104*56bb7041Schristos     ONE_DASH },
105*56bb7041Schristos   { {"architecture", required_argument, NULL, 'A'},
106*56bb7041Schristos     'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES },
107*56bb7041Schristos   { {"format", required_argument, NULL, 'b'},
108*56bb7041Schristos     'b', N_("TARGET"), N_("Specify target for following input files"),
109*56bb7041Schristos     TWO_DASHES },
110*56bb7041Schristos   { {"mri-script", required_argument, NULL, 'c'},
111*56bb7041Schristos     'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES },
112*56bb7041Schristos   { {"dc", no_argument, NULL, 'd'},
113*56bb7041Schristos     'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
114*56bb7041Schristos   { {"dp", no_argument, NULL, 'd'},
115*56bb7041Schristos     '\0', NULL, NULL, ONE_DASH },
116*56bb7041Schristos   { {"dependency-file", required_argument, NULL, OPTION_DEPENDENCY_FILE},
117*56bb7041Schristos     '\0', N_("FILE"), N_("Write dependency file"), TWO_DASHES },
118*56bb7041Schristos   { {"force-group-allocation", no_argument, NULL,
119*56bb7041Schristos      OPTION_FORCE_GROUP_ALLOCATION},
120*56bb7041Schristos     '\0', NULL, N_("Force group members out of groups"), TWO_DASHES },
121*56bb7041Schristos   { {"entry", required_argument, NULL, 'e'},
122*56bb7041Schristos     'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
123*56bb7041Schristos   { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
124*56bb7041Schristos     'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
125*56bb7041Schristos   { {"no-export-dynamic", no_argument, NULL, OPTION_NO_EXPORT_DYNAMIC},
126*56bb7041Schristos     '\0', NULL, N_("Undo the effect of --export-dynamic"), TWO_DASHES },
127*56bb7041Schristos   { {"enable-non-contiguous-regions", no_argument, NULL, OPTION_NON_CONTIGUOUS_REGIONS},
128*56bb7041Schristos     '\0', NULL, N_("Enable support of non-contiguous memory regions"), TWO_DASHES },
129*56bb7041Schristos   { {"enable-non-contiguous-regions-warnings", no_argument, NULL, OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS},
130*56bb7041Schristos     '\0', NULL, N_("Enable warnings when --enable-non-contiguous-regions may cause unexpected behaviour"), TWO_DASHES },
131*56bb7041Schristos   { {"EB", no_argument, NULL, OPTION_EB},
132*56bb7041Schristos     '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
133*56bb7041Schristos   { {"EL", no_argument, NULL, OPTION_EL},
134*56bb7041Schristos     '\0', NULL, N_("Link little-endian objects"), ONE_DASH },
135*56bb7041Schristos   { {"auxiliary", required_argument, NULL, 'f'},
136*56bb7041Schristos     'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
137*56bb7041Schristos     TWO_DASHES },
138*56bb7041Schristos   { {"filter", required_argument, NULL, 'F'},
139*56bb7041Schristos     'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
140*56bb7041Schristos     TWO_DASHES },
141*56bb7041Schristos   { {NULL, no_argument, NULL, '\0'},
142*56bb7041Schristos     'g', NULL, N_("Ignored"), ONE_DASH },
143*56bb7041Schristos   { {"gpsize", required_argument, NULL, 'G'},
144*56bb7041Schristos     'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
145*56bb7041Schristos     TWO_DASHES },
146*56bb7041Schristos   { {"soname", required_argument, NULL, OPTION_SONAME},
147*56bb7041Schristos     'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
148*56bb7041Schristos   { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
149*56bb7041Schristos     'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
150*56bb7041Schristos     TWO_DASHES },
151*56bb7041Schristos   { {"no-dynamic-linker", no_argument, NULL, OPTION_NO_DYNAMIC_LINKER},
152*56bb7041Schristos     '\0', NULL, N_("Produce an executable with no program interpreter header"),
153*56bb7041Schristos     TWO_DASHES },
154*56bb7041Schristos   { {"library", required_argument, NULL, 'l'},
155*56bb7041Schristos     'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
156*56bb7041Schristos   { {"library-path", required_argument, NULL, 'L'},
157*56bb7041Schristos     'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
158*56bb7041Schristos     TWO_DASHES },
159*56bb7041Schristos   { {"sysroot=<DIRECTORY>", required_argument, NULL, OPTION_SYSROOT},
160*56bb7041Schristos     '\0', NULL, N_("Override the default sysroot location"), TWO_DASHES },
161*56bb7041Schristos   { {NULL, required_argument, NULL, '\0'},
162*56bb7041Schristos     'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH },
163*56bb7041Schristos   { {"print-map", no_argument, NULL, 'M'},
164*56bb7041Schristos     'M', NULL, N_("Print map file on standard output"), TWO_DASHES },
165*56bb7041Schristos   { {"nmagic", no_argument, NULL, 'n'},
166*56bb7041Schristos     'n', NULL, N_("Do not page align data"), TWO_DASHES },
167*56bb7041Schristos   { {"omagic", no_argument, NULL, 'N'},
168*56bb7041Schristos     'N', NULL, N_("Do not page align data, do not make text readonly"),
169*56bb7041Schristos     EXACTLY_TWO_DASHES },
170*56bb7041Schristos   { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC},
171*56bb7041Schristos     '\0', NULL, N_("Page align data, make text readonly"),
172*56bb7041Schristos     EXACTLY_TWO_DASHES },
173*56bb7041Schristos   { {"output", required_argument, NULL, 'o'},
174*56bb7041Schristos     'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES },
175*56bb7041Schristos   { {NULL, required_argument, NULL, '\0'},
176*56bb7041Schristos     'O', NULL, N_("Optimize output file"), ONE_DASH },
177*56bb7041Schristos   { {"out-implib", required_argument, NULL, OPTION_OUT_IMPLIB},
178*56bb7041Schristos     '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES },
179*56bb7041Schristos #if BFD_SUPPORTS_PLUGINS
180*56bb7041Schristos   { {"plugin", required_argument, NULL, OPTION_PLUGIN},
181*56bb7041Schristos     '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
182*56bb7041Schristos   { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
183*56bb7041Schristos     '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
184*56bb7041Schristos   { {"flto", optional_argument, NULL, OPTION_IGNORE},
185*56bb7041Schristos     '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
186*56bb7041Schristos     ONE_DASH },
187*56bb7041Schristos   { {"flto-partition=", required_argument, NULL, OPTION_IGNORE},
188*56bb7041Schristos     '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
189*56bb7041Schristos     ONE_DASH },
190*56bb7041Schristos #else
191*56bb7041Schristos   { {"plugin", required_argument, NULL, OPTION_IGNORE},
192*56bb7041Schristos     '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH },
193*56bb7041Schristos   { {"plugin-opt", required_argument, NULL, OPTION_IGNORE},
194*56bb7041Schristos     '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH },
195*56bb7041Schristos #endif /* BFD_SUPPORTS_PLUGINS */
196*56bb7041Schristos   { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE},
197*56bb7041Schristos     '\0', NULL, N_("Ignored for GCC linker option compatibility"),
198*56bb7041Schristos     ONE_DASH },
199*56bb7041Schristos   { {"map-whole-files", optional_argument, NULL, OPTION_IGNORE},
200*56bb7041Schristos     '\0', NULL, N_("Ignored for gold option compatibility"),
201*56bb7041Schristos     TWO_DASHES },
202*56bb7041Schristos   { {"no-map-whole-files", optional_argument, NULL, OPTION_IGNORE},
203*56bb7041Schristos     '\0', NULL, N_("Ignored for gold option compatibility"),
204*56bb7041Schristos     TWO_DASHES },
205*56bb7041Schristos   { {"Qy", no_argument, NULL, OPTION_IGNORE},
206*56bb7041Schristos     '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
207*56bb7041Schristos   { {"emit-relocs", no_argument, NULL, 'q'},
208*56bb7041Schristos     'q', NULL, "Generate relocations in final output", TWO_DASHES },
209*56bb7041Schristos   { {"relocatable", no_argument, NULL, 'r'},
210*56bb7041Schristos     'r', NULL, N_("Generate relocatable output"), TWO_DASHES },
211*56bb7041Schristos   { {NULL, no_argument, NULL, '\0'},
212*56bb7041Schristos     'i', NULL, NULL, ONE_DASH },
213*56bb7041Schristos   { {"just-symbols", required_argument, NULL, 'R'},
214*56bb7041Schristos     'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
215*56bb7041Schristos     TWO_DASHES },
216*56bb7041Schristos   { {"strip-all", no_argument, NULL, 's'},
217*56bb7041Schristos     's', NULL, N_("Strip all symbols"), TWO_DASHES },
218*56bb7041Schristos   { {"strip-debug", no_argument, NULL, 'S'},
219*56bb7041Schristos     'S', NULL, N_("Strip debugging symbols"), TWO_DASHES },
220*56bb7041Schristos   { {"strip-discarded", no_argument, NULL, OPTION_STRIP_DISCARDED},
221*56bb7041Schristos     '\0', NULL, N_("Strip symbols in discarded sections"), TWO_DASHES },
222*56bb7041Schristos   { {"no-strip-discarded", no_argument, NULL, OPTION_NO_STRIP_DISCARDED},
223*56bb7041Schristos     '\0', NULL, N_("Do not strip symbols in discarded sections"), TWO_DASHES },
224*56bb7041Schristos   { {"trace", no_argument, NULL, 't'},
225*56bb7041Schristos     't', NULL, N_("Trace file opens"), TWO_DASHES },
226*56bb7041Schristos   { {"script", required_argument, NULL, 'T'},
227*56bb7041Schristos     'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
228*56bb7041Schristos   { {"default-script", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
229*56bb7041Schristos     '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES },
230*56bb7041Schristos   { {"dT", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
231*56bb7041Schristos     '\0', NULL, NULL, ONE_DASH },
232*56bb7041Schristos   { {"undefined", required_argument, NULL, 'u'},
233*56bb7041Schristos     'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
234*56bb7041Schristos     TWO_DASHES },
235*56bb7041Schristos   { {"require-defined", required_argument, NULL, OPTION_REQUIRE_DEFINED_SYMBOL},
236*56bb7041Schristos     '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
237*56bb7041Schristos     TWO_DASHES },
238*56bb7041Schristos   { {"unique", optional_argument, NULL, OPTION_UNIQUE},
239*56bb7041Schristos     '\0', N_("[=SECTION]"),
240*56bb7041Schristos     N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
241*56bb7041Schristos   { {"Ur", no_argument, NULL, OPTION_UR},
242*56bb7041Schristos     '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
243*56bb7041Schristos   { {"version", no_argument, NULL, OPTION_VERSION},
244*56bb7041Schristos     'v', NULL, N_("Print version information"), TWO_DASHES },
245*56bb7041Schristos   { {NULL, no_argument, NULL, '\0'},
246*56bb7041Schristos     'V', NULL, N_("Print version and emulation information"), ONE_DASH },
247*56bb7041Schristos   { {"discard-all", no_argument, NULL, 'x'},
248*56bb7041Schristos     'x', NULL, N_("Discard all local symbols"), TWO_DASHES },
249*56bb7041Schristos   { {"discard-locals", no_argument, NULL, 'X'},
250*56bb7041Schristos     'X', NULL, N_("Discard temporary local symbols (default)"), TWO_DASHES },
251*56bb7041Schristos   { {"discard-none", no_argument, NULL, OPTION_DISCARD_NONE},
252*56bb7041Schristos     '\0', NULL, N_("Don't discard any local symbols"), TWO_DASHES },
253*56bb7041Schristos   { {"trace-symbol", required_argument, NULL, 'y'},
254*56bb7041Schristos     'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
255*56bb7041Schristos   { {NULL, required_argument, NULL, '\0'},
256*56bb7041Schristos     'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
257*56bb7041Schristos     ONE_DASH },
258*56bb7041Schristos   { {"start-group", no_argument, NULL, '('},
259*56bb7041Schristos     '(', NULL, N_("Start a group"), TWO_DASHES },
260*56bb7041Schristos   { {"end-group", no_argument, NULL, ')'},
261*56bb7041Schristos     ')', NULL, N_("End a group"), TWO_DASHES },
262*56bb7041Schristos   { {"accept-unknown-input-arch", no_argument, NULL,
263*56bb7041Schristos      OPTION_ACCEPT_UNKNOWN_INPUT_ARCH},
264*56bb7041Schristos     '\0', NULL,
265*56bb7041Schristos     N_("Accept input files whose architecture cannot be determined"),
266*56bb7041Schristos     TWO_DASHES },
267*56bb7041Schristos   { {"no-accept-unknown-input-arch", no_argument, NULL,
268*56bb7041Schristos      OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
269*56bb7041Schristos     '\0', NULL, N_("Reject input files whose architecture is unknown"),
270*56bb7041Schristos     TWO_DASHES },
271*56bb7041Schristos 
272*56bb7041Schristos   /* The next two options are deprecated because of their similarity to
273*56bb7041Schristos      --as-needed and --no-as-needed.  They have been replaced by
274*56bb7041Schristos      --copy-dt-needed-entries and --no-copy-dt-needed-entries.  */
275*56bb7041Schristos   { {"add-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
276*56bb7041Schristos     '\0', NULL, NULL, NO_HELP },
277*56bb7041Schristos   { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
278*56bb7041Schristos     '\0', NULL, NULL, NO_HELP },
279*56bb7041Schristos 
280*56bb7041Schristos   { {"as-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_REGULAR},
281*56bb7041Schristos     '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
282*56bb7041Schristos     TWO_DASHES },
283*56bb7041Schristos   { {"no-as-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR},
284*56bb7041Schristos     '\0', NULL, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
285*56bb7041Schristos 		   "                                the command line"),
286*56bb7041Schristos     TWO_DASHES },
287*56bb7041Schristos   { {"assert", required_argument, NULL, OPTION_ASSERT},
288*56bb7041Schristos     '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
289*56bb7041Schristos   { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
290*56bb7041Schristos     '\0', NULL, N_("Link against shared libraries"), ONE_DASH },
291*56bb7041Schristos   { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
292*56bb7041Schristos     '\0', NULL, NULL, ONE_DASH },
293*56bb7041Schristos   { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
294*56bb7041Schristos     '\0', NULL, NULL, ONE_DASH },
295*56bb7041Schristos   { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
296*56bb7041Schristos     '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
297*56bb7041Schristos   { {"dn", no_argument, NULL, OPTION_NON_SHARED},
298*56bb7041Schristos     '\0', NULL, NULL, ONE_DASH },
299*56bb7041Schristos   { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
300*56bb7041Schristos     '\0', NULL, NULL, ONE_DASH },
301*56bb7041Schristos   { {"static", no_argument, NULL, OPTION_NON_SHARED},
302*56bb7041Schristos     '\0', NULL, NULL, ONE_DASH },
303*56bb7041Schristos   { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
304*56bb7041Schristos     '\0', NULL, N_("Bind global references locally"), ONE_DASH },
305*56bb7041Schristos   { {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS},
306*56bb7041Schristos     '\0', NULL, N_("Bind global function references locally"), ONE_DASH },
307*56bb7041Schristos   { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
308*56bb7041Schristos     '\0', NULL, N_("Check section addresses for overlaps (default)"),
309*56bb7041Schristos     TWO_DASHES },
310*56bb7041Schristos   { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
311*56bb7041Schristos     '\0', NULL, N_("Do not check section addresses for overlaps"),
312*56bb7041Schristos     TWO_DASHES },
313*56bb7041Schristos   { {"copy-dt-needed-entries", no_argument, NULL,
314*56bb7041Schristos      OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
315*56bb7041Schristos     '\0', NULL, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
316*56bb7041Schristos     TWO_DASHES },
317*56bb7041Schristos   { {"no-copy-dt-needed-entries", no_argument, NULL,
318*56bb7041Schristos      OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
319*56bb7041Schristos     '\0', NULL, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
320*56bb7041Schristos     TWO_DASHES },
321*56bb7041Schristos 
322*56bb7041Schristos   { {"cref", no_argument, NULL, OPTION_CREF},
323*56bb7041Schristos     '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
324*56bb7041Schristos   { {"defsym", required_argument, NULL, OPTION_DEFSYM},
325*56bb7041Schristos     '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
326*56bb7041Schristos   { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
327*56bb7041Schristos     '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
328*56bb7041Schristos     TWO_DASHES },
329*56bb7041Schristos   { {"disable-multiple-abs-defs", no_argument, NULL,
330*56bb7041Schristos      OPTION_DISABLE_MULTIPLE_DEFS_ABS},
331*56bb7041Schristos     '\0', NULL, N_("Do not allow multiple definitions with symbols included\n"
332*56bb7041Schristos 		   "           in filename invoked by -R or --just-symbols"),
333*56bb7041Schristos     TWO_DASHES},
334*56bb7041Schristos   { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
335*56bb7041Schristos     '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
336*56bb7041Schristos   { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
337*56bb7041Schristos     '\0', NULL, N_("Treat warnings as errors"),
338*56bb7041Schristos     TWO_DASHES },
339*56bb7041Schristos   { {"no-fatal-warnings", no_argument, NULL, OPTION_NO_WARN_FATAL},
340*56bb7041Schristos     '\0', NULL, N_("Do not treat warnings as errors (default)"),
341*56bb7041Schristos     TWO_DASHES },
342*56bb7041Schristos   { {"fini", required_argument, NULL, OPTION_FINI},
343*56bb7041Schristos     '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
344*56bb7041Schristos   { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
345*56bb7041Schristos     '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
346*56bb7041Schristos   { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
347*56bb7041Schristos     '\0', NULL, N_("Remove unused sections (on some targets)"),
348*56bb7041Schristos     TWO_DASHES },
349*56bb7041Schristos   { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
350*56bb7041Schristos     '\0', NULL, N_("Don't remove unused sections (default)"),
351*56bb7041Schristos     TWO_DASHES },
352*56bb7041Schristos   { {"print-gc-sections", no_argument, NULL, OPTION_PRINT_GC_SECTIONS},
353*56bb7041Schristos     '\0', NULL, N_("List removed unused sections on stderr"),
354*56bb7041Schristos     TWO_DASHES },
355*56bb7041Schristos   { {"no-print-gc-sections", no_argument, NULL, OPTION_NO_PRINT_GC_SECTIONS},
356*56bb7041Schristos     '\0', NULL, N_("Do not list removed unused sections"),
357*56bb7041Schristos     TWO_DASHES },
358*56bb7041Schristos   { {"gc-keep-exported", no_argument, NULL, OPTION_GC_KEEP_EXPORTED},
359*56bb7041Schristos     '\0', NULL, N_("Keep exported symbols when removing unused sections"),
360*56bb7041Schristos     TWO_DASHES },
361*56bb7041Schristos   { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
362*56bb7041Schristos     '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
363*56bb7041Schristos     TWO_DASHES },
364*56bb7041Schristos   { {"help", no_argument, NULL, OPTION_HELP},
365*56bb7041Schristos     '\0', NULL, N_("Print option help"), TWO_DASHES },
366*56bb7041Schristos   { {"init", required_argument, NULL, OPTION_INIT},
367*56bb7041Schristos     '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
368*56bb7041Schristos   { {"Map", required_argument, NULL, OPTION_MAP},
369*56bb7041Schristos     '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH },
370*56bb7041Schristos   { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
371*56bb7041Schristos     '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
372*56bb7041Schristos   { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
373*56bb7041Schristos     '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
374*56bb7041Schristos   { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
375*56bb7041Schristos     '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES },
376*56bb7041Schristos   { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
377*56bb7041Schristos     '\0', NULL, N_("Do not allow unresolved references in object files"),
378*56bb7041Schristos     TWO_DASHES },
379*56bb7041Schristos   { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED},
380*56bb7041Schristos     '\0', NULL, N_("Allow unresolved references in shared libraries"),
381*56bb7041Schristos     TWO_DASHES },
382*56bb7041Schristos   { {"no-allow-shlib-undefined", no_argument, NULL,
383*56bb7041Schristos      OPTION_NO_ALLOW_SHLIB_UNDEFINED},
384*56bb7041Schristos     '\0', NULL, N_("Do not allow unresolved references in shared libs"),
385*56bb7041Schristos     TWO_DASHES },
386*56bb7041Schristos   { {"allow-multiple-definition", no_argument, NULL,
387*56bb7041Schristos      OPTION_ALLOW_MULTIPLE_DEFINITION},
388*56bb7041Schristos     '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES },
389*56bb7041Schristos   { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
390*56bb7041Schristos     '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
391*56bb7041Schristos   { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER},
392*56bb7041Schristos     '\0', NULL, N_("Create default symbol version"), TWO_DASHES },
393*56bb7041Schristos   { {"default-imported-symver", no_argument, NULL,
394*56bb7041Schristos       OPTION_DEFAULT_IMPORTED_SYMVER},
395*56bb7041Schristos     '\0', NULL, N_("Create default symbol version for imported symbols"),
396*56bb7041Schristos     TWO_DASHES },
397*56bb7041Schristos   { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
398*56bb7041Schristos     '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
399*56bb7041Schristos   { {"no-warn-search-mismatch", no_argument, NULL,
400*56bb7041Schristos      OPTION_NO_WARN_SEARCH_MISMATCH},
401*56bb7041Schristos     '\0', NULL, N_("Don't warn on finding an incompatible library"),
402*56bb7041Schristos     TWO_DASHES},
403*56bb7041Schristos   { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
404*56bb7041Schristos     '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
405*56bb7041Schristos   { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
406*56bb7041Schristos     '\0', NULL, N_("Create an output file even if errors occur"),
407*56bb7041Schristos     TWO_DASHES },
408*56bb7041Schristos   { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
409*56bb7041Schristos     '\0', NULL, NULL, NO_HELP },
410*56bb7041Schristos   { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB},
411*56bb7041Schristos     '\0', NULL, N_("Only use library directories specified on\n"
412*56bb7041Schristos 		   "                                the command line"),
413*56bb7041Schristos     ONE_DASH },
414*56bb7041Schristos   { {"oformat", required_argument, NULL, OPTION_OFORMAT},
415*56bb7041Schristos     '\0', N_("TARGET"), N_("Specify target of output file"),
416*56bb7041Schristos     EXACTLY_TWO_DASHES },
417*56bb7041Schristos   { {"print-output-format", no_argument, NULL, OPTION_PRINT_OUTPUT_FORMAT},
418*56bb7041Schristos     '\0', NULL, N_("Print default output format"), TWO_DASHES },
419*56bb7041Schristos   { {"print-sysroot", no_argument, NULL, OPTION_PRINT_SYSROOT},
420*56bb7041Schristos     '\0', NULL, N_("Print current sysroot"), TWO_DASHES },
421*56bb7041Schristos   { {"qmagic", no_argument, NULL, OPTION_IGNORE},
422*56bb7041Schristos     '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
423*56bb7041Schristos   { {"reduce-memory-overheads", no_argument, NULL,
424*56bb7041Schristos      OPTION_REDUCE_MEMORY_OVERHEADS},
425*56bb7041Schristos     '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
426*56bb7041Schristos     TWO_DASHES },
427*56bb7041Schristos   { {"relax", no_argument, NULL, OPTION_RELAX},
428*56bb7041Schristos     '\0', NULL, N_("Reduce code size by using target specific optimizations"), TWO_DASHES },
429*56bb7041Schristos   { {"no-relax", no_argument, NULL, OPTION_NO_RELAX},
430*56bb7041Schristos     '\0', NULL, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES },
431*56bb7041Schristos   { {"retain-symbols-file", required_argument, NULL,
432*56bb7041Schristos      OPTION_RETAIN_SYMBOLS_FILE},
433*56bb7041Schristos     '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
434*56bb7041Schristos   { {"rpath", required_argument, NULL, OPTION_RPATH},
435*56bb7041Schristos     '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH },
436*56bb7041Schristos   { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
437*56bb7041Schristos     '\0', N_("PATH"), N_("Set link time shared library search path"),
438*56bb7041Schristos     ONE_DASH },
439*56bb7041Schristos   { {"shared", no_argument, NULL, OPTION_SHARED},
440*56bb7041Schristos     '\0', NULL, N_("Create a shared library"), ONE_DASH },
441*56bb7041Schristos   { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD.  */
442*56bb7041Schristos     '\0', NULL, NULL, ONE_DASH },
443*56bb7041Schristos   { {"pie", no_argument, NULL, OPTION_PIE},
444*56bb7041Schristos     '\0', NULL, N_("Create a position independent executable"), ONE_DASH },
445*56bb7041Schristos   { {"pic-executable", no_argument, NULL, OPTION_PIE},
446*56bb7041Schristos     '\0', NULL, NULL, TWO_DASHES },
447*56bb7041Schristos   { {"sort-common", optional_argument, NULL, OPTION_SORT_COMMON},
448*56bb7041Schristos     '\0', N_("[=ascending|descending]"),
449*56bb7041Schristos     N_("Sort common symbols by alignment [in specified order]"),
450*56bb7041Schristos     TWO_DASHES },
451*56bb7041Schristos   { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
452*56bb7041Schristos     '\0', NULL, NULL, NO_HELP },
453*56bb7041Schristos   { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
454*56bb7041Schristos     '\0', N_("name|alignment"),
455*56bb7041Schristos     N_("Sort sections by name or maximum alignment"), TWO_DASHES },
456*56bb7041Schristos   { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
457*56bb7041Schristos     '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
458*56bb7041Schristos     TWO_DASHES },
459*56bb7041Schristos   { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE},
460*56bb7041Schristos     '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
461*56bb7041Schristos     TWO_DASHES },
462*56bb7041Schristos   { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC},
463*56bb7041Schristos     '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
464*56bb7041Schristos     TWO_DASHES },
465*56bb7041Schristos   { {"stats", no_argument, NULL, OPTION_STATS},
466*56bb7041Schristos     '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
467*56bb7041Schristos   { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
468*56bb7041Schristos     '\0', NULL, N_("Display target specific options"), TWO_DASHES },
469*56bb7041Schristos   { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
470*56bb7041Schristos     '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
471*56bb7041Schristos   { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
472*56bb7041Schristos     '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
473*56bb7041Schristos   { {"section-start", required_argument, NULL, OPTION_SECTION_START},
474*56bb7041Schristos     '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
475*56bb7041Schristos     TWO_DASHES },
476*56bb7041Schristos   { {"Tbss", required_argument, NULL, OPTION_TBSS},
477*56bb7041Schristos     '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
478*56bb7041Schristos   { {"Tdata", required_argument, NULL, OPTION_TDATA},
479*56bb7041Schristos     '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
480*56bb7041Schristos   { {"Ttext", required_argument, NULL, OPTION_TTEXT},
481*56bb7041Schristos     '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
482*56bb7041Schristos   { {"Ttext-segment", required_argument, NULL, OPTION_TTEXT_SEGMENT},
483*56bb7041Schristos     '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH },
484*56bb7041Schristos   { {"Trodata-segment", required_argument, NULL, OPTION_TRODATA_SEGMENT},
485*56bb7041Schristos     '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH },
486*56bb7041Schristos   { {"Tldata-segment", required_argument, NULL, OPTION_TLDATA_SEGMENT},
487*56bb7041Schristos     '\0', N_("ADDRESS"), N_("Set address of ldata segment"), ONE_DASH },
488*56bb7041Schristos   { {"unresolved-symbols=<method>", required_argument, NULL,
489*56bb7041Schristos      OPTION_UNRESOLVED_SYMBOLS},
490*56bb7041Schristos     '\0', NULL, N_("How to handle unresolved symbols.  <method> is:\n"
491*56bb7041Schristos 		   "                                ignore-all, report-all, ignore-in-object-files,\n"
492*56bb7041Schristos 		   "                                ignore-in-shared-libs"),
493*56bb7041Schristos     TWO_DASHES },
494*56bb7041Schristos   { {"verbose", optional_argument, NULL, OPTION_VERBOSE},
495*56bb7041Schristos     '\0', N_("[=NUMBER]"),
496*56bb7041Schristos     N_("Output lots of information during link"), TWO_DASHES },
497*56bb7041Schristos   { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux.  */
498*56bb7041Schristos     '\0', NULL, NULL, NO_HELP },
499*56bb7041Schristos   { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
500*56bb7041Schristos     '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
501*56bb7041Schristos   { {"version-exports-section", required_argument, NULL,
502*56bb7041Schristos      OPTION_VERSION_EXPORTS_SECTION },
503*56bb7041Schristos     '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
504*56bb7041Schristos 			   "                                SYMBOL as the version."),
505*56bb7041Schristos     TWO_DASHES },
506*56bb7041Schristos   { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
507*56bb7041Schristos     '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
508*56bb7041Schristos   { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
509*56bb7041Schristos     '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES },
510*56bb7041Schristos   { {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
511*56bb7041Schristos     '\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
512*56bb7041Schristos   { {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
513*56bb7041Schristos     '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
514*56bb7041Schristos   { {"export-dynamic-symbol", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL},
515*56bb7041Schristos     '\0', N_("SYMBOL"), N_("Export the specified symbol"), EXACTLY_TWO_DASHES },
516*56bb7041Schristos   { {"export-dynamic-symbol-list", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL_LIST},
517*56bb7041Schristos     '\0', N_("FILE"), N_("Read export dynamic symbol list"), EXACTLY_TWO_DASHES },
518*56bb7041Schristos   { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
519*56bb7041Schristos     '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
520*56bb7041Schristos   { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
521*56bb7041Schristos     '\0', NULL, N_("Warn if global constructors/destructors are seen"),
522*56bb7041Schristos     TWO_DASHES },
523*56bb7041Schristos   { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
524*56bb7041Schristos     '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
525*56bb7041Schristos   { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
526*56bb7041Schristos     '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
527*56bb7041Schristos   { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
528*56bb7041Schristos     '\0', NULL, N_("Warn if start of section changes due to alignment"),
529*56bb7041Schristos     TWO_DASHES },
530*56bb7041Schristos   { {"warn-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
531*56bb7041Schristos     '\0', NULL,
532*56bb7041Schristos #if DEFAULT_LD_TEXTREL_CHECK_WARNING
533*56bb7041Schristos     N_("Warn if output has DT_TEXTREL (default)"),
534*56bb7041Schristos #else
535*56bb7041Schristos     N_("Warn if output has DT_TEXTREL"),
536*56bb7041Schristos #endif
537*56bb7041Schristos     TWO_DASHES },
538*56bb7041Schristos   { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
539*56bb7041Schristos     '\0', NULL, NULL, NO_HELP },
540*56bb7041Schristos   { {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM},
541*56bb7041Schristos     '\0', NULL, N_("Warn if an object has alternate ELF machine code"),
542*56bb7041Schristos     TWO_DASHES },
543*56bb7041Schristos   { {"warn-unresolved-symbols", no_argument, NULL,
544*56bb7041Schristos      OPTION_WARN_UNRESOLVED_SYMBOLS},
545*56bb7041Schristos     '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
546*56bb7041Schristos   { {"error-unresolved-symbols", no_argument, NULL,
547*56bb7041Schristos      OPTION_ERROR_UNRESOLVED_SYMBOLS},
548*56bb7041Schristos     '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES },
549*56bb7041Schristos   { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
550*56bb7041Schristos     '\0', NULL, N_("Include all objects from following archives"),
551*56bb7041Schristos     TWO_DASHES },
552*56bb7041Schristos   { {"wrap", required_argument, NULL, OPTION_WRAP},
553*56bb7041Schristos     '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
554*56bb7041Schristos   { {"ignore-unresolved-symbol", required_argument, NULL,
555*56bb7041Schristos     OPTION_IGNORE_UNRESOLVED_SYMBOL},
556*56bb7041Schristos     '\0', N_("SYMBOL"),
557*56bb7041Schristos     N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
558*56bb7041Schristos   { {"push-state", no_argument, NULL, OPTION_PUSH_STATE},
559*56bb7041Schristos     '\0', NULL, N_("Push state of flags governing input file handling"),
560*56bb7041Schristos     TWO_DASHES },
561*56bb7041Schristos   { {"pop-state", no_argument, NULL, OPTION_POP_STATE},
562*56bb7041Schristos     '\0', NULL, N_("Pop state of flags governing input file handling"),
563*56bb7041Schristos     TWO_DASHES },
564*56bb7041Schristos   { {"print-memory-usage", no_argument, NULL, OPTION_PRINT_MEMORY_USAGE},
565*56bb7041Schristos     '\0', NULL, N_("Report target memory usage"), TWO_DASHES },
566*56bb7041Schristos   { {"orphan-handling", required_argument, NULL, OPTION_ORPHAN_HANDLING},
567*56bb7041Schristos     '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
568*56bb7041Schristos     TWO_DASHES },
569*56bb7041Schristos   { {"print-map-discarded", no_argument, NULL, OPTION_PRINT_MAP_DISCARDED},
570*56bb7041Schristos     '\0', NULL, N_("Show discarded sections in map file output (default)"),
571*56bb7041Schristos     TWO_DASHES },
572*56bb7041Schristos   { {"no-print-map-discarded", no_argument, NULL, OPTION_NO_PRINT_MAP_DISCARDED},
573*56bb7041Schristos     '\0', NULL, N_("Do not show discarded sections in map file output"),
574*56bb7041Schristos     TWO_DASHES },
575*56bb7041Schristos   { {"ctf-variables", no_argument, NULL, OPTION_CTF_VARIABLES},
576*56bb7041Schristos     '\0', NULL, N_("Emit names and types of static variables in CTF"),
577*56bb7041Schristos     TWO_DASHES },
578*56bb7041Schristos   { {"no-ctf-variables", no_argument, NULL, OPTION_NO_CTF_VARIABLES},
579*56bb7041Schristos     '\0', NULL, N_("Do not emit names and types of static variables in CTF"),
580*56bb7041Schristos     TWO_DASHES },
581*56bb7041Schristos   { {"ctf-share-types=<method>", required_argument, NULL,
582*56bb7041Schristos      OPTION_CTF_SHARE_TYPES},
583*56bb7041Schristos     '\0', NULL, N_("How to share CTF types between translation units.\n"
584*56bb7041Schristos 		   "                                <method> is: share-unconflicted (default),\n"
585*56bb7041Schristos 		   "                                             share-duplicated"),
586*56bb7041Schristos     TWO_DASHES },
587*56bb7041Schristos };
588*56bb7041Schristos 
589*56bb7041Schristos #define OPTION_COUNT ARRAY_SIZE (ld_options)
590*56bb7041Schristos 
591*56bb7041Schristos void
parse_args(unsigned argc,char ** argv)592*56bb7041Schristos parse_args (unsigned argc, char **argv)
593*56bb7041Schristos {
594*56bb7041Schristos   unsigned i;
595*56bb7041Schristos   int is, il, irl;
596*56bb7041Schristos   int ingroup = 0;
597*56bb7041Schristos   char *default_dirlist = NULL;
598*56bb7041Schristos   char *shortopts;
599*56bb7041Schristos   struct option *longopts;
600*56bb7041Schristos   struct option *really_longopts;
601*56bb7041Schristos   int last_optind;
602*56bb7041Schristos   enum symbolic_enum
603*56bb7041Schristos   {
604*56bb7041Schristos     symbolic_unset = 0,
605*56bb7041Schristos     symbolic,
606*56bb7041Schristos     symbolic_functions,
607*56bb7041Schristos   } opt_symbolic = symbolic_unset;
608*56bb7041Schristos   enum dynamic_list_enum
609*56bb7041Schristos   {
610*56bb7041Schristos     dynamic_list_unset = 0,
611*56bb7041Schristos     dynamic_list_data,
612*56bb7041Schristos     dynamic_list
613*56bb7041Schristos   } opt_dynamic_list = dynamic_list_unset;
614*56bb7041Schristos   struct bfd_elf_dynamic_list *export_list = NULL;
615*56bb7041Schristos 
616*56bb7041Schristos   shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
617*56bb7041Schristos   longopts = (struct option *)
618*56bb7041Schristos       xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
619*56bb7041Schristos   really_longopts = (struct option *)
620*56bb7041Schristos       xmalloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
621*56bb7041Schristos 
622*56bb7041Schristos   /* Starting the short option string with '-' is for programs that
623*56bb7041Schristos      expect options and other ARGV-elements in any order and that care about
624*56bb7041Schristos      the ordering of the two.  We describe each non-option ARGV-element
625*56bb7041Schristos      as if it were the argument of an option with character code 1.  */
626*56bb7041Schristos   shortopts[0] = '-';
627*56bb7041Schristos   is = 1;
628*56bb7041Schristos   il = 0;
629*56bb7041Schristos   irl = 0;
630*56bb7041Schristos   for (i = 0; i < OPTION_COUNT; i++)
631*56bb7041Schristos     {
632*56bb7041Schristos       if (ld_options[i].shortopt != '\0')
633*56bb7041Schristos 	{
634*56bb7041Schristos 	  shortopts[is] = ld_options[i].shortopt;
635*56bb7041Schristos 	  ++is;
636*56bb7041Schristos 	  if (ld_options[i].opt.has_arg == required_argument
637*56bb7041Schristos 	      || ld_options[i].opt.has_arg == optional_argument)
638*56bb7041Schristos 	    {
639*56bb7041Schristos 	      shortopts[is] = ':';
640*56bb7041Schristos 	      ++is;
641*56bb7041Schristos 	      if (ld_options[i].opt.has_arg == optional_argument)
642*56bb7041Schristos 		{
643*56bb7041Schristos 		  shortopts[is] = ':';
644*56bb7041Schristos 		  ++is;
645*56bb7041Schristos 		}
646*56bb7041Schristos 	    }
647*56bb7041Schristos 	}
648*56bb7041Schristos       if (ld_options[i].opt.name != NULL)
649*56bb7041Schristos 	{
650*56bb7041Schristos 	  if (ld_options[i].control == EXACTLY_TWO_DASHES)
651*56bb7041Schristos 	    {
652*56bb7041Schristos 	      really_longopts[irl] = ld_options[i].opt;
653*56bb7041Schristos 	      ++irl;
654*56bb7041Schristos 	    }
655*56bb7041Schristos 	  else
656*56bb7041Schristos 	    {
657*56bb7041Schristos 	      longopts[il] = ld_options[i].opt;
658*56bb7041Schristos 	      ++il;
659*56bb7041Schristos 	    }
660*56bb7041Schristos 	}
661*56bb7041Schristos     }
662*56bb7041Schristos   shortopts[is] = '\0';
663*56bb7041Schristos   longopts[il].name = NULL;
664*56bb7041Schristos   really_longopts[irl].name = NULL;
665*56bb7041Schristos 
666*56bb7041Schristos   ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
667*56bb7041Schristos 
668*56bb7041Schristos   /* The -G option is ambiguous on different platforms.  Sometimes it
669*56bb7041Schristos      specifies the largest data size to put into the small data
670*56bb7041Schristos      section.  Sometimes it is equivalent to --shared.  Unfortunately,
671*56bb7041Schristos      the first form takes an argument, while the second does not.
672*56bb7041Schristos 
673*56bb7041Schristos      We need to permit the --shared form because on some platforms,
674*56bb7041Schristos      such as Solaris, gcc -shared will pass -G to the linker.
675*56bb7041Schristos 
676*56bb7041Schristos      To permit either usage, we look through the argument list.  If we
677*56bb7041Schristos      find -G not followed by a number, we change it into --shared.
678*56bb7041Schristos      This will work for most normal cases.  */
679*56bb7041Schristos   for (i = 1; i < argc; i++)
680*56bb7041Schristos     if (strcmp (argv[i], "-G") == 0
681*56bb7041Schristos 	&& (i + 1 >= argc
682*56bb7041Schristos 	    || ! ISDIGIT (argv[i + 1][0])))
683*56bb7041Schristos       argv[i] = (char *) "--shared";
684*56bb7041Schristos 
685*56bb7041Schristos   /* Because we permit long options to start with a single dash, and
686*56bb7041Schristos      we have a --library option, and the -l option is conventionally
687*56bb7041Schristos      used with an immediately following argument, we can have bad
688*56bb7041Schristos      results if somebody tries to use -l with a library whose name
689*56bb7041Schristos      happens to start with "ibrary", as in -li.  We avoid problems by
690*56bb7041Schristos      simply turning -l into --library.  This means that users will
691*56bb7041Schristos      have to use two dashes in order to use --library, which is OK
692*56bb7041Schristos      since that's how it is documented.
693*56bb7041Schristos 
694*56bb7041Schristos      FIXME: It's possible that this problem can arise for other short
695*56bb7041Schristos      options as well, although the user does always have the recourse
696*56bb7041Schristos      of adding a space between the option and the argument.  */
697*56bb7041Schristos   for (i = 1; i < argc; i++)
698*56bb7041Schristos     {
699*56bb7041Schristos       if (argv[i][0] == '-'
700*56bb7041Schristos 	  && argv[i][1] == 'l'
701*56bb7041Schristos 	  && argv[i][2] != '\0')
702*56bb7041Schristos 	{
703*56bb7041Schristos 	  char *n;
704*56bb7041Schristos 
705*56bb7041Schristos 	  n = (char *) xmalloc (strlen (argv[i]) + 20);
706*56bb7041Schristos 	  sprintf (n, "--library=%s", argv[i] + 2);
707*56bb7041Schristos 	  argv[i] = n;
708*56bb7041Schristos 	}
709*56bb7041Schristos     }
710*56bb7041Schristos 
711*56bb7041Schristos   last_optind = -1;
712*56bb7041Schristos   while (1)
713*56bb7041Schristos     {
714*56bb7041Schristos       int longind;
715*56bb7041Schristos       int optc;
716*56bb7041Schristos       static unsigned int defsym_count;
717*56bb7041Schristos 
718*56bb7041Schristos       /* Using last_optind lets us avoid calling ldemul_parse_args
719*56bb7041Schristos 	 multiple times on a single option, which would lead to
720*56bb7041Schristos 	 confusion in the internal static variables maintained by
721*56bb7041Schristos 	 getopt.  This could otherwise happen for an argument like
722*56bb7041Schristos 	 -nx, in which the -n is parsed as a single option, and we
723*56bb7041Schristos 	 loop around to pick up the -x.  */
724*56bb7041Schristos       if (optind != last_optind)
725*56bb7041Schristos 	if (ldemul_parse_args (argc, argv))
726*56bb7041Schristos 	  continue;
727*56bb7041Schristos 
728*56bb7041Schristos       /* getopt_long_only is like getopt_long, but '-' as well as '--'
729*56bb7041Schristos 	 can indicate a long option.  */
730*56bb7041Schristos       opterr = 0;
731*56bb7041Schristos       last_optind = optind;
732*56bb7041Schristos       optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
733*56bb7041Schristos       if (optc == '?')
734*56bb7041Schristos 	{
735*56bb7041Schristos 	  optind = last_optind;
736*56bb7041Schristos 	  optc = getopt_long (argc, argv, "-", really_longopts, &longind);
737*56bb7041Schristos 	}
738*56bb7041Schristos 
739*56bb7041Schristos       if (ldemul_handle_option (optc))
740*56bb7041Schristos 	continue;
741*56bb7041Schristos 
742*56bb7041Schristos       if (optc == -1)
743*56bb7041Schristos 	break;
744*56bb7041Schristos 
745*56bb7041Schristos       switch (optc)
746*56bb7041Schristos 	{
747*56bb7041Schristos 	case '?':
748*56bb7041Schristos 	  {
749*56bb7041Schristos 	    /* If the last word on the command line is an option that
750*56bb7041Schristos 	       requires an argument, getopt will refuse to recognise it.
751*56bb7041Schristos 	       Try to catch such options here and issue a more helpful
752*56bb7041Schristos 	       error message than just "unrecognized option".  */
753*56bb7041Schristos 	    int opt;
754*56bb7041Schristos 
755*56bb7041Schristos 	    for (opt = ARRAY_SIZE (ld_options); opt--;)
756*56bb7041Schristos 	      if (ld_options[opt].opt.has_arg == required_argument
757*56bb7041Schristos 		  /* FIXME: There are a few short options that do not
758*56bb7041Schristos 		     have long equivalents, but which require arguments.
759*56bb7041Schristos 		     We should handle them too.  */
760*56bb7041Schristos 		  && ld_options[opt].opt.name != NULL
761*56bb7041Schristos 		  && strcmp (argv[last_optind] + ld_options[opt].control, ld_options[opt].opt.name) == 0)
762*56bb7041Schristos 		{
763*56bb7041Schristos 		  einfo (_("%P: %s: missing argument\n"), argv[last_optind]);
764*56bb7041Schristos 		  break;
765*56bb7041Schristos 		}
766*56bb7041Schristos 
767*56bb7041Schristos 	    if (opt == -1)
768*56bb7041Schristos 	      einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
769*56bb7041Schristos 	  }
770*56bb7041Schristos 	  /* Fall through.  */
771*56bb7041Schristos 
772*56bb7041Schristos 	default:
773*56bb7041Schristos 	  einfo (_("%F%P: use the --help option for usage information\n"));
774*56bb7041Schristos 	  break;
775*56bb7041Schristos 
776*56bb7041Schristos 	case 1:			/* File name.  */
777*56bb7041Schristos 	  lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL);
778*56bb7041Schristos 	  break;
779*56bb7041Schristos 
780*56bb7041Schristos 	case OPTION_IGNORE:
781*56bb7041Schristos 	  break;
782*56bb7041Schristos 	case 'a':
783*56bb7041Schristos 	  /* For HP/UX compatibility.  Actually -a shared should mean
784*56bb7041Schristos 	     ``use only shared libraries'' but, then, we don't
785*56bb7041Schristos 	     currently support shared libraries on HP/UX anyhow.  */
786*56bb7041Schristos 	  if (strcmp (optarg, "archive") == 0)
787*56bb7041Schristos 	    input_flags.dynamic = FALSE;
788*56bb7041Schristos 	  else if (strcmp (optarg, "shared") == 0
789*56bb7041Schristos 		   || strcmp (optarg, "default") == 0)
790*56bb7041Schristos 	    input_flags.dynamic = TRUE;
791*56bb7041Schristos 	  else
792*56bb7041Schristos 	    einfo (_("%F%P: unrecognized -a option `%s'\n"), optarg);
793*56bb7041Schristos 	  break;
794*56bb7041Schristos 	case OPTION_ASSERT:
795*56bb7041Schristos 	  /* FIXME: We just ignore these, but we should handle them.  */
796*56bb7041Schristos 	  if (strcmp (optarg, "definitions") == 0)
797*56bb7041Schristos 	    ;
798*56bb7041Schristos 	  else if (strcmp (optarg, "nodefinitions") == 0)
799*56bb7041Schristos 	    ;
800*56bb7041Schristos 	  else if (strcmp (optarg, "nosymbolic") == 0)
801*56bb7041Schristos 	    ;
802*56bb7041Schristos 	  else if (strcmp (optarg, "pure-text") == 0)
803*56bb7041Schristos 	    ;
804*56bb7041Schristos 	  else
805*56bb7041Schristos 	    einfo (_("%F%P: unrecognized -assert option `%s'\n"), optarg);
806*56bb7041Schristos 	  break;
807*56bb7041Schristos 	case 'A':
808*56bb7041Schristos 	  ldfile_add_arch (optarg);
809*56bb7041Schristos 	  break;
810*56bb7041Schristos 	case 'b':
811*56bb7041Schristos 	  lang_add_target (optarg);
812*56bb7041Schristos 	  break;
813*56bb7041Schristos 	case 'c':
814*56bb7041Schristos 	  ldfile_open_command_file (optarg);
815*56bb7041Schristos 	  parser_input = input_mri_script;
816*56bb7041Schristos 	  yyparse ();
817*56bb7041Schristos 	  break;
818*56bb7041Schristos 	case OPTION_CALL_SHARED:
819*56bb7041Schristos 	  input_flags.dynamic = TRUE;
820*56bb7041Schristos 	  break;
821*56bb7041Schristos 	case OPTION_NON_SHARED:
822*56bb7041Schristos 	  input_flags.dynamic = FALSE;
823*56bb7041Schristos 	  break;
824*56bb7041Schristos 	case OPTION_CREF:
825*56bb7041Schristos 	  command_line.cref = TRUE;
826*56bb7041Schristos 	  link_info.notice_all = TRUE;
827*56bb7041Schristos 	  break;
828*56bb7041Schristos 	case 'd':
829*56bb7041Schristos 	  command_line.force_common_definition = TRUE;
830*56bb7041Schristos 	  break;
831*56bb7041Schristos 	case OPTION_FORCE_GROUP_ALLOCATION:
832*56bb7041Schristos 	  command_line.force_group_allocation = TRUE;
833*56bb7041Schristos 	  break;
834*56bb7041Schristos 	case OPTION_DEFSYM:
835*56bb7041Schristos 	  lex_string = optarg;
836*56bb7041Schristos 	  lex_redirect (optarg, "--defsym", ++defsym_count);
837*56bb7041Schristos 	  parser_input = input_defsym;
838*56bb7041Schristos 	  yyparse ();
839*56bb7041Schristos 	  lex_string = NULL;
840*56bb7041Schristos 	  break;
841*56bb7041Schristos 	case OPTION_DEMANGLE:
842*56bb7041Schristos 	  demangling = TRUE;
843*56bb7041Schristos 	  if (optarg != NULL)
844*56bb7041Schristos 	    {
845*56bb7041Schristos 	      enum demangling_styles style;
846*56bb7041Schristos 
847*56bb7041Schristos 	      style = cplus_demangle_name_to_style (optarg);
848*56bb7041Schristos 	      if (style == unknown_demangling)
849*56bb7041Schristos 		einfo (_("%F%P: unknown demangling style `%s'\n"),
850*56bb7041Schristos 		       optarg);
851*56bb7041Schristos 
852*56bb7041Schristos 	      cplus_demangle_set_style (style);
853*56bb7041Schristos 	    }
854*56bb7041Schristos 	  break;
855*56bb7041Schristos 	case 'I':		/* Used on Solaris.  */
856*56bb7041Schristos 	case OPTION_DYNAMIC_LINKER:
857*56bb7041Schristos 	  command_line.interpreter = optarg;
858*56bb7041Schristos 	  link_info.nointerp = 0;
859*56bb7041Schristos 	  break;
860*56bb7041Schristos 	case OPTION_NO_DYNAMIC_LINKER:
861*56bb7041Schristos 	  link_info.nointerp = 1;
862*56bb7041Schristos 	  break;
863*56bb7041Schristos 	case OPTION_SYSROOT:
864*56bb7041Schristos 	  /* Already handled in ldmain.c.  */
865*56bb7041Schristos 	  break;
866*56bb7041Schristos 	case OPTION_EB:
867*56bb7041Schristos 	  command_line.endian = ENDIAN_BIG;
868*56bb7041Schristos 	  break;
869*56bb7041Schristos 	case OPTION_EL:
870*56bb7041Schristos 	  command_line.endian = ENDIAN_LITTLE;
871*56bb7041Schristos 	  break;
872*56bb7041Schristos 	case OPTION_EMBEDDED_RELOCS:
873*56bb7041Schristos 	  command_line.embedded_relocs = TRUE;
874*56bb7041Schristos 	  break;
875*56bb7041Schristos 	case OPTION_EXPORT_DYNAMIC:
876*56bb7041Schristos 	case 'E': /* HP/UX compatibility.  */
877*56bb7041Schristos 	  link_info.export_dynamic = TRUE;
878*56bb7041Schristos 	  break;
879*56bb7041Schristos 	case OPTION_NO_EXPORT_DYNAMIC:
880*56bb7041Schristos 	  link_info.export_dynamic = FALSE;
881*56bb7041Schristos 	  break;
882*56bb7041Schristos 	case OPTION_NON_CONTIGUOUS_REGIONS:
883*56bb7041Schristos 	  link_info.non_contiguous_regions = TRUE;
884*56bb7041Schristos 	  break;
885*56bb7041Schristos 	case OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS:
886*56bb7041Schristos 	  link_info.non_contiguous_regions_warnings = TRUE;
887*56bb7041Schristos 	  break;
888*56bb7041Schristos 	case 'e':
889*56bb7041Schristos 	  lang_add_entry (optarg, TRUE);
890*56bb7041Schristos 	  break;
891*56bb7041Schristos 	case 'f':
892*56bb7041Schristos 	  if (command_line.auxiliary_filters == NULL)
893*56bb7041Schristos 	    {
894*56bb7041Schristos 	      command_line.auxiliary_filters = (char **)
895*56bb7041Schristos 		xmalloc (2 * sizeof (char *));
896*56bb7041Schristos 	      command_line.auxiliary_filters[0] = optarg;
897*56bb7041Schristos 	      command_line.auxiliary_filters[1] = NULL;
898*56bb7041Schristos 	    }
899*56bb7041Schristos 	  else
900*56bb7041Schristos 	    {
901*56bb7041Schristos 	      int c;
902*56bb7041Schristos 	      char **p;
903*56bb7041Schristos 
904*56bb7041Schristos 	      c = 0;
905*56bb7041Schristos 	      for (p = command_line.auxiliary_filters; *p != NULL; p++)
906*56bb7041Schristos 		++c;
907*56bb7041Schristos 	      command_line.auxiliary_filters = (char **)
908*56bb7041Schristos 		xrealloc (command_line.auxiliary_filters,
909*56bb7041Schristos 			  (c + 2) * sizeof (char *));
910*56bb7041Schristos 	      command_line.auxiliary_filters[c] = optarg;
911*56bb7041Schristos 	      command_line.auxiliary_filters[c + 1] = NULL;
912*56bb7041Schristos 	    }
913*56bb7041Schristos 	  break;
914*56bb7041Schristos 	case 'F':
915*56bb7041Schristos 	  command_line.filter_shlib = optarg;
916*56bb7041Schristos 	  break;
917*56bb7041Schristos 	case OPTION_FORCE_EXE_SUFFIX:
918*56bb7041Schristos 	  command_line.force_exe_suffix = TRUE;
919*56bb7041Schristos 	  break;
920*56bb7041Schristos 	case 'G':
921*56bb7041Schristos 	  {
922*56bb7041Schristos 	    char *end;
923*56bb7041Schristos 	    g_switch_value = strtoul (optarg, &end, 0);
924*56bb7041Schristos 	    if (*end)
925*56bb7041Schristos 	      einfo (_("%F%P: invalid number `%s'\n"), optarg);
926*56bb7041Schristos 	  }
927*56bb7041Schristos 	  break;
928*56bb7041Schristos 	case 'g':
929*56bb7041Schristos 	  /* Ignore.  */
930*56bb7041Schristos 	  break;
931*56bb7041Schristos 	case OPTION_GC_SECTIONS:
932*56bb7041Schristos 	  link_info.gc_sections = TRUE;
933*56bb7041Schristos 	  break;
934*56bb7041Schristos 	case OPTION_PRINT_GC_SECTIONS:
935*56bb7041Schristos 	  link_info.print_gc_sections = TRUE;
936*56bb7041Schristos 	  break;
937*56bb7041Schristos 	case OPTION_GC_KEEP_EXPORTED:
938*56bb7041Schristos 	  link_info.gc_keep_exported = TRUE;
939*56bb7041Schristos 	  break;
940*56bb7041Schristos 	case OPTION_HELP:
941*56bb7041Schristos 	  help ();
942*56bb7041Schristos 	  xexit (0);
943*56bb7041Schristos 	  break;
944*56bb7041Schristos 	case 'L':
945*56bb7041Schristos 	  ldfile_add_library_path (optarg, TRUE);
946*56bb7041Schristos 	  break;
947*56bb7041Schristos 	case 'l':
948*56bb7041Schristos 	  lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL);
949*56bb7041Schristos 	  break;
950*56bb7041Schristos 	case 'M':
951*56bb7041Schristos 	  config.map_filename = "-";
952*56bb7041Schristos 	  break;
953*56bb7041Schristos 	case 'm':
954*56bb7041Schristos 	  /* Ignore.  Was handled in a pre-parse.   */
955*56bb7041Schristos 	  break;
956*56bb7041Schristos 	case OPTION_MAP:
957*56bb7041Schristos 	  config.map_filename = optarg;
958*56bb7041Schristos 	  break;
959*56bb7041Schristos 	case 'N':
960*56bb7041Schristos 	  config.text_read_only = FALSE;
961*56bb7041Schristos 	  config.magic_demand_paged = FALSE;
962*56bb7041Schristos 	  input_flags.dynamic = FALSE;
963*56bb7041Schristos 	  break;
964*56bb7041Schristos 	case OPTION_NO_OMAGIC:
965*56bb7041Schristos 	  config.text_read_only = TRUE;
966*56bb7041Schristos 	  config.magic_demand_paged = TRUE;
967*56bb7041Schristos 	  /* NB/ Does not set input_flags.dynamic to TRUE.
968*56bb7041Schristos 	     Use --call-shared or -Bdynamic for this.  */
969*56bb7041Schristos 	  break;
970*56bb7041Schristos 	case 'n':
971*56bb7041Schristos 	  config.text_read_only = TRUE;
972*56bb7041Schristos 	  config.magic_demand_paged = FALSE;
973*56bb7041Schristos 	  input_flags.dynamic = FALSE;
974*56bb7041Schristos 	  break;
975*56bb7041Schristos 	case OPTION_NO_DEFINE_COMMON:
976*56bb7041Schristos 	  link_info.inhibit_common_definition = TRUE;
977*56bb7041Schristos 	  break;
978*56bb7041Schristos 	case OPTION_NO_DEMANGLE:
979*56bb7041Schristos 	  demangling = FALSE;
980*56bb7041Schristos 	  break;
981*56bb7041Schristos 	case OPTION_NO_GC_SECTIONS:
982*56bb7041Schristos 	  link_info.gc_sections = FALSE;
983*56bb7041Schristos 	  break;
984*56bb7041Schristos 	case OPTION_NO_PRINT_GC_SECTIONS:
985*56bb7041Schristos 	  link_info.print_gc_sections = FALSE;
986*56bb7041Schristos 	  break;
987*56bb7041Schristos 	case OPTION_NO_KEEP_MEMORY:
988*56bb7041Schristos 	  link_info.keep_memory = FALSE;
989*56bb7041Schristos 	  break;
990*56bb7041Schristos 	case OPTION_NO_UNDEFINED:
991*56bb7041Schristos 	  link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
992*56bb7041Schristos 	  break;
993*56bb7041Schristos 	case OPTION_ALLOW_SHLIB_UNDEFINED:
994*56bb7041Schristos 	  link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
995*56bb7041Schristos 	  break;
996*56bb7041Schristos 	case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
997*56bb7041Schristos 	  link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
998*56bb7041Schristos 	  break;
999*56bb7041Schristos 	case OPTION_UNRESOLVED_SYMBOLS:
1000*56bb7041Schristos 	  if (strcmp (optarg, "ignore-all") == 0)
1001*56bb7041Schristos 	    {
1002*56bb7041Schristos 	      link_info.unresolved_syms_in_objects = RM_IGNORE;
1003*56bb7041Schristos 	      link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1004*56bb7041Schristos 	    }
1005*56bb7041Schristos 	  else if (strcmp (optarg, "report-all") == 0)
1006*56bb7041Schristos 	    {
1007*56bb7041Schristos 	      link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
1008*56bb7041Schristos 	      link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
1009*56bb7041Schristos 	    }
1010*56bb7041Schristos 	  else if (strcmp (optarg, "ignore-in-object-files") == 0)
1011*56bb7041Schristos 	    {
1012*56bb7041Schristos 	      link_info.unresolved_syms_in_objects = RM_IGNORE;
1013*56bb7041Schristos 	      link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
1014*56bb7041Schristos 	    }
1015*56bb7041Schristos 	  else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
1016*56bb7041Schristos 	    {
1017*56bb7041Schristos 	      link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
1018*56bb7041Schristos 	      link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1019*56bb7041Schristos 	    }
1020*56bb7041Schristos 	  else
1021*56bb7041Schristos 	    einfo (_("%F%P: bad --unresolved-symbols option: %s\n"), optarg);
1022*56bb7041Schristos 	  break;
1023*56bb7041Schristos 	case OPTION_WARN_UNRESOLVED_SYMBOLS:
1024*56bb7041Schristos 	  link_info.warn_unresolved_syms = TRUE;
1025*56bb7041Schristos 	  break;
1026*56bb7041Schristos 	case OPTION_ERROR_UNRESOLVED_SYMBOLS:
1027*56bb7041Schristos 	  link_info.warn_unresolved_syms = FALSE;
1028*56bb7041Schristos 	  break;
1029*56bb7041Schristos 	case OPTION_ALLOW_MULTIPLE_DEFINITION:
1030*56bb7041Schristos 	  link_info.allow_multiple_definition = TRUE;
1031*56bb7041Schristos 	  break;
1032*56bb7041Schristos 	case OPTION_NO_UNDEFINED_VERSION:
1033*56bb7041Schristos 	  link_info.allow_undefined_version = FALSE;
1034*56bb7041Schristos 	  break;
1035*56bb7041Schristos 	case OPTION_DEFAULT_SYMVER:
1036*56bb7041Schristos 	  link_info.create_default_symver = TRUE;
1037*56bb7041Schristos 	  break;
1038*56bb7041Schristos 	case OPTION_DEFAULT_IMPORTED_SYMVER:
1039*56bb7041Schristos 	  link_info.default_imported_symver = TRUE;
1040*56bb7041Schristos 	  break;
1041*56bb7041Schristos 	case OPTION_NO_WARN_MISMATCH:
1042*56bb7041Schristos 	  command_line.warn_mismatch = FALSE;
1043*56bb7041Schristos 	  break;
1044*56bb7041Schristos 	case OPTION_NO_WARN_SEARCH_MISMATCH:
1045*56bb7041Schristos 	  command_line.warn_search_mismatch = FALSE;
1046*56bb7041Schristos 	  break;
1047*56bb7041Schristos 	case OPTION_NOINHIBIT_EXEC:
1048*56bb7041Schristos 	  force_make_executable = TRUE;
1049*56bb7041Schristos 	  break;
1050*56bb7041Schristos 	case OPTION_NOSTDLIB:
1051*56bb7041Schristos 	  config.only_cmd_line_lib_dirs = TRUE;
1052*56bb7041Schristos 	  break;
1053*56bb7041Schristos 	case OPTION_NO_WHOLE_ARCHIVE:
1054*56bb7041Schristos 	  input_flags.whole_archive = FALSE;
1055*56bb7041Schristos 	  break;
1056*56bb7041Schristos 	case 'O':
1057*56bb7041Schristos 	  /* FIXME "-O<non-digits> <value>" used to set the address of
1058*56bb7041Schristos 	     section <non-digits>.  Was this for compatibility with
1059*56bb7041Schristos 	     something, or can we create a new option to do that
1060*56bb7041Schristos 	     (with a syntax similar to -defsym)?
1061*56bb7041Schristos 	     getopt can't handle two args to an option without kludges.  */
1062*56bb7041Schristos 
1063*56bb7041Schristos 	  /* Enable optimizations of output files.  */
1064*56bb7041Schristos 	  link_info.optimize = strtoul (optarg, NULL, 0) ? TRUE : FALSE;
1065*56bb7041Schristos 	  break;
1066*56bb7041Schristos 	case 'o':
1067*56bb7041Schristos 	  lang_add_output (optarg, 0);
1068*56bb7041Schristos 	  break;
1069*56bb7041Schristos 	case OPTION_OFORMAT:
1070*56bb7041Schristos 	  lang_add_output_format (optarg, NULL, NULL, 0);
1071*56bb7041Schristos 	  break;
1072*56bb7041Schristos 	case OPTION_OUT_IMPLIB:
1073*56bb7041Schristos 	  command_line.out_implib_filename = xstrdup (optarg);
1074*56bb7041Schristos 	  break;
1075*56bb7041Schristos 	case OPTION_PRINT_SYSROOT:
1076*56bb7041Schristos 	  if (*ld_sysroot)
1077*56bb7041Schristos 	    puts (ld_sysroot);
1078*56bb7041Schristos 	  xexit (0);
1079*56bb7041Schristos 	  break;
1080*56bb7041Schristos 	case OPTION_PRINT_OUTPUT_FORMAT:
1081*56bb7041Schristos 	  command_line.print_output_format = TRUE;
1082*56bb7041Schristos 	  break;
1083*56bb7041Schristos #if BFD_SUPPORTS_PLUGINS
1084*56bb7041Schristos 	case OPTION_PLUGIN:
1085*56bb7041Schristos 	  plugin_opt_plugin (optarg);
1086*56bb7041Schristos 	  break;
1087*56bb7041Schristos 	case OPTION_PLUGIN_OPT:
1088*56bb7041Schristos 	  if (plugin_opt_plugin_arg (optarg))
1089*56bb7041Schristos 	    einfo (_("%F%P: bad -plugin-opt option\n"));
1090*56bb7041Schristos 	  break;
1091*56bb7041Schristos #endif /* BFD_SUPPORTS_PLUGINS */
1092*56bb7041Schristos 	case 'q':
1093*56bb7041Schristos 	  link_info.emitrelocations = TRUE;
1094*56bb7041Schristos 	  break;
1095*56bb7041Schristos 	case 'i':
1096*56bb7041Schristos 	case 'r':
1097*56bb7041Schristos 	  if (optind == last_optind)
1098*56bb7041Schristos 	    /* This can happen if the user put "-rpath,a" on the command
1099*56bb7041Schristos 	       line.  (Or something similar.  The comma is important).
1100*56bb7041Schristos 	       Getopt becomes confused and thinks that this is a -r option
1101*56bb7041Schristos 	       but it cannot parse the text after the -r so it refuses to
1102*56bb7041Schristos 	       increment the optind counter.  Detect this case and issue
1103*56bb7041Schristos 	       an error message here.  We cannot just make this a warning,
1104*56bb7041Schristos 	       increment optind, and continue because getopt is too confused
1105*56bb7041Schristos 	       and will seg-fault the next time around.  */
1106*56bb7041Schristos 	    einfo(_("%F%P: unrecognised option: %s\n"), argv[optind]);
1107*56bb7041Schristos 
1108*56bb7041Schristos 	  if (bfd_link_pic (&link_info))
1109*56bb7041Schristos 	    einfo (_("%F%P: -r and %s may not be used together\n"),
1110*56bb7041Schristos 		     bfd_link_dll (&link_info) ? "-shared" : "-pie");
1111*56bb7041Schristos 
1112*56bb7041Schristos 	  link_info.type = type_relocatable;
1113*56bb7041Schristos 	  config.build_constructors = FALSE;
1114*56bb7041Schristos 	  config.magic_demand_paged = FALSE;
1115*56bb7041Schristos 	  config.text_read_only = FALSE;
1116*56bb7041Schristos 	  input_flags.dynamic = FALSE;
1117*56bb7041Schristos 	  break;
1118*56bb7041Schristos 	case 'R':
1119*56bb7041Schristos 	  /* The GNU linker traditionally uses -R to mean to include
1120*56bb7041Schristos 	     only the symbols from a file.  The Solaris linker uses -R
1121*56bb7041Schristos 	     to set the path used by the runtime linker to find
1122*56bb7041Schristos 	     libraries.  This is the GNU linker -rpath argument.  We
1123*56bb7041Schristos 	     try to support both simultaneously by checking the file
1124*56bb7041Schristos 	     named.  If it is a directory, rather than a regular file,
1125*56bb7041Schristos 	     we assume -rpath was meant.  */
1126*56bb7041Schristos 	  {
1127*56bb7041Schristos 	    struct stat s;
1128*56bb7041Schristos 
1129*56bb7041Schristos 	    if (stat (optarg, &s) >= 0
1130*56bb7041Schristos 		&& ! S_ISDIR (s.st_mode))
1131*56bb7041Schristos 	      {
1132*56bb7041Schristos 		lang_add_input_file (optarg,
1133*56bb7041Schristos 				     lang_input_file_is_symbols_only_enum,
1134*56bb7041Schristos 				     NULL);
1135*56bb7041Schristos 		break;
1136*56bb7041Schristos 	      }
1137*56bb7041Schristos 	  }
1138*56bb7041Schristos 	  /* Fall through.  */
1139*56bb7041Schristos 	case OPTION_RPATH:
1140*56bb7041Schristos 	  if (command_line.rpath == NULL)
1141*56bb7041Schristos 	    command_line.rpath = xstrdup (optarg);
1142*56bb7041Schristos 	  else
1143*56bb7041Schristos 	    {
1144*56bb7041Schristos 	      size_t rpath_len = strlen (command_line.rpath);
1145*56bb7041Schristos 	      size_t optarg_len = strlen (optarg);
1146*56bb7041Schristos 	      char *buf;
1147*56bb7041Schristos 	      char *cp = command_line.rpath;
1148*56bb7041Schristos 
1149*56bb7041Schristos 	      /* First see whether OPTARG is already in the path.  */
1150*56bb7041Schristos 	      do
1151*56bb7041Schristos 		{
1152*56bb7041Schristos 		  if (strncmp (optarg, cp, optarg_len) == 0
1153*56bb7041Schristos 		      && (cp[optarg_len] == 0
1154*56bb7041Schristos 			  || cp[optarg_len] == config.rpath_separator))
1155*56bb7041Schristos 		    /* We found it.  */
1156*56bb7041Schristos 		    break;
1157*56bb7041Schristos 
1158*56bb7041Schristos 		  /* Not yet found.  */
1159*56bb7041Schristos 		  cp = strchr (cp, config.rpath_separator);
1160*56bb7041Schristos 		  if (cp != NULL)
1161*56bb7041Schristos 		    ++cp;
1162*56bb7041Schristos 		}
1163*56bb7041Schristos 	      while (cp != NULL);
1164*56bb7041Schristos 
1165*56bb7041Schristos 	      if (cp == NULL)
1166*56bb7041Schristos 		{
1167*56bb7041Schristos 		  buf = (char *) xmalloc (rpath_len + optarg_len + 2);
1168*56bb7041Schristos 		  sprintf (buf, "%s%c%s", command_line.rpath,
1169*56bb7041Schristos 			   config.rpath_separator, optarg);
1170*56bb7041Schristos 		  free (command_line.rpath);
1171*56bb7041Schristos 		  command_line.rpath = buf;
1172*56bb7041Schristos 		}
1173*56bb7041Schristos 	    }
1174*56bb7041Schristos 	  break;
1175*56bb7041Schristos 	case OPTION_RPATH_LINK:
1176*56bb7041Schristos 	  if (command_line.rpath_link == NULL)
1177*56bb7041Schristos 	    command_line.rpath_link = xstrdup (optarg);
1178*56bb7041Schristos 	  else
1179*56bb7041Schristos 	    {
1180*56bb7041Schristos 	      char *buf;
1181*56bb7041Schristos 
1182*56bb7041Schristos 	      buf = (char *) xmalloc (strlen (command_line.rpath_link)
1183*56bb7041Schristos 				      + strlen (optarg)
1184*56bb7041Schristos 				      + 2);
1185*56bb7041Schristos 	      sprintf (buf, "%s%c%s", command_line.rpath_link,
1186*56bb7041Schristos 		       config.rpath_separator, optarg);
1187*56bb7041Schristos 	      free (command_line.rpath_link);
1188*56bb7041Schristos 	      command_line.rpath_link = buf;
1189*56bb7041Schristos 	    }
1190*56bb7041Schristos 	  break;
1191*56bb7041Schristos 	case OPTION_NO_RELAX:
1192*56bb7041Schristos 	  DISABLE_RELAXATION;
1193*56bb7041Schristos 	  break;
1194*56bb7041Schristos 	case OPTION_RELAX:
1195*56bb7041Schristos 	  ENABLE_RELAXATION;
1196*56bb7041Schristos 	  break;
1197*56bb7041Schristos 	case OPTION_RETAIN_SYMBOLS_FILE:
1198*56bb7041Schristos 	  add_keepsyms_file (optarg);
1199*56bb7041Schristos 	  break;
1200*56bb7041Schristos 	case 'S':
1201*56bb7041Schristos 	  link_info.strip = strip_debugger;
1202*56bb7041Schristos 	  break;
1203*56bb7041Schristos 	case 's':
1204*56bb7041Schristos 	  link_info.strip = strip_all;
1205*56bb7041Schristos 	  break;
1206*56bb7041Schristos 	case OPTION_STRIP_DISCARDED:
1207*56bb7041Schristos 	  link_info.strip_discarded = TRUE;
1208*56bb7041Schristos 	  break;
1209*56bb7041Schristos 	case OPTION_NO_STRIP_DISCARDED:
1210*56bb7041Schristos 	  link_info.strip_discarded = FALSE;
1211*56bb7041Schristos 	  break;
1212*56bb7041Schristos 	case OPTION_DISABLE_MULTIPLE_DEFS_ABS:
1213*56bb7041Schristos 	  link_info.prohibit_multiple_definition_absolute = TRUE;
1214*56bb7041Schristos 	  break;
1215*56bb7041Schristos 	case OPTION_SHARED:
1216*56bb7041Schristos 	  if (config.has_shared)
1217*56bb7041Schristos 	    {
1218*56bb7041Schristos 	      if (bfd_link_relocatable (&link_info))
1219*56bb7041Schristos 		einfo (_("%F%P: -r and %s may not be used together\n"),
1220*56bb7041Schristos 		       "-shared");
1221*56bb7041Schristos 
1222*56bb7041Schristos 	      link_info.type = type_dll;
1223*56bb7041Schristos 	      /* When creating a shared library, the default
1224*56bb7041Schristos 		 behaviour is to ignore any unresolved references.  */
1225*56bb7041Schristos 	      if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1226*56bb7041Schristos 		link_info.unresolved_syms_in_objects = RM_IGNORE;
1227*56bb7041Schristos 	      if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1228*56bb7041Schristos 		link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
1229*56bb7041Schristos 	    }
1230*56bb7041Schristos 	  else
1231*56bb7041Schristos 	    einfo (_("%F%P: -shared not supported\n"));
1232*56bb7041Schristos 	  break;
1233*56bb7041Schristos 	case OPTION_PIE:
1234*56bb7041Schristos 	  if (config.has_shared)
1235*56bb7041Schristos 	    {
1236*56bb7041Schristos 	      if (bfd_link_relocatable (&link_info))
1237*56bb7041Schristos 		einfo (_("%F%P: -r and %s may not be used together\n"), "-pie");
1238*56bb7041Schristos 
1239*56bb7041Schristos 	      link_info.type = type_pie;
1240*56bb7041Schristos 	    }
1241*56bb7041Schristos 	  else
1242*56bb7041Schristos 	    einfo (_("%F%P: -pie not supported\n"));
1243*56bb7041Schristos 	  break;
1244*56bb7041Schristos 	case 'h':		/* Used on Solaris.  */
1245*56bb7041Schristos 	case OPTION_SONAME:
1246*56bb7041Schristos 	  if (optarg[0] == '\0' && command_line.soname
1247*56bb7041Schristos 	      && command_line.soname[0])
1248*56bb7041Schristos 	    einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
1249*56bb7041Schristos 	  else
1250*56bb7041Schristos 	    command_line.soname = optarg;
1251*56bb7041Schristos 	  break;
1252*56bb7041Schristos 	case OPTION_SORT_COMMON:
1253*56bb7041Schristos 	  if (optarg == NULL
1254*56bb7041Schristos 	      || strcmp (optarg, N_("descending")) == 0)
1255*56bb7041Schristos 	    config.sort_common = sort_descending;
1256*56bb7041Schristos 	  else if (strcmp (optarg, N_("ascending")) == 0)
1257*56bb7041Schristos 	    config.sort_common = sort_ascending;
1258*56bb7041Schristos 	  else
1259*56bb7041Schristos 	    einfo (_("%F%P: invalid common section sorting option: %s\n"),
1260*56bb7041Schristos 		   optarg);
1261*56bb7041Schristos 	  break;
1262*56bb7041Schristos 	case OPTION_SORT_SECTION:
1263*56bb7041Schristos 	  if (strcmp (optarg, N_("name")) == 0)
1264*56bb7041Schristos 	    sort_section = by_name;
1265*56bb7041Schristos 	  else if (strcmp (optarg, N_("alignment")) == 0)
1266*56bb7041Schristos 	    sort_section = by_alignment;
1267*56bb7041Schristos 	  else
1268*56bb7041Schristos 	    einfo (_("%F%P: invalid section sorting option: %s\n"),
1269*56bb7041Schristos 		   optarg);
1270*56bb7041Schristos 	  break;
1271*56bb7041Schristos 	case OPTION_STATS:
1272*56bb7041Schristos 	  config.stats = TRUE;
1273*56bb7041Schristos 	  break;
1274*56bb7041Schristos 	case OPTION_SYMBOLIC:
1275*56bb7041Schristos 	  opt_symbolic = symbolic;
1276*56bb7041Schristos 	  break;
1277*56bb7041Schristos 	case OPTION_SYMBOLIC_FUNCTIONS:
1278*56bb7041Schristos 	  opt_symbolic = symbolic_functions;
1279*56bb7041Schristos 	  break;
1280*56bb7041Schristos 	case 't':
1281*56bb7041Schristos 	  ++trace_files;
1282*56bb7041Schristos 	  break;
1283*56bb7041Schristos 	case 'T':
1284*56bb7041Schristos 	  previous_script_handle = saved_script_handle;
1285*56bb7041Schristos 	  ldfile_open_script_file (optarg);
1286*56bb7041Schristos 	  parser_input = input_script;
1287*56bb7041Schristos 	  yyparse ();
1288*56bb7041Schristos 	  previous_script_handle = NULL;
1289*56bb7041Schristos 	  break;
1290*56bb7041Schristos 	case OPTION_DEFAULT_SCRIPT:
1291*56bb7041Schristos 	  command_line.default_script = optarg;
1292*56bb7041Schristos 	  break;
1293*56bb7041Schristos 	case OPTION_SECTION_START:
1294*56bb7041Schristos 	  {
1295*56bb7041Schristos 	    char *optarg2;
1296*56bb7041Schristos 	    char *sec_name;
1297*56bb7041Schristos 	    int len;
1298*56bb7041Schristos 
1299*56bb7041Schristos 	    /* Check for <something>=<somthing>...  */
1300*56bb7041Schristos 	    optarg2 = strchr (optarg, '=');
1301*56bb7041Schristos 	    if (optarg2 == NULL)
1302*56bb7041Schristos 	      einfo (_("%F%P: invalid argument to option"
1303*56bb7041Schristos 		       " \"--section-start\"\n"));
1304*56bb7041Schristos 
1305*56bb7041Schristos 	    optarg2++;
1306*56bb7041Schristos 
1307*56bb7041Schristos 	    /* So far so good.  Are all the args present?  */
1308*56bb7041Schristos 	    if ((*optarg == '\0') || (*optarg2 == '\0'))
1309*56bb7041Schristos 	      einfo (_("%F%P: missing argument(s) to option"
1310*56bb7041Schristos 		       " \"--section-start\"\n"));
1311*56bb7041Schristos 
1312*56bb7041Schristos 	    /* We must copy the section name as set_section_start
1313*56bb7041Schristos 	       doesn't do it for us.  */
1314*56bb7041Schristos 	    len = optarg2 - optarg;
1315*56bb7041Schristos 	    sec_name = (char *) xmalloc (len);
1316*56bb7041Schristos 	    memcpy (sec_name, optarg, len - 1);
1317*56bb7041Schristos 	    sec_name[len - 1] = 0;
1318*56bb7041Schristos 
1319*56bb7041Schristos 	    /* Then set it...  */
1320*56bb7041Schristos 	    set_section_start (sec_name, optarg2);
1321*56bb7041Schristos 	  }
1322*56bb7041Schristos 	  break;
1323*56bb7041Schristos 	case OPTION_TARGET_HELP:
1324*56bb7041Schristos 	  /* Mention any target specific options.  */
1325*56bb7041Schristos 	  ldemul_list_emulation_options (stdout);
1326*56bb7041Schristos 	  exit (0);
1327*56bb7041Schristos 	case OPTION_TBSS:
1328*56bb7041Schristos 	  set_segment_start (".bss", optarg);
1329*56bb7041Schristos 	  break;
1330*56bb7041Schristos 	case OPTION_TDATA:
1331*56bb7041Schristos 	  set_segment_start (".data", optarg);
1332*56bb7041Schristos 	  break;
1333*56bb7041Schristos 	case OPTION_TTEXT:
1334*56bb7041Schristos 	  set_segment_start (".text", optarg);
1335*56bb7041Schristos 	  break;
1336*56bb7041Schristos 	case OPTION_TTEXT_SEGMENT:
1337*56bb7041Schristos 	  set_segment_start (".text-segment", optarg);
1338*56bb7041Schristos 	  break;
1339*56bb7041Schristos 	case OPTION_TRODATA_SEGMENT:
1340*56bb7041Schristos 	  set_segment_start (".rodata-segment", optarg);
1341*56bb7041Schristos 	  break;
1342*56bb7041Schristos 	case OPTION_TLDATA_SEGMENT:
1343*56bb7041Schristos 	  set_segment_start (".ldata-segment", optarg);
1344*56bb7041Schristos 	  break;
1345*56bb7041Schristos 	case OPTION_TRADITIONAL_FORMAT:
1346*56bb7041Schristos 	  link_info.traditional_format = TRUE;
1347*56bb7041Schristos 	  break;
1348*56bb7041Schristos 	case OPTION_TASK_LINK:
1349*56bb7041Schristos 	  link_info.task_link = TRUE;
1350*56bb7041Schristos 	  /* Fall through.  */
1351*56bb7041Schristos 	case OPTION_UR:
1352*56bb7041Schristos 	  if (bfd_link_pic (&link_info))
1353*56bb7041Schristos 	    einfo (_("%F%P: -r and %s may not be used together\n"),
1354*56bb7041Schristos 		     bfd_link_dll (&link_info) ? "-shared" : "-pie");
1355*56bb7041Schristos 
1356*56bb7041Schristos 	  link_info.type = type_relocatable;
1357*56bb7041Schristos 	  config.build_constructors = TRUE;
1358*56bb7041Schristos 	  config.magic_demand_paged = FALSE;
1359*56bb7041Schristos 	  config.text_read_only = FALSE;
1360*56bb7041Schristos 	  input_flags.dynamic = FALSE;
1361*56bb7041Schristos 	  break;
1362*56bb7041Schristos 	case 'u':
1363*56bb7041Schristos 	  ldlang_add_undef (optarg, TRUE);
1364*56bb7041Schristos 	  break;
1365*56bb7041Schristos 	case OPTION_REQUIRE_DEFINED_SYMBOL:
1366*56bb7041Schristos 	  ldlang_add_require_defined (optarg);
1367*56bb7041Schristos 	  break;
1368*56bb7041Schristos 	case OPTION_UNIQUE:
1369*56bb7041Schristos 	  if (optarg != NULL)
1370*56bb7041Schristos 	    lang_add_unique (optarg);
1371*56bb7041Schristos 	  else
1372*56bb7041Schristos 	    config.unique_orphan_sections = TRUE;
1373*56bb7041Schristos 	  break;
1374*56bb7041Schristos 	case OPTION_VERBOSE:
1375*56bb7041Schristos 	  ldversion (1);
1376*56bb7041Schristos 	  version_printed = TRUE;
1377*56bb7041Schristos 	  verbose = TRUE;
1378*56bb7041Schristos 	  overflow_cutoff_limit = -2;
1379*56bb7041Schristos 	  if (optarg != NULL)
1380*56bb7041Schristos 	    {
1381*56bb7041Schristos 	      char *end;
1382*56bb7041Schristos 	      int level ATTRIBUTE_UNUSED = strtoul (optarg, &end, 0);
1383*56bb7041Schristos 	      if (*end)
1384*56bb7041Schristos 		einfo (_("%F%P: invalid number `%s'\n"), optarg);
1385*56bb7041Schristos #if BFD_SUPPORTS_PLUGINS
1386*56bb7041Schristos 	      report_plugin_symbols = level > 1;
1387*56bb7041Schristos #endif /* BFD_SUPPORTS_PLUGINS */
1388*56bb7041Schristos 	    }
1389*56bb7041Schristos 	  break;
1390*56bb7041Schristos 	case 'v':
1391*56bb7041Schristos 	  ldversion (0);
1392*56bb7041Schristos 	  version_printed = TRUE;
1393*56bb7041Schristos 	  break;
1394*56bb7041Schristos 	case 'V':
1395*56bb7041Schristos 	  ldversion (1);
1396*56bb7041Schristos 	  version_printed = TRUE;
1397*56bb7041Schristos 	  break;
1398*56bb7041Schristos 	case OPTION_VERSION:
1399*56bb7041Schristos 	  ldversion (2);
1400*56bb7041Schristos 	  xexit (0);
1401*56bb7041Schristos 	  break;
1402*56bb7041Schristos 	case OPTION_VERSION_SCRIPT:
1403*56bb7041Schristos 	  /* This option indicates a small script that only specifies
1404*56bb7041Schristos 	     version information.  Read it, but don't assume that
1405*56bb7041Schristos 	     we've seen a linker script.  */
1406*56bb7041Schristos 	  {
1407*56bb7041Schristos 	    FILE *hold_script_handle;
1408*56bb7041Schristos 
1409*56bb7041Schristos 	    hold_script_handle = saved_script_handle;
1410*56bb7041Schristos 	    ldfile_open_command_file (optarg);
1411*56bb7041Schristos 	    saved_script_handle = hold_script_handle;
1412*56bb7041Schristos 	    parser_input = input_version_script;
1413*56bb7041Schristos 	    yyparse ();
1414*56bb7041Schristos 	  }
1415*56bb7041Schristos 	  break;
1416*56bb7041Schristos 	case OPTION_VERSION_EXPORTS_SECTION:
1417*56bb7041Schristos 	  /* This option records a version symbol to be applied to the
1418*56bb7041Schristos 	     symbols listed for export to be found in the object files
1419*56bb7041Schristos 	     .exports sections.  */
1420*56bb7041Schristos 	  command_line.version_exports_section = optarg;
1421*56bb7041Schristos 	  break;
1422*56bb7041Schristos 	case OPTION_DYNAMIC_LIST_DATA:
1423*56bb7041Schristos 	  opt_dynamic_list = dynamic_list_data;
1424*56bb7041Schristos 	  break;
1425*56bb7041Schristos 	case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
1426*56bb7041Schristos 	  lang_append_dynamic_list_cpp_typeinfo ();
1427*56bb7041Schristos 	  if (opt_dynamic_list != dynamic_list_data)
1428*56bb7041Schristos 	    opt_dynamic_list = dynamic_list;
1429*56bb7041Schristos 	  break;
1430*56bb7041Schristos 	case OPTION_DYNAMIC_LIST_CPP_NEW:
1431*56bb7041Schristos 	  lang_append_dynamic_list_cpp_new ();
1432*56bb7041Schristos 	  if (opt_dynamic_list != dynamic_list_data)
1433*56bb7041Schristos 	    opt_dynamic_list = dynamic_list;
1434*56bb7041Schristos 	  break;
1435*56bb7041Schristos 	case OPTION_DYNAMIC_LIST:
1436*56bb7041Schristos 	  /* This option indicates a small script that only specifies
1437*56bb7041Schristos 	     a dynamic list.  Read it, but don't assume that we've
1438*56bb7041Schristos 	     seen a linker script.  */
1439*56bb7041Schristos 	  {
1440*56bb7041Schristos 	    FILE *hold_script_handle;
1441*56bb7041Schristos 
1442*56bb7041Schristos 	    hold_script_handle = saved_script_handle;
1443*56bb7041Schristos 	    ldfile_open_command_file (optarg);
1444*56bb7041Schristos 	    saved_script_handle = hold_script_handle;
1445*56bb7041Schristos 	    parser_input = input_dynamic_list;
1446*56bb7041Schristos 	    current_dynamic_list_p = &link_info.dynamic_list;
1447*56bb7041Schristos 	    yyparse ();
1448*56bb7041Schristos 	  }
1449*56bb7041Schristos 	  if (opt_dynamic_list != dynamic_list_data)
1450*56bb7041Schristos 	    opt_dynamic_list = dynamic_list;
1451*56bb7041Schristos 	  break;
1452*56bb7041Schristos 	case OPTION_EXPORT_DYNAMIC_SYMBOL:
1453*56bb7041Schristos 	  {
1454*56bb7041Schristos 	    struct bfd_elf_version_expr *expr
1455*56bb7041Schristos 	      = lang_new_vers_pattern (NULL, xstrdup (optarg), NULL,
1456*56bb7041Schristos 				       FALSE);
1457*56bb7041Schristos 	    lang_append_dynamic_list (&export_list, expr);
1458*56bb7041Schristos 	  }
1459*56bb7041Schristos 	  break;
1460*56bb7041Schristos 	case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST:
1461*56bb7041Schristos 	  /* This option indicates a small script that only specifies
1462*56bb7041Schristos 	     an export list.  Read it, but don't assume that we've
1463*56bb7041Schristos 	     seen a linker script.  */
1464*56bb7041Schristos 	  {
1465*56bb7041Schristos 	    FILE *hold_script_handle;
1466*56bb7041Schristos 
1467*56bb7041Schristos 	    hold_script_handle = saved_script_handle;
1468*56bb7041Schristos 	    ldfile_open_command_file (optarg);
1469*56bb7041Schristos 	    saved_script_handle = hold_script_handle;
1470*56bb7041Schristos 	    parser_input = input_dynamic_list;
1471*56bb7041Schristos 	    current_dynamic_list_p = &export_list;
1472*56bb7041Schristos 	    yyparse ();
1473*56bb7041Schristos 	  }
1474*56bb7041Schristos 	  break;
1475*56bb7041Schristos 	case OPTION_WARN_COMMON:
1476*56bb7041Schristos 	  config.warn_common = TRUE;
1477*56bb7041Schristos 	  break;
1478*56bb7041Schristos 	case OPTION_WARN_CONSTRUCTORS:
1479*56bb7041Schristos 	  config.warn_constructors = TRUE;
1480*56bb7041Schristos 	  break;
1481*56bb7041Schristos 	case OPTION_WARN_FATAL:
1482*56bb7041Schristos 	  config.fatal_warnings = TRUE;
1483*56bb7041Schristos 	  break;
1484*56bb7041Schristos 	case OPTION_NO_WARN_FATAL:
1485*56bb7041Schristos 	  config.fatal_warnings = FALSE;
1486*56bb7041Schristos 	  break;
1487*56bb7041Schristos 	case OPTION_WARN_MULTIPLE_GP:
1488*56bb7041Schristos 	  config.warn_multiple_gp = TRUE;
1489*56bb7041Schristos 	  break;
1490*56bb7041Schristos 	case OPTION_WARN_ONCE:
1491*56bb7041Schristos 	  config.warn_once = TRUE;
1492*56bb7041Schristos 	  break;
1493*56bb7041Schristos 	case OPTION_WARN_SECTION_ALIGN:
1494*56bb7041Schristos 	  config.warn_section_align = TRUE;
1495*56bb7041Schristos 	  break;
1496*56bb7041Schristos 	case OPTION_WARN_TEXTREL:
1497*56bb7041Schristos 	  link_info.textrel_check = textrel_check_warning;
1498*56bb7041Schristos 	  break;
1499*56bb7041Schristos 	case OPTION_WARN_ALTERNATE_EM:
1500*56bb7041Schristos 	  link_info.warn_alternate_em = TRUE;
1501*56bb7041Schristos 	  break;
1502*56bb7041Schristos 	case OPTION_WHOLE_ARCHIVE:
1503*56bb7041Schristos 	  input_flags.whole_archive = TRUE;
1504*56bb7041Schristos 	  break;
1505*56bb7041Schristos 	case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC:
1506*56bb7041Schristos 	  input_flags.add_DT_NEEDED_for_dynamic = TRUE;
1507*56bb7041Schristos 	  break;
1508*56bb7041Schristos 	case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC:
1509*56bb7041Schristos 	  input_flags.add_DT_NEEDED_for_dynamic = FALSE;
1510*56bb7041Schristos 	  break;
1511*56bb7041Schristos 	case OPTION_ADD_DT_NEEDED_FOR_REGULAR:
1512*56bb7041Schristos 	  input_flags.add_DT_NEEDED_for_regular = TRUE;
1513*56bb7041Schristos 	  break;
1514*56bb7041Schristos 	case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR:
1515*56bb7041Schristos 	  input_flags.add_DT_NEEDED_for_regular = FALSE;
1516*56bb7041Schristos 	  break;
1517*56bb7041Schristos 	case OPTION_WRAP:
1518*56bb7041Schristos 	  add_wrap (optarg);
1519*56bb7041Schristos 	  break;
1520*56bb7041Schristos 	case OPTION_IGNORE_UNRESOLVED_SYMBOL:
1521*56bb7041Schristos 	  add_ignoresym (&link_info, optarg);
1522*56bb7041Schristos 	  break;
1523*56bb7041Schristos 	case OPTION_DISCARD_NONE:
1524*56bb7041Schristos 	  link_info.discard = discard_none;
1525*56bb7041Schristos 	  break;
1526*56bb7041Schristos 	case 'X':
1527*56bb7041Schristos 	  link_info.discard = discard_l;
1528*56bb7041Schristos 	  break;
1529*56bb7041Schristos 	case 'x':
1530*56bb7041Schristos 	  link_info.discard = discard_all;
1531*56bb7041Schristos 	  break;
1532*56bb7041Schristos 	case 'Y':
1533*56bb7041Schristos 	  if (CONST_STRNEQ (optarg, "P,"))
1534*56bb7041Schristos 	    optarg += 2;
1535*56bb7041Schristos 	  free (default_dirlist);
1536*56bb7041Schristos 	  default_dirlist = xstrdup (optarg);
1537*56bb7041Schristos 	  break;
1538*56bb7041Schristos 	case 'y':
1539*56bb7041Schristos 	  add_ysym (optarg);
1540*56bb7041Schristos 	  break;
1541*56bb7041Schristos 	case OPTION_SPARE_DYNAMIC_TAGS:
1542*56bb7041Schristos 	  link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0);
1543*56bb7041Schristos 	  break;
1544*56bb7041Schristos 	case OPTION_SPLIT_BY_RELOC:
1545*56bb7041Schristos 	  if (optarg != NULL)
1546*56bb7041Schristos 	    config.split_by_reloc = strtoul (optarg, NULL, 0);
1547*56bb7041Schristos 	  else
1548*56bb7041Schristos 	    config.split_by_reloc = 32768;
1549*56bb7041Schristos 	  break;
1550*56bb7041Schristos 	case OPTION_SPLIT_BY_FILE:
1551*56bb7041Schristos 	  if (optarg != NULL)
1552*56bb7041Schristos 	    config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
1553*56bb7041Schristos 	  else
1554*56bb7041Schristos 	    config.split_by_file = 1;
1555*56bb7041Schristos 	  break;
1556*56bb7041Schristos 	case OPTION_CHECK_SECTIONS:
1557*56bb7041Schristos 	  command_line.check_section_addresses = 1;
1558*56bb7041Schristos 	  break;
1559*56bb7041Schristos 	case OPTION_NO_CHECK_SECTIONS:
1560*56bb7041Schristos 	  command_line.check_section_addresses = 0;
1561*56bb7041Schristos 	  break;
1562*56bb7041Schristos 	case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
1563*56bb7041Schristos 	  command_line.accept_unknown_input_arch = TRUE;
1564*56bb7041Schristos 	  break;
1565*56bb7041Schristos 	case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
1566*56bb7041Schristos 	  command_line.accept_unknown_input_arch = FALSE;
1567*56bb7041Schristos 	  break;
1568*56bb7041Schristos 	case '(':
1569*56bb7041Schristos 	  lang_enter_group ();
1570*56bb7041Schristos 	  ingroup++;
1571*56bb7041Schristos 	  break;
1572*56bb7041Schristos 	case ')':
1573*56bb7041Schristos 	  if (! ingroup)
1574*56bb7041Schristos 	    einfo (_("%F%P: group ended before it began (--help for usage)\n"));
1575*56bb7041Schristos 
1576*56bb7041Schristos 	  lang_leave_group ();
1577*56bb7041Schristos 	  ingroup--;
1578*56bb7041Schristos 	  break;
1579*56bb7041Schristos 
1580*56bb7041Schristos 	case OPTION_INIT:
1581*56bb7041Schristos 	  link_info.init_function = optarg;
1582*56bb7041Schristos 	  break;
1583*56bb7041Schristos 
1584*56bb7041Schristos 	case OPTION_FINI:
1585*56bb7041Schristos 	  link_info.fini_function = optarg;
1586*56bb7041Schristos 	  break;
1587*56bb7041Schristos 
1588*56bb7041Schristos 	case OPTION_REDUCE_MEMORY_OVERHEADS:
1589*56bb7041Schristos 	  link_info.reduce_memory_overheads = TRUE;
1590*56bb7041Schristos 	  if (config.hash_table_size == 0)
1591*56bb7041Schristos 	    config.hash_table_size = 1021;
1592*56bb7041Schristos 	  break;
1593*56bb7041Schristos 
1594*56bb7041Schristos 	case OPTION_HASH_SIZE:
1595*56bb7041Schristos 	  {
1596*56bb7041Schristos 	    bfd_size_type new_size;
1597*56bb7041Schristos 
1598*56bb7041Schristos 	    new_size = strtoul (optarg, NULL, 0);
1599*56bb7041Schristos 	    if (new_size)
1600*56bb7041Schristos 	      config.hash_table_size = new_size;
1601*56bb7041Schristos 	    else
1602*56bb7041Schristos 	      einfo (_("%X%P: --hash-size needs a numeric argument\n"));
1603*56bb7041Schristos 	  }
1604*56bb7041Schristos 	  break;
1605*56bb7041Schristos 
1606*56bb7041Schristos 	case OPTION_PUSH_STATE:
1607*56bb7041Schristos 	  input_flags.pushed = xmemdup (&input_flags,
1608*56bb7041Schristos 					sizeof (input_flags),
1609*56bb7041Schristos 					sizeof (input_flags));
1610*56bb7041Schristos 	  break;
1611*56bb7041Schristos 
1612*56bb7041Schristos 	case OPTION_POP_STATE:
1613*56bb7041Schristos 	  if (input_flags.pushed == NULL)
1614*56bb7041Schristos 	    einfo (_("%F%P: no state pushed before popping\n"));
1615*56bb7041Schristos 	  else
1616*56bb7041Schristos 	    {
1617*56bb7041Schristos 	      struct lang_input_statement_flags *oldp = input_flags.pushed;
1618*56bb7041Schristos 	      memcpy (&input_flags, oldp, sizeof (input_flags));
1619*56bb7041Schristos 	      free (oldp);
1620*56bb7041Schristos 	    }
1621*56bb7041Schristos 	  break;
1622*56bb7041Schristos 
1623*56bb7041Schristos 	case OPTION_PRINT_MEMORY_USAGE:
1624*56bb7041Schristos 	  command_line.print_memory_usage = TRUE;
1625*56bb7041Schristos 	  break;
1626*56bb7041Schristos 
1627*56bb7041Schristos 	case OPTION_ORPHAN_HANDLING:
1628*56bb7041Schristos 	  if (strcasecmp (optarg, "place") == 0)
1629*56bb7041Schristos 	    config.orphan_handling = orphan_handling_place;
1630*56bb7041Schristos 	  else if (strcasecmp (optarg, "warn") == 0)
1631*56bb7041Schristos 	    config.orphan_handling = orphan_handling_warn;
1632*56bb7041Schristos 	  else if (strcasecmp (optarg, "error") == 0)
1633*56bb7041Schristos 	    config.orphan_handling = orphan_handling_error;
1634*56bb7041Schristos 	  else if (strcasecmp (optarg, "discard") == 0)
1635*56bb7041Schristos 	    config.orphan_handling = orphan_handling_discard;
1636*56bb7041Schristos 	  else
1637*56bb7041Schristos 	    einfo (_("%F%P: invalid argument to option"
1638*56bb7041Schristos 		     " \"--orphan-handling\"\n"));
1639*56bb7041Schristos 	  break;
1640*56bb7041Schristos 
1641*56bb7041Schristos 	case OPTION_NO_PRINT_MAP_DISCARDED:
1642*56bb7041Schristos 	  config.print_map_discarded = FALSE;
1643*56bb7041Schristos 	  break;
1644*56bb7041Schristos 
1645*56bb7041Schristos 	case OPTION_PRINT_MAP_DISCARDED:
1646*56bb7041Schristos 	  config.print_map_discarded = TRUE;
1647*56bb7041Schristos 	  break;
1648*56bb7041Schristos 
1649*56bb7041Schristos 	case OPTION_DEPENDENCY_FILE:
1650*56bb7041Schristos 	  config.dependency_file = optarg;
1651*56bb7041Schristos 	  break;
1652*56bb7041Schristos 
1653*56bb7041Schristos 	case OPTION_CTF_VARIABLES:
1654*56bb7041Schristos 	  config.ctf_variables = TRUE;
1655*56bb7041Schristos 	  break;
1656*56bb7041Schristos 
1657*56bb7041Schristos 	case OPTION_NO_CTF_VARIABLES:
1658*56bb7041Schristos 	  config.ctf_variables = FALSE;
1659*56bb7041Schristos 	  break;
1660*56bb7041Schristos 
1661*56bb7041Schristos 	case OPTION_CTF_SHARE_TYPES:
1662*56bb7041Schristos 	  if (strcmp (optarg, "share-unconflicted") == 0)
1663*56bb7041Schristos 	    config.ctf_share_duplicated = FALSE;
1664*56bb7041Schristos 	  else if (strcmp (optarg, "share-duplicated") == 0)
1665*56bb7041Schristos 	    config.ctf_share_duplicated = TRUE;
1666*56bb7041Schristos 	  else
1667*56bb7041Schristos 	    einfo (_("%F%P: bad --ctf-share-types option: %s\n"), optarg);
1668*56bb7041Schristos 	  break;
1669*56bb7041Schristos 	}
1670*56bb7041Schristos     }
1671*56bb7041Schristos 
1672*56bb7041Schristos   /* Run a couple of checks on the map filename.  */
1673*56bb7041Schristos   if (config.map_filename)
1674*56bb7041Schristos     {
1675*56bb7041Schristos       if (config.map_filename[0] == 0)
1676*56bb7041Schristos 	{
1677*56bb7041Schristos 	  einfo (_("%P: no file/directory name provided for map output; ignored\n"));
1678*56bb7041Schristos 	  config.map_filename = NULL;
1679*56bb7041Schristos 	}
1680*56bb7041Schristos       else
1681*56bb7041Schristos 	{
1682*56bb7041Schristos 	  struct stat s;
1683*56bb7041Schristos 
1684*56bb7041Schristos 	  /* If the map filename is actually a directory then create
1685*56bb7041Schristos 	     a file inside it, based upon the output filename.  */
1686*56bb7041Schristos 	  if (stat (config.map_filename, &s) >= 0
1687*56bb7041Schristos 	      && S_ISDIR (s.st_mode))
1688*56bb7041Schristos 	    {
1689*56bb7041Schristos 	      char * new_name;
1690*56bb7041Schristos 
1691*56bb7041Schristos 	      /* FIXME: This is a (trivial) memory leak.  */
1692*56bb7041Schristos 	      if (asprintf (&new_name, "%s/%s.map",
1693*56bb7041Schristos 			    config.map_filename, output_filename) < 0)
1694*56bb7041Schristos 		{
1695*56bb7041Schristos 		  /* If this alloc fails then something is probably very
1696*56bb7041Schristos 		     wrong.  Better to halt now rather than continue on
1697*56bb7041Schristos 		     into more problems.  */
1698*56bb7041Schristos 		  einfo (_("%P%F: cannot create name for linker map file: %E\n"));
1699*56bb7041Schristos 		  new_name = NULL;
1700*56bb7041Schristos 		}
1701*56bb7041Schristos 
1702*56bb7041Schristos 	      config.map_filename = new_name;
1703*56bb7041Schristos 	    }
1704*56bb7041Schristos 	}
1705*56bb7041Schristos     }
1706*56bb7041Schristos 
1707*56bb7041Schristos   if (command_line.soname && command_line.soname[0] == '\0')
1708*56bb7041Schristos     {
1709*56bb7041Schristos       einfo (_("%P: SONAME must not be empty string; ignored\n"));
1710*56bb7041Schristos       command_line.soname = NULL;
1711*56bb7041Schristos     }
1712*56bb7041Schristos 
1713*56bb7041Schristos   while (ingroup)
1714*56bb7041Schristos     {
1715*56bb7041Schristos       einfo (_("%P: missing --end-group; added as last command line option\n"));
1716*56bb7041Schristos       lang_leave_group ();
1717*56bb7041Schristos       ingroup--;
1718*56bb7041Schristos     }
1719*56bb7041Schristos 
1720*56bb7041Schristos   if (default_dirlist != NULL)
1721*56bb7041Schristos     {
1722*56bb7041Schristos       set_default_dirlist (default_dirlist);
1723*56bb7041Schristos       free (default_dirlist);
1724*56bb7041Schristos     }
1725*56bb7041Schristos 
1726*56bb7041Schristos   if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1727*56bb7041Schristos     /* FIXME: Should we allow emulations a chance to set this ?  */
1728*56bb7041Schristos     link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
1729*56bb7041Schristos 
1730*56bb7041Schristos   if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1731*56bb7041Schristos     /* FIXME: Should we allow emulations a chance to set this ?  */
1732*56bb7041Schristos     link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
1733*56bb7041Schristos 
1734*56bb7041Schristos   if (bfd_link_relocatable (&link_info)
1735*56bb7041Schristos       && command_line.check_section_addresses < 0)
1736*56bb7041Schristos     command_line.check_section_addresses = 0;
1737*56bb7041Schristos 
1738*56bb7041Schristos   if (export_list)
1739*56bb7041Schristos     {
1740*56bb7041Schristos       struct bfd_elf_version_expr *head = export_list->head.list;
1741*56bb7041Schristos       struct bfd_elf_version_expr *next;
1742*56bb7041Schristos 
1743*56bb7041Schristos       /* For --export-dynamic-symbol[-list]:
1744*56bb7041Schristos 	 1. When building executable, treat like --dynamic-list.
1745*56bb7041Schristos 	 2. When building shared object:
1746*56bb7041Schristos 	    a. If -Bsymbolic or --dynamic-list are used, treat like
1747*56bb7041Schristos 	       --dynamic-list.
1748*56bb7041Schristos 	    b. Otherwise, ignored.
1749*56bb7041Schristos        */
1750*56bb7041Schristos       if (!bfd_link_relocatable (&link_info)
1751*56bb7041Schristos 	  && (bfd_link_executable (&link_info)
1752*56bb7041Schristos 	      || opt_symbolic != symbolic_unset
1753*56bb7041Schristos 	      || opt_dynamic_list != dynamic_list_unset))
1754*56bb7041Schristos 	{
1755*56bb7041Schristos 	  /* Append the export list to link_info.dynamic_list.  */
1756*56bb7041Schristos 	  if (link_info.dynamic_list)
1757*56bb7041Schristos 	    {
1758*56bb7041Schristos 	      for (next = head; next->next != NULL; next = next->next)
1759*56bb7041Schristos 		;
1760*56bb7041Schristos 	      next->next = link_info.dynamic_list->head.list;
1761*56bb7041Schristos 	      link_info.dynamic_list->head.list = head;
1762*56bb7041Schristos 	    }
1763*56bb7041Schristos 	  else
1764*56bb7041Schristos 	    link_info.dynamic_list = export_list;
1765*56bb7041Schristos 
1766*56bb7041Schristos 	  if (opt_dynamic_list != dynamic_list_data)
1767*56bb7041Schristos 	    opt_dynamic_list = dynamic_list;
1768*56bb7041Schristos 	}
1769*56bb7041Schristos       else
1770*56bb7041Schristos 	{
1771*56bb7041Schristos 	  /* Free the export list.  */
1772*56bb7041Schristos 	  for (; head->next != NULL; head = next)
1773*56bb7041Schristos 	    {
1774*56bb7041Schristos 	      next = head->next;
1775*56bb7041Schristos 	      free (head);
1776*56bb7041Schristos 	    }
1777*56bb7041Schristos 	  free (export_list);
1778*56bb7041Schristos 	}
1779*56bb7041Schristos     }
1780*56bb7041Schristos 
1781*56bb7041Schristos   switch (opt_dynamic_list)
1782*56bb7041Schristos     {
1783*56bb7041Schristos     case dynamic_list_unset:
1784*56bb7041Schristos       break;
1785*56bb7041Schristos     case dynamic_list_data:
1786*56bb7041Schristos       link_info.dynamic_data = TRUE;
1787*56bb7041Schristos       /* Fall through.  */
1788*56bb7041Schristos     case dynamic_list:
1789*56bb7041Schristos       link_info.dynamic = TRUE;
1790*56bb7041Schristos       opt_symbolic = symbolic_unset;
1791*56bb7041Schristos       break;
1792*56bb7041Schristos     }
1793*56bb7041Schristos 
1794*56bb7041Schristos   /* -Bsymbolic and -Bsymbols-functions are for shared library output.  */
1795*56bb7041Schristos   if (bfd_link_dll (&link_info))
1796*56bb7041Schristos     switch (opt_symbolic)
1797*56bb7041Schristos       {
1798*56bb7041Schristos       case symbolic_unset:
1799*56bb7041Schristos 	break;
1800*56bb7041Schristos       case symbolic:
1801*56bb7041Schristos 	link_info.symbolic = TRUE;
1802*56bb7041Schristos 	if (link_info.dynamic_list)
1803*56bb7041Schristos 	  {
1804*56bb7041Schristos 	    struct bfd_elf_version_expr *ent, *next;
1805*56bb7041Schristos 	    for (ent = link_info.dynamic_list->head.list; ent; ent = next)
1806*56bb7041Schristos 	      {
1807*56bb7041Schristos 		next = ent->next;
1808*56bb7041Schristos 		free (ent);
1809*56bb7041Schristos 	      }
1810*56bb7041Schristos 	    free (link_info.dynamic_list);
1811*56bb7041Schristos 	    link_info.dynamic_list = NULL;
1812*56bb7041Schristos 	  }
1813*56bb7041Schristos 	break;
1814*56bb7041Schristos       case symbolic_functions:
1815*56bb7041Schristos 	link_info.dynamic = TRUE;
1816*56bb7041Schristos 	link_info.dynamic_data = TRUE;
1817*56bb7041Schristos 	break;
1818*56bb7041Schristos       }
1819*56bb7041Schristos 
1820*56bb7041Schristos   if (!bfd_link_dll (&link_info))
1821*56bb7041Schristos     {
1822*56bb7041Schristos       if (command_line.filter_shlib)
1823*56bb7041Schristos 	einfo (_("%F%P: -F may not be used without -shared\n"));
1824*56bb7041Schristos       if (command_line.auxiliary_filters)
1825*56bb7041Schristos 	einfo (_("%F%P: -f may not be used without -shared\n"));
1826*56bb7041Schristos     }
1827*56bb7041Schristos 
1828*56bb7041Schristos   /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols).  I
1829*56bb7041Schristos      don't see how else this can be handled, since in this case we
1830*56bb7041Schristos      must preserve all externally visible symbols.  */
1831*56bb7041Schristos   if (bfd_link_relocatable (&link_info) && link_info.strip == strip_all)
1832*56bb7041Schristos     {
1833*56bb7041Schristos       link_info.strip = strip_debugger;
1834*56bb7041Schristos       if (link_info.discard == discard_sec_merge)
1835*56bb7041Schristos 	link_info.discard = discard_all;
1836*56bb7041Schristos     }
1837*56bb7041Schristos }
1838*56bb7041Schristos 
1839*56bb7041Schristos /* Add the (colon-separated) elements of DIRLIST_PTR to the
1840*56bb7041Schristos    library search path.  */
1841*56bb7041Schristos 
1842*56bb7041Schristos static void
set_default_dirlist(char * dirlist_ptr)1843*56bb7041Schristos set_default_dirlist (char *dirlist_ptr)
1844*56bb7041Schristos {
1845*56bb7041Schristos   char *p;
1846*56bb7041Schristos 
1847*56bb7041Schristos   while (1)
1848*56bb7041Schristos     {
1849*56bb7041Schristos       p = strchr (dirlist_ptr, PATH_SEPARATOR);
1850*56bb7041Schristos       if (p != NULL)
1851*56bb7041Schristos 	*p = '\0';
1852*56bb7041Schristos       if (*dirlist_ptr != '\0')
1853*56bb7041Schristos 	ldfile_add_library_path (dirlist_ptr, TRUE);
1854*56bb7041Schristos       if (p == NULL)
1855*56bb7041Schristos 	break;
1856*56bb7041Schristos       dirlist_ptr = p + 1;
1857*56bb7041Schristos     }
1858*56bb7041Schristos }
1859*56bb7041Schristos 
1860*56bb7041Schristos static void
set_section_start(char * sect,char * valstr)1861*56bb7041Schristos set_section_start (char *sect, char *valstr)
1862*56bb7041Schristos {
1863*56bb7041Schristos   const char *end;
1864*56bb7041Schristos   bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1865*56bb7041Schristos   if (*end)
1866*56bb7041Schristos     einfo (_("%F%P: invalid hex number `%s'\n"), valstr);
1867*56bb7041Schristos   lang_section_start (sect, exp_intop (val), NULL);
1868*56bb7041Schristos }
1869*56bb7041Schristos 
1870*56bb7041Schristos static void
set_segment_start(const char * section,char * valstr)1871*56bb7041Schristos set_segment_start (const char *section, char *valstr)
1872*56bb7041Schristos {
1873*56bb7041Schristos   const char *name;
1874*56bb7041Schristos   const char *end;
1875*56bb7041Schristos   segment_type *seg;
1876*56bb7041Schristos 
1877*56bb7041Schristos   bfd_vma val = bfd_scan_vma (valstr, &end, 16);
1878*56bb7041Schristos   if (*end)
1879*56bb7041Schristos     einfo (_("%F%P: invalid hex number `%s'\n"), valstr);
1880*56bb7041Schristos   /* If we already have an entry for this segment, update the existing
1881*56bb7041Schristos      value.  */
1882*56bb7041Schristos   name = section + 1;
1883*56bb7041Schristos   for (seg = segments; seg; seg = seg->next)
1884*56bb7041Schristos     if (strcmp (seg->name, name) == 0)
1885*56bb7041Schristos       {
1886*56bb7041Schristos 	seg->value = val;
1887*56bb7041Schristos 	lang_section_start (section, exp_intop (val), seg);
1888*56bb7041Schristos 	return;
1889*56bb7041Schristos       }
1890*56bb7041Schristos   /* There was no existing value so we must create a new segment
1891*56bb7041Schristos      entry.  */
1892*56bb7041Schristos   seg = stat_alloc (sizeof (*seg));
1893*56bb7041Schristos   seg->name = name;
1894*56bb7041Schristos   seg->value = val;
1895*56bb7041Schristos   seg->used = FALSE;
1896*56bb7041Schristos   /* Add it to the linked list of segments.  */
1897*56bb7041Schristos   seg->next = segments;
1898*56bb7041Schristos   segments = seg;
1899*56bb7041Schristos   /* Historically, -Ttext and friends set the base address of a
1900*56bb7041Schristos      particular section.  For backwards compatibility, we still do
1901*56bb7041Schristos      that.  If a SEGMENT_START directive is seen, the section address
1902*56bb7041Schristos      assignment will be disabled.  */
1903*56bb7041Schristos   lang_section_start (section, exp_intop (val), seg);
1904*56bb7041Schristos }
1905*56bb7041Schristos 
1906*56bb7041Schristos static void
elf_shlib_list_options(FILE * file)1907*56bb7041Schristos elf_shlib_list_options (FILE *file)
1908*56bb7041Schristos {
1909*56bb7041Schristos   fprintf (file, _("\
1910*56bb7041Schristos   --audit=AUDITLIB            Specify a library to use for auditing\n"));
1911*56bb7041Schristos   fprintf (file, _("\
1912*56bb7041Schristos   -Bgroup                     Selects group name lookup rules for DSO\n"));
1913*56bb7041Schristos   fprintf (file, _("\
1914*56bb7041Schristos   --disable-new-dtags         Disable new dynamic tags\n"));
1915*56bb7041Schristos   fprintf (file, _("\
1916*56bb7041Schristos   --enable-new-dtags          Enable new dynamic tags\n"));
1917*56bb7041Schristos   fprintf (file, _("\
1918*56bb7041Schristos   --eh-frame-hdr              Create .eh_frame_hdr section\n"));
1919*56bb7041Schristos   fprintf (file, _("\
1920*56bb7041Schristos   --no-eh-frame-hdr           Do not create .eh_frame_hdr section\n"));
1921*56bb7041Schristos   fprintf (file, _("\
1922*56bb7041Schristos   --exclude-libs=LIBS         Make all symbols in LIBS hidden\n"));
1923*56bb7041Schristos   fprintf (file, _("\
1924*56bb7041Schristos   --hash-style=STYLE          Set hash style to sysv/gnu/both.  Default: "));
1925*56bb7041Schristos   if (DEFAULT_EMIT_SYSV_HASH)
1926*56bb7041Schristos     {
1927*56bb7041Schristos       /* Note - these strings are not translated as
1928*56bb7041Schristos 	 they are keywords not descriptive text.  */
1929*56bb7041Schristos       if (DEFAULT_EMIT_GNU_HASH)
1930*56bb7041Schristos 	fprintf (file, "both\n");
1931*56bb7041Schristos       else
1932*56bb7041Schristos 	fprintf (file, "sysv\n");
1933*56bb7041Schristos     }
1934*56bb7041Schristos   else
1935*56bb7041Schristos     {
1936*56bb7041Schristos       if (DEFAULT_EMIT_GNU_HASH)
1937*56bb7041Schristos 	fprintf (file, "gnu\n");
1938*56bb7041Schristos       else
1939*56bb7041Schristos 	/* FIXME: Can this happen ?  */
1940*56bb7041Schristos 	fprintf (file, "none\n");
1941*56bb7041Schristos     }
1942*56bb7041Schristos   fprintf (file, _("\
1943*56bb7041Schristos   -P AUDITLIB, --depaudit=AUDITLIB\n" "\
1944*56bb7041Schristos                               Specify a library to use for auditing dependencies\n"));
1945*56bb7041Schristos   fprintf (file, _("\
1946*56bb7041Schristos   -z combreloc                Merge dynamic relocs into one section and sort\n"));
1947*56bb7041Schristos   fprintf (file, _("\
1948*56bb7041Schristos   -z nocombreloc              Don't merge dynamic relocs into one section\n"));
1949*56bb7041Schristos   fprintf (file, _("\
1950*56bb7041Schristos   -z global                   Make symbols in DSO available for subsequently\n\
1951*56bb7041Schristos                                 loaded objects\n"));
1952*56bb7041Schristos   fprintf (file, _("\
1953*56bb7041Schristos   -z initfirst                Mark DSO to be initialized first at runtime\n"));
1954*56bb7041Schristos   fprintf (file, _("\
1955*56bb7041Schristos   -z interpose                Mark object to interpose all DSOs but executable\n"));
1956*56bb7041Schristos   fprintf (file, _("\
1957*56bb7041Schristos   -z lazy                     Mark object lazy runtime binding (default)\n"));
1958*56bb7041Schristos   fprintf (file, _("\
1959*56bb7041Schristos   -z loadfltr                 Mark object requiring immediate process\n"));
1960*56bb7041Schristos   fprintf (file, _("\
1961*56bb7041Schristos   -z nocopyreloc              Don't create copy relocs\n"));
1962*56bb7041Schristos   fprintf (file, _("\
1963*56bb7041Schristos   -z nodefaultlib             Mark object not to use default search paths\n"));
1964*56bb7041Schristos   fprintf (file, _("\
1965*56bb7041Schristos   -z nodelete                 Mark DSO non-deletable at runtime\n"));
1966*56bb7041Schristos   fprintf (file, _("\
1967*56bb7041Schristos   -z nodlopen                 Mark DSO not available to dlopen\n"));
1968*56bb7041Schristos   fprintf (file, _("\
1969*56bb7041Schristos   -z nodump                   Mark DSO not available to dldump\n"));
1970*56bb7041Schristos   fprintf (file, _("\
1971*56bb7041Schristos   -z now                      Mark object non-lazy runtime binding\n"));
1972*56bb7041Schristos   fprintf (file, _("\
1973*56bb7041Schristos   -z origin                   Mark object requiring immediate $ORIGIN\n\
1974*56bb7041Schristos                                 processing at runtime\n"));
1975*56bb7041Schristos #if DEFAULT_LD_Z_RELRO
1976*56bb7041Schristos   fprintf (file, _("\
1977*56bb7041Schristos   -z relro                    Create RELRO program header (default)\n"));
1978*56bb7041Schristos   fprintf (file, _("\
1979*56bb7041Schristos   -z norelro                  Don't create RELRO program header\n"));
1980*56bb7041Schristos #else
1981*56bb7041Schristos   fprintf (file, _("\
1982*56bb7041Schristos   -z relro                    Create RELRO program header\n"));
1983*56bb7041Schristos   fprintf (file, _("\
1984*56bb7041Schristos   -z norelro                  Don't create RELRO program header (default)\n"));
1985*56bb7041Schristos #endif
1986*56bb7041Schristos #if DEFAULT_LD_Z_SEPARATE_CODE
1987*56bb7041Schristos   fprintf (file, _("\
1988*56bb7041Schristos   -z separate-code            Create separate code program header (default)\n"));
1989*56bb7041Schristos   fprintf (file, _("\
1990*56bb7041Schristos   -z noseparate-code          Don't create separate code program header\n"));
1991*56bb7041Schristos #else
1992*56bb7041Schristos   fprintf (file, _("\
1993*56bb7041Schristos   -z separate-code            Create separate code program header\n"));
1994*56bb7041Schristos   fprintf (file, _("\
1995*56bb7041Schristos   -z noseparate-code          Don't create separate code program header (default)\n"));
1996*56bb7041Schristos #endif
1997*56bb7041Schristos   fprintf (file, _("\
1998*56bb7041Schristos   -z common                   Generate common symbols with STT_COMMON type\n"));
1999*56bb7041Schristos   fprintf (file, _("\
2000*56bb7041Schristos   -z nocommon                 Generate common symbols with STT_OBJECT type\n"));
2001*56bb7041Schristos   fprintf (file, _("\
2002*56bb7041Schristos   -z stack-size=SIZE          Set size of stack segment\n"));
2003*56bb7041Schristos   if (link_info.textrel_check == textrel_check_error)
2004*56bb7041Schristos     fprintf (file, _("\
2005*56bb7041Schristos   -z text                     Treat DT_TEXTREL in output as error (default)\n"));
2006*56bb7041Schristos   else
2007*56bb7041Schristos     fprintf (file, _("\
2008*56bb7041Schristos   -z text                     Treat DT_TEXTREL in output as error\n"));
2009*56bb7041Schristos   if (link_info.textrel_check == textrel_check_none)
2010*56bb7041Schristos     {
2011*56bb7041Schristos       fprintf (file, _("\
2012*56bb7041Schristos   -z notext                   Don't treat DT_TEXTREL in output as error (default)\n"));
2013*56bb7041Schristos       fprintf (file, _("\
2014*56bb7041Schristos   -z textoff                  Don't treat DT_TEXTREL in output as error (default)\n"));
2015*56bb7041Schristos     }
2016*56bb7041Schristos   else
2017*56bb7041Schristos     {
2018*56bb7041Schristos       fprintf (file, _("\
2019*56bb7041Schristos   -z notext                   Don't treat DT_TEXTREL in output as error\n"));
2020*56bb7041Schristos       fprintf (file, _("\
2021*56bb7041Schristos   -z textoff                  Don't treat DT_TEXTREL in output as error\n"));
2022*56bb7041Schristos     }
2023*56bb7041Schristos }
2024*56bb7041Schristos 
2025*56bb7041Schristos static void
elf_static_list_options(FILE * file)2026*56bb7041Schristos elf_static_list_options (FILE *file)
2027*56bb7041Schristos {
2028*56bb7041Schristos   fprintf (file, _("\
2029*56bb7041Schristos   --build-id[=STYLE]          Generate build ID note\n"));
2030*56bb7041Schristos   fprintf (file, _("\
2031*56bb7041Schristos   --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]\n\
2032*56bb7041Schristos                               Compress DWARF debug sections using zlib\n"));
2033*56bb7041Schristos #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
2034*56bb7041Schristos   fprintf (file, _("\
2035*56bb7041Schristos                                 Default: zlib-gabi\n"));
2036*56bb7041Schristos #else
2037*56bb7041Schristos   fprintf (file, _("\
2038*56bb7041Schristos                                 Default: none\n"));
2039*56bb7041Schristos #endif
2040*56bb7041Schristos   fprintf (file, _("\
2041*56bb7041Schristos   -z common-page-size=SIZE    Set common page size to SIZE\n"));
2042*56bb7041Schristos   fprintf (file, _("\
2043*56bb7041Schristos   -z max-page-size=SIZE       Set maximum page size to SIZE\n"));
2044*56bb7041Schristos   fprintf (file, _("\
2045*56bb7041Schristos   -z defs                     Report unresolved symbols in object files\n"));
2046*56bb7041Schristos   fprintf (file, _("\
2047*56bb7041Schristos   -z muldefs                  Allow multiple definitions\n"));
2048*56bb7041Schristos   fprintf (file, _("\
2049*56bb7041Schristos   -z execstack                Mark executable as requiring executable stack\n"));
2050*56bb7041Schristos   fprintf (file, _("\
2051*56bb7041Schristos   -z noexecstack              Mark executable as not requiring executable stack\n"));
2052*56bb7041Schristos   fprintf (file, _("\
2053*56bb7041Schristos   -z unique-symbol            Avoid duplicated local symbol names\n"));
2054*56bb7041Schristos   fprintf (file, _("\
2055*56bb7041Schristos   -z nounique-symbol          Keep duplicated local symbol names (default)\n"));
2056*56bb7041Schristos   fprintf (file, _("\
2057*56bb7041Schristos   -z globalaudit              Mark executable requiring global auditing\n"));
2058*56bb7041Schristos }
2059*56bb7041Schristos 
2060*56bb7041Schristos static void
elf_plt_unwind_list_options(FILE * file)2061*56bb7041Schristos elf_plt_unwind_list_options (FILE *file)
2062*56bb7041Schristos {
2063*56bb7041Schristos   fprintf (file, _("\
2064*56bb7041Schristos   --ld-generated-unwind-info  Generate exception handling info for PLT\n"));
2065*56bb7041Schristos   fprintf (file, _("\
2066*56bb7041Schristos   --no-ld-generated-unwind-info\n\
2067*56bb7041Schristos                               Don't generate exception handling info for PLT\n"));
2068*56bb7041Schristos }
2069*56bb7041Schristos 
2070*56bb7041Schristos static void
ld_list_options(FILE * file,bfd_boolean elf,bfd_boolean shlib,bfd_boolean plt_unwind)2071*56bb7041Schristos ld_list_options (FILE *file, bfd_boolean elf, bfd_boolean shlib,
2072*56bb7041Schristos 		 bfd_boolean plt_unwind)
2073*56bb7041Schristos {
2074*56bb7041Schristos   if (!elf)
2075*56bb7041Schristos     return;
2076*56bb7041Schristos   printf (_("ELF emulations:\n"));
2077*56bb7041Schristos   if (plt_unwind)
2078*56bb7041Schristos     elf_plt_unwind_list_options (file);
2079*56bb7041Schristos   elf_static_list_options (file);
2080*56bb7041Schristos   if (shlib)
2081*56bb7041Schristos     elf_shlib_list_options (file);
2082*56bb7041Schristos }
2083*56bb7041Schristos 
2084*56bb7041Schristos 
2085*56bb7041Schristos /* Print help messages for the options.  */
2086*56bb7041Schristos 
2087*56bb7041Schristos static void
help(void)2088*56bb7041Schristos help (void)
2089*56bb7041Schristos {
2090*56bb7041Schristos   unsigned i;
2091*56bb7041Schristos   const char **targets, **pp;
2092*56bb7041Schristos   int len;
2093*56bb7041Schristos 
2094*56bb7041Schristos   printf (_("Usage: %s [options] file...\n"), program_name);
2095*56bb7041Schristos 
2096*56bb7041Schristos   printf (_("Options:\n"));
2097*56bb7041Schristos   for (i = 0; i < OPTION_COUNT; i++)
2098*56bb7041Schristos     {
2099*56bb7041Schristos       if (ld_options[i].doc != NULL)
2100*56bb7041Schristos 	{
2101*56bb7041Schristos 	  bfd_boolean comma;
2102*56bb7041Schristos 	  unsigned j;
2103*56bb7041Schristos 
2104*56bb7041Schristos 	  printf ("  ");
2105*56bb7041Schristos 
2106*56bb7041Schristos 	  comma = FALSE;
2107*56bb7041Schristos 	  len = 2;
2108*56bb7041Schristos 
2109*56bb7041Schristos 	  j = i;
2110*56bb7041Schristos 	  do
2111*56bb7041Schristos 	    {
2112*56bb7041Schristos 	      if (ld_options[j].shortopt != '\0'
2113*56bb7041Schristos 		  && ld_options[j].control != NO_HELP)
2114*56bb7041Schristos 		{
2115*56bb7041Schristos 		  printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
2116*56bb7041Schristos 		  len += (comma ? 2 : 0) + 2;
2117*56bb7041Schristos 		  if (ld_options[j].arg != NULL)
2118*56bb7041Schristos 		    {
2119*56bb7041Schristos 		      if (ld_options[j].opt.has_arg != optional_argument)
2120*56bb7041Schristos 			{
2121*56bb7041Schristos 			  printf (" ");
2122*56bb7041Schristos 			  ++len;
2123*56bb7041Schristos 			}
2124*56bb7041Schristos 		      printf ("%s", _(ld_options[j].arg));
2125*56bb7041Schristos 		      len += strlen (_(ld_options[j].arg));
2126*56bb7041Schristos 		    }
2127*56bb7041Schristos 		  comma = TRUE;
2128*56bb7041Schristos 		}
2129*56bb7041Schristos 	      ++j;
2130*56bb7041Schristos 	    }
2131*56bb7041Schristos 	  while (j < OPTION_COUNT && ld_options[j].doc == NULL);
2132*56bb7041Schristos 
2133*56bb7041Schristos 	  j = i;
2134*56bb7041Schristos 	  do
2135*56bb7041Schristos 	    {
2136*56bb7041Schristos 	      if (ld_options[j].opt.name != NULL
2137*56bb7041Schristos 		  && ld_options[j].control != NO_HELP)
2138*56bb7041Schristos 		{
2139*56bb7041Schristos 		  int two_dashes =
2140*56bb7041Schristos 		    (ld_options[j].control == TWO_DASHES
2141*56bb7041Schristos 		     || ld_options[j].control == EXACTLY_TWO_DASHES);
2142*56bb7041Schristos 
2143*56bb7041Schristos 		  printf ("%s-%s%s",
2144*56bb7041Schristos 			  comma ? ", " : "",
2145*56bb7041Schristos 			  two_dashes ? "-" : "",
2146*56bb7041Schristos 			  ld_options[j].opt.name);
2147*56bb7041Schristos 		  len += ((comma ? 2 : 0)
2148*56bb7041Schristos 			  + 1
2149*56bb7041Schristos 			  + (two_dashes ? 1 : 0)
2150*56bb7041Schristos 			  + strlen (ld_options[j].opt.name));
2151*56bb7041Schristos 		  if (ld_options[j].arg != NULL)
2152*56bb7041Schristos 		    {
2153*56bb7041Schristos 		      printf (" %s", _(ld_options[j].arg));
2154*56bb7041Schristos 		      len += 1 + strlen (_(ld_options[j].arg));
2155*56bb7041Schristos 		    }
2156*56bb7041Schristos 		  comma = TRUE;
2157*56bb7041Schristos 		}
2158*56bb7041Schristos 	      ++j;
2159*56bb7041Schristos 	    }
2160*56bb7041Schristos 	  while (j < OPTION_COUNT && ld_options[j].doc == NULL);
2161*56bb7041Schristos 
2162*56bb7041Schristos 	  if (len >= 30)
2163*56bb7041Schristos 	    {
2164*56bb7041Schristos 	      printf ("\n");
2165*56bb7041Schristos 	      len = 0;
2166*56bb7041Schristos 	    }
2167*56bb7041Schristos 
2168*56bb7041Schristos 	  for (; len < 30; len++)
2169*56bb7041Schristos 	    putchar (' ');
2170*56bb7041Schristos 
2171*56bb7041Schristos 	  printf ("%s\n", _(ld_options[i].doc));
2172*56bb7041Schristos 	}
2173*56bb7041Schristos     }
2174*56bb7041Schristos   printf (_("  @FILE"));
2175*56bb7041Schristos   for (len = strlen ("  @FILE"); len < 30; len++)
2176*56bb7041Schristos     putchar (' ');
2177*56bb7041Schristos   printf (_("Read options from FILE\n"));
2178*56bb7041Schristos 
2179*56bb7041Schristos   /* Note: Various tools (such as libtool) depend upon the
2180*56bb7041Schristos      format of the listings below - do not change them.  */
2181*56bb7041Schristos   /* xgettext:c-format */
2182*56bb7041Schristos   printf (_("%s: supported targets:"), program_name);
2183*56bb7041Schristos   targets = bfd_target_list ();
2184*56bb7041Schristos   for (pp = targets; *pp != NULL; pp++)
2185*56bb7041Schristos     printf (" %s", *pp);
2186*56bb7041Schristos   free (targets);
2187*56bb7041Schristos   printf ("\n");
2188*56bb7041Schristos 
2189*56bb7041Schristos   /* xgettext:c-format */
2190*56bb7041Schristos   printf (_("%s: supported emulations: "), program_name);
2191*56bb7041Schristos   ldemul_list_emulations (stdout);
2192*56bb7041Schristos   printf ("\n");
2193*56bb7041Schristos 
2194*56bb7041Schristos   /* xgettext:c-format */
2195*56bb7041Schristos   printf (_("%s: emulation specific options:\n"), program_name);
2196*56bb7041Schristos   ld_list_options (stdout, ELF_LIST_OPTIONS, ELF_SHLIB_LIST_OPTIONS,
2197*56bb7041Schristos 		   ELF_PLT_UNWIND_LIST_OPTIONS);
2198*56bb7041Schristos   ldemul_list_emulation_options (stdout);
2199*56bb7041Schristos   printf ("\n");
2200*56bb7041Schristos 
2201*56bb7041Schristos   if (REPORT_BUGS_TO[0])
2202*56bb7041Schristos     printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);
2203*56bb7041Schristos }
2204