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