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