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