1 /* Parse options for the GNU linker.
2 Copyright (C) 1991-2020 Free Software Foundation, Inc.
4 This file is part of the GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
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.
16 You should have received a copy of the GNU General Public License
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. */
24 #include "libiberty.h"
25 #include "filenames.h"
29 #include "safe-ctype.h"
44 #if BFD_SUPPORTS_PLUGINS
46 #endif /* BFD_SUPPORTS_PLUGINS */
48 #ifndef PATH_SEPARATOR
49 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
50 #define PATH_SEPARATOR ';'
52 #define PATH_SEPARATOR ':'
56 /* Somewhere above, sys/stat.h got included . . . . */
57 #if !defined(S_ISDIR) && defined(S_IFDIR)
58 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
61 static void set_default_dirlist (char *);
62 static void set_section_start (char *, char *);
63 static void set_segment_start (const char *, char *);
64 static void help (void);
66 /* The long options. This structure is used for both the option
67 parsing and the help text. */
70 /* Use one dash before long option name. */
72 /* Use two dashes before long option name. */
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
84 /* Don't mention this option in --help output. */
90 /* The long option information. */
92 /* The short option with the same meaning ('\0' if none). */
94 /* The name of the argument (NULL if none). */
96 /* The documentation string. If this is NULL, this is a synonym for
97 the previous option. */
99 enum control_enum control
;
102 static const struct ld_option ld_options
[] =
104 { {NULL
, required_argument
, NULL
, '\0'},
105 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
107 { {"architecture", required_argument
, NULL
, 'A'},
108 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
109 { {"format", required_argument
, NULL
, 'b'},
110 'b', N_("TARGET"), N_("Specify target for following input files"),
112 { {"mri-script", required_argument
, NULL
, 'c'},
113 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
114 { {"dc", no_argument
, NULL
, 'd'},
115 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
116 { {"dp", no_argument
, NULL
, 'd'},
117 '\0', NULL
, NULL
, ONE_DASH
},
118 { {"dependency-file", required_argument
, NULL
, OPTION_DEPENDENCY_FILE
},
119 '\0', N_("FILE"), N_("Write dependency file"), TWO_DASHES
},
120 { {"force-group-allocation", no_argument
, NULL
,
121 OPTION_FORCE_GROUP_ALLOCATION
},
122 '\0', NULL
, N_("Force group members out of groups"), TWO_DASHES
},
123 { {"entry", required_argument
, NULL
, 'e'},
124 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
125 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
126 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
127 { {"no-export-dynamic", no_argument
, NULL
, OPTION_NO_EXPORT_DYNAMIC
},
128 '\0', NULL
, N_("Undo the effect of --export-dynamic"), TWO_DASHES
},
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
},
133 { {"EB", no_argument
, NULL
, OPTION_EB
},
134 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
135 { {"EL", no_argument
, NULL
, OPTION_EL
},
136 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
137 { {"auxiliary", required_argument
, NULL
, 'f'},
138 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
140 { {"filter", required_argument
, NULL
, 'F'},
141 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
143 { {NULL
, no_argument
, NULL
, '\0'},
144 'g', NULL
, N_("Ignored"), ONE_DASH
},
145 { {"gpsize", required_argument
, NULL
, 'G'},
146 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
148 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
149 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
150 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
151 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
153 { {"no-dynamic-linker", no_argument
, NULL
, OPTION_NO_DYNAMIC_LINKER
},
154 '\0', NULL
, N_("Produce an executable with no program interpreter header"),
156 { {"library", required_argument
, NULL
, 'l'},
157 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
158 { {"library-path", required_argument
, NULL
, 'L'},
159 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
161 { {"sysroot=<DIRECTORY>", required_argument
, NULL
, OPTION_SYSROOT
},
162 '\0', NULL
, N_("Override the default sysroot location"), TWO_DASHES
},
163 { {NULL
, required_argument
, NULL
, '\0'},
164 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
165 { {"print-map", no_argument
, NULL
, 'M'},
166 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
167 { {"nmagic", no_argument
, NULL
, 'n'},
168 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
169 { {"omagic", no_argument
, NULL
, 'N'},
170 'N', NULL
, N_("Do not page align data, do not make text readonly"),
171 EXACTLY_TWO_DASHES
},
172 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
173 '\0', NULL
, N_("Page align data, make text readonly"),
174 EXACTLY_TWO_DASHES
},
175 { {"output", required_argument
, NULL
, 'o'},
176 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
177 { {NULL
, required_argument
, NULL
, '\0'},
178 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
179 { {"out-implib", required_argument
, NULL
, OPTION_OUT_IMPLIB
},
180 '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES
},
181 #if BFD_SUPPORTS_PLUGINS
182 { {"plugin", required_argument
, NULL
, OPTION_PLUGIN
},
183 '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH
},
184 { {"plugin-opt", required_argument
, NULL
, OPTION_PLUGIN_OPT
},
185 '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH
},
186 { {"flto", optional_argument
, NULL
, OPTION_IGNORE
},
187 '\0', NULL
, N_("Ignored for GCC LTO option compatibility"),
189 { {"flto-partition=", required_argument
, NULL
, OPTION_IGNORE
},
190 '\0', NULL
, N_("Ignored for GCC LTO option compatibility"),
193 { {"plugin", required_argument
, NULL
, OPTION_IGNORE
},
194 '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH
},
195 { {"plugin-opt", required_argument
, NULL
, OPTION_IGNORE
},
196 '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH
},
197 #endif /* BFD_SUPPORTS_PLUGINS */
198 { {"fuse-ld=", required_argument
, NULL
, OPTION_IGNORE
},
199 '\0', NULL
, N_("Ignored for GCC linker option compatibility"),
201 { {"map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
202 '\0', NULL
, N_("Ignored for gold option compatibility"),
204 { {"no-map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
205 '\0', NULL
, N_("Ignored for gold option compatibility"),
207 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
208 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
209 { {"emit-relocs", no_argument
, NULL
, 'q'},
210 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
211 { {"relocatable", no_argument
, NULL
, 'r'},
212 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
213 { {NULL
, no_argument
, NULL
, '\0'},
214 'i', NULL
, NULL
, ONE_DASH
},
215 { {"just-symbols", required_argument
, NULL
, 'R'},
216 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
218 { {"strip-all", no_argument
, NULL
, 's'},
219 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
220 { {"strip-debug", no_argument
, NULL
, 'S'},
221 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
222 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
223 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
224 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
225 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
226 { {"trace", no_argument
, NULL
, 't'},
227 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
228 { {"script", required_argument
, NULL
, 'T'},
229 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
230 { {"default-script", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
231 '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES
},
232 { {"dT", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
233 '\0', NULL
, NULL
, ONE_DASH
},
234 { {"undefined", required_argument
, NULL
, 'u'},
235 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
237 { {"require-defined", required_argument
, NULL
, OPTION_REQUIRE_DEFINED_SYMBOL
},
238 '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
240 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
241 '\0', N_("[=SECTION]"),
242 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
243 { {"Ur", no_argument
, NULL
, OPTION_UR
},
244 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
245 { {"version", no_argument
, NULL
, OPTION_VERSION
},
246 'v', NULL
, N_("Print version information"), TWO_DASHES
},
247 { {NULL
, no_argument
, NULL
, '\0'},
248 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
249 { {"discard-all", no_argument
, NULL
, 'x'},
250 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
251 { {"discard-locals", no_argument
, NULL
, 'X'},
252 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
253 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
254 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
255 { {"trace-symbol", required_argument
, NULL
, 'y'},
256 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
257 { {NULL
, required_argument
, NULL
, '\0'},
258 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
260 { {"start-group", no_argument
, NULL
, '('},
261 '(', NULL
, N_("Start a group"), TWO_DASHES
},
262 { {"end-group", no_argument
, NULL
, ')'},
263 ')', NULL
, N_("End a group"), TWO_DASHES
},
264 { {"accept-unknown-input-arch", no_argument
, NULL
,
265 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
267 N_("Accept input files whose architecture cannot be determined"),
269 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
270 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
271 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
274 /* The next two options are deprecated because of their similarity to
275 --as-needed and --no-as-needed. They have been replaced by
276 --copy-dt-needed-entries and --no-copy-dt-needed-entries. */
277 { {"add-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
278 '\0', NULL
, NULL
, NO_HELP
},
279 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
280 '\0', NULL
, NULL
, NO_HELP
},
282 { {"as-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_REGULAR
},
283 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
285 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
},
286 '\0', NULL
, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
287 " the command line"),
289 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
290 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
291 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
292 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
293 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
294 '\0', NULL
, NULL
, ONE_DASH
},
295 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
296 '\0', NULL
, NULL
, ONE_DASH
},
297 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
298 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
299 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
300 '\0', NULL
, NULL
, ONE_DASH
},
301 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
302 '\0', NULL
, NULL
, ONE_DASH
},
303 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
304 '\0', NULL
, NULL
, ONE_DASH
},
305 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
306 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
307 { {"Bsymbolic-functions", no_argument
, NULL
, OPTION_SYMBOLIC_FUNCTIONS
},
308 '\0', NULL
, N_("Bind global function references locally"), ONE_DASH
},
309 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
310 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
312 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
313 '\0', NULL
, N_("Do not check section addresses for overlaps"),
315 { {"copy-dt-needed-entries", no_argument
, NULL
,
316 OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
317 '\0', NULL
, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
319 { {"no-copy-dt-needed-entries", no_argument
, NULL
,
320 OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
321 '\0', NULL
, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
324 { {"cref", no_argument
, NULL
, OPTION_CREF
},
325 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
326 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
327 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
328 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
329 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
331 { {"disable-multiple-abs-defs", no_argument
, NULL
,
332 OPTION_DISABLE_MULTIPLE_DEFS_ABS
},
333 '\0', NULL
, N_("Do not allow multiple definitions with symbols included\n"
334 " in filename invoked by -R or --just-symbols"),
336 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
337 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
338 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
339 '\0', NULL
, N_("Treat warnings as errors"),
341 { {"no-fatal-warnings", no_argument
, NULL
, OPTION_NO_WARN_FATAL
},
342 '\0', NULL
, N_("Do not treat warnings as errors (default)"),
344 { {"fini", required_argument
, NULL
, OPTION_FINI
},
345 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
346 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
347 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
348 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
349 '\0', NULL
, N_("Remove unused sections (on some targets)"),
351 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
352 '\0', NULL
, N_("Don't remove unused sections (default)"),
354 { {"print-gc-sections", no_argument
, NULL
, OPTION_PRINT_GC_SECTIONS
},
355 '\0', NULL
, N_("List removed unused sections on stderr"),
357 { {"no-print-gc-sections", no_argument
, NULL
, OPTION_NO_PRINT_GC_SECTIONS
},
358 '\0', NULL
, N_("Do not list removed unused sections"),
360 { {"gc-keep-exported", no_argument
, NULL
, OPTION_GC_KEEP_EXPORTED
},
361 '\0', NULL
, N_("Keep exported symbols when removing unused sections"),
363 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
364 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
366 { {"help", no_argument
, NULL
, OPTION_HELP
},
367 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
368 { {"init", required_argument
, NULL
, OPTION_INIT
},
369 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
370 { {"Map", required_argument
, NULL
, OPTION_MAP
},
371 '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH
},
372 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
373 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
374 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
375 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
376 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
377 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
378 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
379 '\0', NULL
, N_("Do not allow unresolved references in object files"),
381 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
382 '\0', NULL
, N_("Allow unresolved references in shared libraries"),
384 { {"no-allow-shlib-undefined", no_argument
, NULL
,
385 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
386 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
388 { {"allow-multiple-definition", no_argument
, NULL
,
389 OPTION_ALLOW_MULTIPLE_DEFINITION
},
390 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
391 #if SUPPORT_ERROR_HANDLING_SCRIPT
392 { {"error-handling-script", required_argument
, NULL
,
393 OPTION_ERROR_HANDLING_SCRIPT
},
394 '\0', N_("SCRIPT"), N_("Provide a script to help with undefined symbol errors"), TWO_DASHES
},
396 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
397 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
398 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
399 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
400 { {"default-imported-symver", no_argument
, NULL
,
401 OPTION_DEFAULT_IMPORTED_SYMVER
},
402 '\0', NULL
, N_("Create default symbol version for imported symbols"),
404 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
405 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
406 { {"no-warn-search-mismatch", no_argument
, NULL
,
407 OPTION_NO_WARN_SEARCH_MISMATCH
},
408 '\0', NULL
, N_("Don't warn on finding an incompatible library"),
410 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
411 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
412 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
413 '\0', NULL
, N_("Create an output file even if errors occur"),
415 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
416 '\0', NULL
, NULL
, NO_HELP
},
417 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
418 '\0', NULL
, N_("Only use library directories specified on\n"
419 " the command line"),
421 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
422 '\0', N_("TARGET"), N_("Specify target of output file"),
423 EXACTLY_TWO_DASHES
},
424 { {"print-output-format", no_argument
, NULL
, OPTION_PRINT_OUTPUT_FORMAT
},
425 '\0', NULL
, N_("Print default output format"), TWO_DASHES
},
426 { {"print-sysroot", no_argument
, NULL
, OPTION_PRINT_SYSROOT
},
427 '\0', NULL
, N_("Print current sysroot"), TWO_DASHES
},
428 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
429 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
430 { {"reduce-memory-overheads", no_argument
, NULL
,
431 OPTION_REDUCE_MEMORY_OVERHEADS
},
432 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
434 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
435 '\0', NULL
, N_("Reduce code size by using target specific optimizations"), TWO_DASHES
},
436 { {"no-relax", no_argument
, NULL
, OPTION_NO_RELAX
},
437 '\0', NULL
, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES
},
438 { {"retain-symbols-file", required_argument
, NULL
,
439 OPTION_RETAIN_SYMBOLS_FILE
},
440 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
441 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
442 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
443 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
444 '\0', N_("PATH"), N_("Set link time shared library search path"),
446 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
447 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
448 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
449 '\0', NULL
, NULL
, ONE_DASH
},
450 { {"pie", no_argument
, NULL
, OPTION_PIE
},
451 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
452 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
453 '\0', NULL
, NULL
, TWO_DASHES
},
454 { {"sort-common", optional_argument
, NULL
, OPTION_SORT_COMMON
},
455 '\0', N_("[=ascending|descending]"),
456 N_("Sort common symbols by alignment [in specified order]"),
458 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
459 '\0', NULL
, NULL
, NO_HELP
},
460 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
461 '\0', N_("name|alignment"),
462 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
463 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
464 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
466 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
467 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
469 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
470 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
472 { {"stats", no_argument
, NULL
, OPTION_STATS
},
473 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
474 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
475 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
476 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
477 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
478 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
479 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
480 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
481 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
483 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
484 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
485 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
486 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
487 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
488 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
489 { {"Ttext-segment", required_argument
, NULL
, OPTION_TTEXT_SEGMENT
},
490 '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH
},
491 { {"Trodata-segment", required_argument
, NULL
, OPTION_TRODATA_SEGMENT
},
492 '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH
},
493 { {"Tldata-segment", required_argument
, NULL
, OPTION_TLDATA_SEGMENT
},
494 '\0', N_("ADDRESS"), N_("Set address of ldata segment"), ONE_DASH
},
495 { {"unresolved-symbols=<method>", required_argument
, NULL
,
496 OPTION_UNRESOLVED_SYMBOLS
},
497 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
498 " ignore-all, report-all, ignore-in-object-files,\n"
499 " ignore-in-shared-libs"),
501 { {"verbose", optional_argument
, NULL
, OPTION_VERBOSE
},
502 '\0', N_("[=NUMBER]"),
503 N_("Output lots of information during link"), TWO_DASHES
},
504 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
505 '\0', NULL
, NULL
, NO_HELP
},
506 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
507 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
508 { {"version-exports-section", required_argument
, NULL
,
509 OPTION_VERSION_EXPORTS_SECTION
},
510 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
511 " SYMBOL as the version."),
513 { {"dynamic-list-data", no_argument
, NULL
, OPTION_DYNAMIC_LIST_DATA
},
514 '\0', NULL
, N_("Add data symbols to dynamic list"), TWO_DASHES
},
515 { {"dynamic-list-cpp-new", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_NEW
},
516 '\0', NULL
, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES
},
517 { {"dynamic-list-cpp-typeinfo", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_TYPEINFO
},
518 '\0', NULL
, N_("Use C++ typeinfo dynamic list"), TWO_DASHES
},
519 { {"dynamic-list", required_argument
, NULL
, OPTION_DYNAMIC_LIST
},
520 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES
},
521 { {"export-dynamic-symbol", required_argument
, NULL
, OPTION_EXPORT_DYNAMIC_SYMBOL
},
522 '\0', N_("SYMBOL"), N_("Export the specified symbol"), EXACTLY_TWO_DASHES
},
523 { {"export-dynamic-symbol-list", required_argument
, NULL
, OPTION_EXPORT_DYNAMIC_SYMBOL_LIST
},
524 '\0', N_("FILE"), N_("Read export dynamic symbol list"), EXACTLY_TWO_DASHES
},
525 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
526 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
527 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
528 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
530 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
531 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
532 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
533 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
534 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
535 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
537 { {"warn-textrel", no_argument
, NULL
, OPTION_WARN_TEXTREL
},
539 #if DEFAULT_LD_TEXTREL_CHECK_WARNING
540 N_("Warn if output has DT_TEXTREL (default)"),
542 N_("Warn if output has DT_TEXTREL"),
545 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_TEXTREL
},
546 '\0', NULL
, NULL
, NO_HELP
},
547 { {"warn-alternate-em", no_argument
, NULL
, OPTION_WARN_ALTERNATE_EM
},
548 '\0', NULL
, N_("Warn if an object has alternate ELF machine code"),
550 { {"warn-unresolved-symbols", no_argument
, NULL
,
551 OPTION_WARN_UNRESOLVED_SYMBOLS
},
552 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
553 { {"error-unresolved-symbols", no_argument
, NULL
,
554 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
555 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
556 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
557 '\0', NULL
, N_("Include all objects from following archives"),
559 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
560 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
561 { {"ignore-unresolved-symbol", required_argument
, NULL
,
562 OPTION_IGNORE_UNRESOLVED_SYMBOL
},
564 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES
},
565 { {"push-state", no_argument
, NULL
, OPTION_PUSH_STATE
},
566 '\0', NULL
, N_("Push state of flags governing input file handling"),
568 { {"pop-state", no_argument
, NULL
, OPTION_POP_STATE
},
569 '\0', NULL
, N_("Pop state of flags governing input file handling"),
571 { {"print-memory-usage", no_argument
, NULL
, OPTION_PRINT_MEMORY_USAGE
},
572 '\0', NULL
, N_("Report target memory usage"), TWO_DASHES
},
573 { {"orphan-handling", required_argument
, NULL
, OPTION_ORPHAN_HANDLING
},
574 '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
576 { {"print-map-discarded", no_argument
, NULL
, OPTION_PRINT_MAP_DISCARDED
},
577 '\0', NULL
, N_("Show discarded sections in map file output (default)"),
579 { {"no-print-map-discarded", no_argument
, NULL
, OPTION_NO_PRINT_MAP_DISCARDED
},
580 '\0', NULL
, N_("Do not show discarded sections in map file output"),
582 { {"ctf-variables", no_argument
, NULL
, OPTION_CTF_VARIABLES
},
583 '\0', NULL
, N_("Emit names and types of static variables in CTF"),
585 { {"no-ctf-variables", no_argument
, NULL
, OPTION_NO_CTF_VARIABLES
},
586 '\0', NULL
, N_("Do not emit names and types of static variables in CTF"),
588 { {"ctf-share-types=<method>", required_argument
, NULL
,
589 OPTION_CTF_SHARE_TYPES
},
590 '\0', NULL
, N_("How to share CTF types between translation units.\n"
591 " <method> is: share-unconflicted (default),\n"
592 " share-duplicated"),
596 #define OPTION_COUNT ARRAY_SIZE (ld_options)
599 parse_args (unsigned argc
, char **argv
)
604 char *default_dirlist
= NULL
;
606 struct option
*longopts
;
607 struct option
*really_longopts
;
614 } opt_symbolic
= symbolic_unset
;
615 enum dynamic_list_enum
617 dynamic_list_unset
= 0,
620 } opt_dynamic_list
= dynamic_list_unset
;
621 struct bfd_elf_dynamic_list
*export_list
= NULL
;
623 shortopts
= (char *) xmalloc (OPTION_COUNT
* 3 + 2);
624 longopts
= (struct option
*)
625 xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
626 really_longopts
= (struct option
*)
627 xmalloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
629 /* Starting the short option string with '-' is for programs that
630 expect options and other ARGV-elements in any order and that care about
631 the ordering of the two. We describe each non-option ARGV-element
632 as if it were the argument of an option with character code 1. */
637 for (i
= 0; i
< OPTION_COUNT
; i
++)
639 if (ld_options
[i
].shortopt
!= '\0')
641 shortopts
[is
] = ld_options
[i
].shortopt
;
643 if (ld_options
[i
].opt
.has_arg
== required_argument
644 || ld_options
[i
].opt
.has_arg
== optional_argument
)
648 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
655 if (ld_options
[i
].opt
.name
!= NULL
)
657 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
659 really_longopts
[irl
] = ld_options
[i
].opt
;
664 longopts
[il
] = ld_options
[i
].opt
;
669 shortopts
[is
] = '\0';
670 longopts
[il
].name
= NULL
;
671 really_longopts
[irl
].name
= NULL
;
673 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
675 /* The -G option is ambiguous on different platforms. Sometimes it
676 specifies the largest data size to put into the small data
677 section. Sometimes it is equivalent to --shared. Unfortunately,
678 the first form takes an argument, while the second does not.
680 We need to permit the --shared form because on some platforms,
681 such as Solaris, gcc -shared will pass -G to the linker.
683 To permit either usage, we look through the argument list. If we
684 find -G not followed by a number, we change it into --shared.
685 This will work for most normal cases. */
686 for (i
= 1; i
< argc
; i
++)
687 if (strcmp (argv
[i
], "-G") == 0
689 || ! ISDIGIT (argv
[i
+ 1][0])))
690 argv
[i
] = (char *) "--shared";
692 /* Because we permit long options to start with a single dash, and
693 we have a --library option, and the -l option is conventionally
694 used with an immediately following argument, we can have bad
695 results if somebody tries to use -l with a library whose name
696 happens to start with "ibrary", as in -li. We avoid problems by
697 simply turning -l into --library. This means that users will
698 have to use two dashes in order to use --library, which is OK
699 since that's how it is documented.
701 FIXME: It's possible that this problem can arise for other short
702 options as well, although the user does always have the recourse
703 of adding a space between the option and the argument. */
704 for (i
= 1; i
< argc
; i
++)
706 if (argv
[i
][0] == '-'
708 && argv
[i
][2] != '\0')
712 n
= (char *) xmalloc (strlen (argv
[i
]) + 20);
713 sprintf (n
, "--library=%s", argv
[i
] + 2);
723 static unsigned int defsym_count
;
725 /* Using last_optind lets us avoid calling ldemul_parse_args
726 multiple times on a single option, which would lead to
727 confusion in the internal static variables maintained by
728 getopt. This could otherwise happen for an argument like
729 -nx, in which the -n is parsed as a single option, and we
730 loop around to pick up the -x. */
731 if (optind
!= last_optind
)
732 if (ldemul_parse_args (argc
, argv
))
735 /* getopt_long_only is like getopt_long, but '-' as well as '--'
736 can indicate a long option. */
738 last_optind
= optind
;
739 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
742 optind
= last_optind
;
743 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
745 /* Attempt to detect grouped short options, eg: "-non-start".
746 Accepting such options is error prone as it is not clear if the user
747 intended "-n -o n-start" or "--non-start". */
748 else if (longind
== 0 /* This is a short option. */
749 && optc
> 32 /* It is a valid option. */
750 /* The character is not the second character of argv[last_optind]. */
751 && optc
!= argv
[last_optind
][1])
754 einfo (_("%F%P: Error: unable to disambiguate: %s (did you mean -%s ?)\n"),
755 argv
[last_optind
], argv
[last_optind
]);
757 einfo (_("%P: Warning: grouped short command line options are deprecated: %s\n"), argv
[last_optind
]);
760 if (ldemul_handle_option (optc
))
770 /* If the last word on the command line is an option that
771 requires an argument, getopt will refuse to recognise it.
772 Try to catch such options here and issue a more helpful
773 error message than just "unrecognized option". */
776 for (opt
= ARRAY_SIZE (ld_options
); opt
--;)
777 if (ld_options
[opt
].opt
.has_arg
== required_argument
778 /* FIXME: There are a few short options that do not
779 have long equivalents, but which require arguments.
780 We should handle them too. */
781 && ld_options
[opt
].opt
.name
!= NULL
782 && strcmp (argv
[last_optind
] + ld_options
[opt
].control
, ld_options
[opt
].opt
.name
) == 0)
784 einfo (_("%P: %s: missing argument\n"), argv
[last_optind
]);
789 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
794 einfo (_("%F%P: use the --help option for usage information\n"));
797 case 1: /* File name. */
798 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
804 /* For HP/UX compatibility. Actually -a shared should mean
805 ``use only shared libraries'' but, then, we don't
806 currently support shared libraries on HP/UX anyhow. */
807 if (strcmp (optarg
, "archive") == 0)
808 input_flags
.dynamic
= FALSE
;
809 else if (strcmp (optarg
, "shared") == 0
810 || strcmp (optarg
, "default") == 0)
811 input_flags
.dynamic
= TRUE
;
813 einfo (_("%F%P: unrecognized -a option `%s'\n"), optarg
);
816 /* FIXME: We just ignore these, but we should handle them. */
817 if (strcmp (optarg
, "definitions") == 0)
819 else if (strcmp (optarg
, "nodefinitions") == 0)
821 else if (strcmp (optarg
, "nosymbolic") == 0)
823 else if (strcmp (optarg
, "pure-text") == 0)
826 einfo (_("%F%P: unrecognized -assert option `%s'\n"), optarg
);
829 ldfile_add_arch (optarg
);
832 lang_add_target (optarg
);
835 ldfile_open_command_file (optarg
);
836 parser_input
= input_mri_script
;
839 case OPTION_CALL_SHARED
:
840 input_flags
.dynamic
= TRUE
;
842 case OPTION_NON_SHARED
:
843 input_flags
.dynamic
= FALSE
;
846 command_line
.cref
= TRUE
;
847 link_info
.notice_all
= TRUE
;
850 command_line
.force_common_definition
= TRUE
;
852 case OPTION_FORCE_GROUP_ALLOCATION
:
853 command_line
.force_group_allocation
= TRUE
;
857 lex_redirect (optarg
, "--defsym", ++defsym_count
);
858 parser_input
= input_defsym
;
862 case OPTION_DEMANGLE
:
866 enum demangling_styles style
;
868 style
= cplus_demangle_name_to_style (optarg
);
869 if (style
== unknown_demangling
)
870 einfo (_("%F%P: unknown demangling style `%s'\n"),
873 cplus_demangle_set_style (style
);
876 case 'I': /* Used on Solaris. */
877 case OPTION_DYNAMIC_LINKER
:
878 command_line
.interpreter
= optarg
;
879 link_info
.nointerp
= 0;
881 case OPTION_NO_DYNAMIC_LINKER
:
882 link_info
.nointerp
= 1;
885 /* Already handled in ldmain.c. */
888 command_line
.endian
= ENDIAN_BIG
;
891 command_line
.endian
= ENDIAN_LITTLE
;
893 case OPTION_EMBEDDED_RELOCS
:
894 command_line
.embedded_relocs
= TRUE
;
896 case OPTION_EXPORT_DYNAMIC
:
897 case 'E': /* HP/UX compatibility. */
898 link_info
.export_dynamic
= TRUE
;
900 case OPTION_NO_EXPORT_DYNAMIC
:
901 link_info
.export_dynamic
= FALSE
;
903 case OPTION_NON_CONTIGUOUS_REGIONS
:
904 link_info
.non_contiguous_regions
= TRUE
;
906 case OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS
:
907 link_info
.non_contiguous_regions_warnings
= TRUE
;
910 lang_add_entry (optarg
, TRUE
);
913 if (command_line
.auxiliary_filters
== NULL
)
915 command_line
.auxiliary_filters
= (char **)
916 xmalloc (2 * sizeof (char *));
917 command_line
.auxiliary_filters
[0] = optarg
;
918 command_line
.auxiliary_filters
[1] = NULL
;
926 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
928 command_line
.auxiliary_filters
= (char **)
929 xrealloc (command_line
.auxiliary_filters
,
930 (c
+ 2) * sizeof (char *));
931 command_line
.auxiliary_filters
[c
] = optarg
;
932 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
936 command_line
.filter_shlib
= optarg
;
938 case OPTION_FORCE_EXE_SUFFIX
:
939 command_line
.force_exe_suffix
= TRUE
;
944 g_switch_value
= strtoul (optarg
, &end
, 0);
946 einfo (_("%F%P: invalid number `%s'\n"), optarg
);
952 case OPTION_GC_SECTIONS
:
953 link_info
.gc_sections
= TRUE
;
955 case OPTION_PRINT_GC_SECTIONS
:
956 link_info
.print_gc_sections
= TRUE
;
958 case OPTION_GC_KEEP_EXPORTED
:
959 link_info
.gc_keep_exported
= TRUE
;
966 ldfile_add_library_path (optarg
, TRUE
);
969 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
972 config
.map_filename
= "-";
975 /* Ignore. Was handled in a pre-parse. */
978 config
.map_filename
= optarg
;
981 config
.text_read_only
= FALSE
;
982 config
.magic_demand_paged
= FALSE
;
983 input_flags
.dynamic
= FALSE
;
985 case OPTION_NO_OMAGIC
:
986 config
.text_read_only
= TRUE
;
987 config
.magic_demand_paged
= TRUE
;
988 /* NB/ Does not set input_flags.dynamic to TRUE.
989 Use --call-shared or -Bdynamic for this. */
992 config
.text_read_only
= TRUE
;
993 config
.magic_demand_paged
= FALSE
;
994 input_flags
.dynamic
= FALSE
;
996 case OPTION_NO_DEFINE_COMMON
:
997 link_info
.inhibit_common_definition
= TRUE
;
999 case OPTION_NO_DEMANGLE
:
1002 case OPTION_NO_GC_SECTIONS
:
1003 link_info
.gc_sections
= FALSE
;
1005 case OPTION_NO_PRINT_GC_SECTIONS
:
1006 link_info
.print_gc_sections
= FALSE
;
1008 case OPTION_NO_KEEP_MEMORY
:
1009 link_info
.keep_memory
= FALSE
;
1011 case OPTION_NO_UNDEFINED
:
1012 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1014 case OPTION_ALLOW_SHLIB_UNDEFINED
:
1015 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1017 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
1018 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1020 case OPTION_UNRESOLVED_SYMBOLS
:
1021 if (strcmp (optarg
, "ignore-all") == 0)
1023 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1024 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1026 else if (strcmp (optarg
, "report-all") == 0)
1028 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1029 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1031 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
1033 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1034 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1036 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
1038 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1039 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1042 einfo (_("%F%P: bad --unresolved-symbols option: %s\n"), optarg
);
1044 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
1045 link_info
.warn_unresolved_syms
= TRUE
;
1047 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
1048 link_info
.warn_unresolved_syms
= FALSE
;
1050 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
1051 link_info
.allow_multiple_definition
= TRUE
;
1054 #if SUPPORT_ERROR_HANDLING_SCRIPT
1055 case OPTION_ERROR_HANDLING_SCRIPT
:
1056 /* FIXME: Should we warn if the script is being overridden by another ?
1057 Or maybe they should be chained together ? */
1058 error_handling_script
= optarg
;
1062 case OPTION_NO_UNDEFINED_VERSION
:
1063 link_info
.allow_undefined_version
= FALSE
;
1065 case OPTION_DEFAULT_SYMVER
:
1066 link_info
.create_default_symver
= TRUE
;
1068 case OPTION_DEFAULT_IMPORTED_SYMVER
:
1069 link_info
.default_imported_symver
= TRUE
;
1071 case OPTION_NO_WARN_MISMATCH
:
1072 command_line
.warn_mismatch
= FALSE
;
1074 case OPTION_NO_WARN_SEARCH_MISMATCH
:
1075 command_line
.warn_search_mismatch
= FALSE
;
1077 case OPTION_NOINHIBIT_EXEC
:
1078 force_make_executable
= TRUE
;
1080 case OPTION_NOSTDLIB
:
1081 config
.only_cmd_line_lib_dirs
= TRUE
;
1083 case OPTION_NO_WHOLE_ARCHIVE
:
1084 input_flags
.whole_archive
= FALSE
;
1087 /* FIXME "-O<non-digits> <value>" used to set the address of
1088 section <non-digits>. Was this for compatibility with
1089 something, or can we create a new option to do that
1090 (with a syntax similar to -defsym)?
1091 getopt can't handle two args to an option without kludges. */
1093 /* Enable optimizations of output files. */
1094 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
1097 lang_add_output (optarg
, 0);
1099 case OPTION_OFORMAT
:
1100 lang_add_output_format (optarg
, NULL
, NULL
, 0);
1102 case OPTION_OUT_IMPLIB
:
1103 command_line
.out_implib_filename
= xstrdup (optarg
);
1105 case OPTION_PRINT_SYSROOT
:
1110 case OPTION_PRINT_OUTPUT_FORMAT
:
1111 command_line
.print_output_format
= TRUE
;
1113 #if BFD_SUPPORTS_PLUGINS
1115 plugin_opt_plugin (optarg
);
1117 case OPTION_PLUGIN_OPT
:
1118 if (plugin_opt_plugin_arg (optarg
))
1119 einfo (_("%F%P: bad -plugin-opt option\n"));
1121 #endif /* BFD_SUPPORTS_PLUGINS */
1123 link_info
.emitrelocations
= TRUE
;
1127 if (optind
== last_optind
)
1128 /* This can happen if the user put "-rpath,a" on the command
1129 line. (Or something similar. The comma is important).
1130 Getopt becomes confused and thinks that this is a -r option
1131 but it cannot parse the text after the -r so it refuses to
1132 increment the optind counter. Detect this case and issue
1133 an error message here. We cannot just make this a warning,
1134 increment optind, and continue because getopt is too confused
1135 and will seg-fault the next time around. */
1136 einfo(_("%F%P: unrecognised option: %s\n"), argv
[optind
]);
1138 if (bfd_link_pic (&link_info
))
1139 einfo (_("%F%P: -r and %s may not be used together\n"),
1140 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1142 link_info
.type
= type_relocatable
;
1143 config
.build_constructors
= FALSE
;
1144 config
.magic_demand_paged
= FALSE
;
1145 config
.text_read_only
= FALSE
;
1146 input_flags
.dynamic
= FALSE
;
1149 /* The GNU linker traditionally uses -R to mean to include
1150 only the symbols from a file. The Solaris linker uses -R
1151 to set the path used by the runtime linker to find
1152 libraries. This is the GNU linker -rpath argument. We
1153 try to support both simultaneously by checking the file
1154 named. If it is a directory, rather than a regular file,
1155 we assume -rpath was meant. */
1159 if (stat (optarg
, &s
) >= 0
1160 && ! S_ISDIR (s
.st_mode
))
1162 lang_add_input_file (optarg
,
1163 lang_input_file_is_symbols_only_enum
,
1170 if (command_line
.rpath
== NULL
)
1171 command_line
.rpath
= xstrdup (optarg
);
1174 size_t rpath_len
= strlen (command_line
.rpath
);
1175 size_t optarg_len
= strlen (optarg
);
1177 char *cp
= command_line
.rpath
;
1179 /* First see whether OPTARG is already in the path. */
1182 if (strncmp (optarg
, cp
, optarg_len
) == 0
1183 && (cp
[optarg_len
] == 0
1184 || cp
[optarg_len
] == config
.rpath_separator
))
1188 /* Not yet found. */
1189 cp
= strchr (cp
, config
.rpath_separator
);
1197 buf
= (char *) xmalloc (rpath_len
+ optarg_len
+ 2);
1198 sprintf (buf
, "%s%c%s", command_line
.rpath
,
1199 config
.rpath_separator
, optarg
);
1200 free (command_line
.rpath
);
1201 command_line
.rpath
= buf
;
1205 case OPTION_RPATH_LINK
:
1206 if (command_line
.rpath_link
== NULL
)
1207 command_line
.rpath_link
= xstrdup (optarg
);
1212 buf
= (char *) xmalloc (strlen (command_line
.rpath_link
)
1215 sprintf (buf
, "%s%c%s", command_line
.rpath_link
,
1216 config
.rpath_separator
, optarg
);
1217 free (command_line
.rpath_link
);
1218 command_line
.rpath_link
= buf
;
1221 case OPTION_NO_RELAX
:
1227 case OPTION_RETAIN_SYMBOLS_FILE
:
1228 add_keepsyms_file (optarg
);
1231 link_info
.strip
= strip_debugger
;
1234 link_info
.strip
= strip_all
;
1236 case OPTION_STRIP_DISCARDED
:
1237 link_info
.strip_discarded
= TRUE
;
1239 case OPTION_NO_STRIP_DISCARDED
:
1240 link_info
.strip_discarded
= FALSE
;
1242 case OPTION_DISABLE_MULTIPLE_DEFS_ABS
:
1243 link_info
.prohibit_multiple_definition_absolute
= TRUE
;
1246 if (config
.has_shared
)
1248 if (bfd_link_relocatable (&link_info
))
1249 einfo (_("%F%P: -r and %s may not be used together\n"),
1252 link_info
.type
= type_dll
;
1253 /* When creating a shared library, the default
1254 behaviour is to ignore any unresolved references. */
1255 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1256 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1257 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1258 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1261 einfo (_("%F%P: -shared not supported\n"));
1264 if (config
.has_shared
)
1266 if (bfd_link_relocatable (&link_info
))
1267 einfo (_("%F%P: -r and %s may not be used together\n"), "-pie");
1269 link_info
.type
= type_pie
;
1272 einfo (_("%F%P: -pie not supported\n"));
1274 case 'h': /* Used on Solaris. */
1276 if (optarg
[0] == '\0' && command_line
.soname
1277 && command_line
.soname
[0])
1278 einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
1280 command_line
.soname
= optarg
;
1282 case OPTION_SORT_COMMON
:
1284 || strcmp (optarg
, N_("descending")) == 0)
1285 config
.sort_common
= sort_descending
;
1286 else if (strcmp (optarg
, N_("ascending")) == 0)
1287 config
.sort_common
= sort_ascending
;
1289 einfo (_("%F%P: invalid common section sorting option: %s\n"),
1292 case OPTION_SORT_SECTION
:
1293 if (strcmp (optarg
, N_("name")) == 0)
1294 sort_section
= by_name
;
1295 else if (strcmp (optarg
, N_("alignment")) == 0)
1296 sort_section
= by_alignment
;
1298 einfo (_("%F%P: invalid section sorting option: %s\n"),
1302 config
.stats
= TRUE
;
1304 case OPTION_SYMBOLIC
:
1305 opt_symbolic
= symbolic
;
1307 case OPTION_SYMBOLIC_FUNCTIONS
:
1308 opt_symbolic
= symbolic_functions
;
1314 previous_script_handle
= saved_script_handle
;
1315 ldfile_open_script_file (optarg
);
1316 parser_input
= input_script
;
1318 previous_script_handle
= NULL
;
1320 case OPTION_DEFAULT_SCRIPT
:
1321 command_line
.default_script
= optarg
;
1323 case OPTION_SECTION_START
:
1329 /* Check for <something>=<somthing>... */
1330 optarg2
= strchr (optarg
, '=');
1331 if (optarg2
== NULL
)
1332 einfo (_("%F%P: invalid argument to option"
1333 " \"--section-start\"\n"));
1337 /* So far so good. Are all the args present? */
1338 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1339 einfo (_("%F%P: missing argument(s) to option"
1340 " \"--section-start\"\n"));
1342 /* We must copy the section name as set_section_start
1343 doesn't do it for us. */
1344 len
= optarg2
- optarg
;
1345 sec_name
= (char *) xmalloc (len
);
1346 memcpy (sec_name
, optarg
, len
- 1);
1347 sec_name
[len
- 1] = 0;
1349 /* Then set it... */
1350 set_section_start (sec_name
, optarg2
);
1353 case OPTION_TARGET_HELP
:
1354 /* Mention any target specific options. */
1355 ldemul_list_emulation_options (stdout
);
1358 set_segment_start (".bss", optarg
);
1361 set_segment_start (".data", optarg
);
1364 set_segment_start (".text", optarg
);
1366 case OPTION_TTEXT_SEGMENT
:
1367 set_segment_start (".text-segment", optarg
);
1369 case OPTION_TRODATA_SEGMENT
:
1370 set_segment_start (".rodata-segment", optarg
);
1372 case OPTION_TLDATA_SEGMENT
:
1373 set_segment_start (".ldata-segment", optarg
);
1375 case OPTION_TRADITIONAL_FORMAT
:
1376 link_info
.traditional_format
= TRUE
;
1378 case OPTION_TASK_LINK
:
1379 link_info
.task_link
= TRUE
;
1382 if (bfd_link_pic (&link_info
))
1383 einfo (_("%F%P: -r and %s may not be used together\n"),
1384 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1386 link_info
.type
= type_relocatable
;
1387 config
.build_constructors
= TRUE
;
1388 config
.magic_demand_paged
= FALSE
;
1389 config
.text_read_only
= FALSE
;
1390 input_flags
.dynamic
= FALSE
;
1393 ldlang_add_undef (optarg
, TRUE
);
1395 case OPTION_REQUIRE_DEFINED_SYMBOL
:
1396 ldlang_add_require_defined (optarg
);
1400 lang_add_unique (optarg
);
1402 config
.unique_orphan_sections
= TRUE
;
1404 case OPTION_VERBOSE
:
1406 version_printed
= TRUE
;
1408 overflow_cutoff_limit
= -2;
1412 int level ATTRIBUTE_UNUSED
= strtoul (optarg
, &end
, 0);
1414 einfo (_("%F%P: invalid number `%s'\n"), optarg
);
1415 #if BFD_SUPPORTS_PLUGINS
1416 report_plugin_symbols
= level
> 1;
1417 #endif /* BFD_SUPPORTS_PLUGINS */
1422 version_printed
= TRUE
;
1426 version_printed
= TRUE
;
1428 case OPTION_VERSION
:
1432 case OPTION_VERSION_SCRIPT
:
1433 /* This option indicates a small script that only specifies
1434 version information. Read it, but don't assume that
1435 we've seen a linker script. */
1437 FILE *hold_script_handle
;
1439 hold_script_handle
= saved_script_handle
;
1440 ldfile_open_command_file (optarg
);
1441 saved_script_handle
= hold_script_handle
;
1442 parser_input
= input_version_script
;
1446 case OPTION_VERSION_EXPORTS_SECTION
:
1447 /* This option records a version symbol to be applied to the
1448 symbols listed for export to be found in the object files
1449 .exports sections. */
1450 command_line
.version_exports_section
= optarg
;
1452 case OPTION_DYNAMIC_LIST_DATA
:
1453 opt_dynamic_list
= dynamic_list_data
;
1455 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO
:
1456 lang_append_dynamic_list_cpp_typeinfo ();
1457 if (opt_dynamic_list
!= dynamic_list_data
)
1458 opt_dynamic_list
= dynamic_list
;
1460 case OPTION_DYNAMIC_LIST_CPP_NEW
:
1461 lang_append_dynamic_list_cpp_new ();
1462 if (opt_dynamic_list
!= dynamic_list_data
)
1463 opt_dynamic_list
= dynamic_list
;
1465 case OPTION_DYNAMIC_LIST
:
1466 /* This option indicates a small script that only specifies
1467 a dynamic list. Read it, but don't assume that we've
1468 seen a linker script. */
1470 FILE *hold_script_handle
;
1472 hold_script_handle
= saved_script_handle
;
1473 ldfile_open_command_file (optarg
);
1474 saved_script_handle
= hold_script_handle
;
1475 parser_input
= input_dynamic_list
;
1476 current_dynamic_list_p
= &link_info
.dynamic_list
;
1479 if (opt_dynamic_list
!= dynamic_list_data
)
1480 opt_dynamic_list
= dynamic_list
;
1482 case OPTION_EXPORT_DYNAMIC_SYMBOL
:
1484 struct bfd_elf_version_expr
*expr
1485 = lang_new_vers_pattern (NULL
, xstrdup (optarg
), NULL
,
1487 lang_append_dynamic_list (&export_list
, expr
);
1490 case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST
:
1491 /* This option indicates a small script that only specifies
1492 an export list. Read it, but don't assume that we've
1493 seen a linker script. */
1495 FILE *hold_script_handle
;
1497 hold_script_handle
= saved_script_handle
;
1498 ldfile_open_command_file (optarg
);
1499 saved_script_handle
= hold_script_handle
;
1500 parser_input
= input_dynamic_list
;
1501 current_dynamic_list_p
= &export_list
;
1505 case OPTION_WARN_COMMON
:
1506 config
.warn_common
= TRUE
;
1508 case OPTION_WARN_CONSTRUCTORS
:
1509 config
.warn_constructors
= TRUE
;
1511 case OPTION_WARN_FATAL
:
1512 config
.fatal_warnings
= TRUE
;
1514 case OPTION_NO_WARN_FATAL
:
1515 config
.fatal_warnings
= FALSE
;
1517 case OPTION_WARN_MULTIPLE_GP
:
1518 config
.warn_multiple_gp
= TRUE
;
1520 case OPTION_WARN_ONCE
:
1521 config
.warn_once
= TRUE
;
1523 case OPTION_WARN_SECTION_ALIGN
:
1524 config
.warn_section_align
= TRUE
;
1526 case OPTION_WARN_TEXTREL
:
1527 link_info
.textrel_check
= textrel_check_warning
;
1529 case OPTION_WARN_ALTERNATE_EM
:
1530 link_info
.warn_alternate_em
= TRUE
;
1532 case OPTION_WHOLE_ARCHIVE
:
1533 input_flags
.whole_archive
= TRUE
;
1535 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
:
1536 input_flags
.add_DT_NEEDED_for_dynamic
= TRUE
;
1538 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
:
1539 input_flags
.add_DT_NEEDED_for_dynamic
= FALSE
;
1541 case OPTION_ADD_DT_NEEDED_FOR_REGULAR
:
1542 input_flags
.add_DT_NEEDED_for_regular
= TRUE
;
1544 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
:
1545 input_flags
.add_DT_NEEDED_for_regular
= FALSE
;
1550 case OPTION_IGNORE_UNRESOLVED_SYMBOL
:
1551 add_ignoresym (&link_info
, optarg
);
1553 case OPTION_DISCARD_NONE
:
1554 link_info
.discard
= discard_none
;
1557 link_info
.discard
= discard_l
;
1560 link_info
.discard
= discard_all
;
1563 if (CONST_STRNEQ (optarg
, "P,"))
1565 free (default_dirlist
);
1566 default_dirlist
= xstrdup (optarg
);
1571 case OPTION_SPARE_DYNAMIC_TAGS
:
1572 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1574 case OPTION_SPLIT_BY_RELOC
:
1576 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1578 config
.split_by_reloc
= 32768;
1580 case OPTION_SPLIT_BY_FILE
:
1582 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1584 config
.split_by_file
= 1;
1586 case OPTION_CHECK_SECTIONS
:
1587 command_line
.check_section_addresses
= 1;
1589 case OPTION_NO_CHECK_SECTIONS
:
1590 command_line
.check_section_addresses
= 0;
1592 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1593 command_line
.accept_unknown_input_arch
= TRUE
;
1595 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1596 command_line
.accept_unknown_input_arch
= FALSE
;
1599 lang_enter_group ();
1604 einfo (_("%F%P: group ended before it began (--help for usage)\n"));
1606 lang_leave_group ();
1611 link_info
.init_function
= optarg
;
1615 link_info
.fini_function
= optarg
;
1618 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1619 link_info
.reduce_memory_overheads
= TRUE
;
1620 if (config
.hash_table_size
== 0)
1621 config
.hash_table_size
= 1021;
1624 case OPTION_HASH_SIZE
:
1626 bfd_size_type new_size
;
1628 new_size
= strtoul (optarg
, NULL
, 0);
1630 config
.hash_table_size
= new_size
;
1632 einfo (_("%X%P: --hash-size needs a numeric argument\n"));
1636 case OPTION_PUSH_STATE
:
1637 input_flags
.pushed
= xmemdup (&input_flags
,
1638 sizeof (input_flags
),
1639 sizeof (input_flags
));
1642 case OPTION_POP_STATE
:
1643 if (input_flags
.pushed
== NULL
)
1644 einfo (_("%F%P: no state pushed before popping\n"));
1647 struct lang_input_statement_flags
*oldp
= input_flags
.pushed
;
1648 memcpy (&input_flags
, oldp
, sizeof (input_flags
));
1653 case OPTION_PRINT_MEMORY_USAGE
:
1654 command_line
.print_memory_usage
= TRUE
;
1657 case OPTION_ORPHAN_HANDLING
:
1658 if (strcasecmp (optarg
, "place") == 0)
1659 config
.orphan_handling
= orphan_handling_place
;
1660 else if (strcasecmp (optarg
, "warn") == 0)
1661 config
.orphan_handling
= orphan_handling_warn
;
1662 else if (strcasecmp (optarg
, "error") == 0)
1663 config
.orphan_handling
= orphan_handling_error
;
1664 else if (strcasecmp (optarg
, "discard") == 0)
1665 config
.orphan_handling
= orphan_handling_discard
;
1667 einfo (_("%F%P: invalid argument to option"
1668 " \"--orphan-handling\"\n"));
1671 case OPTION_NO_PRINT_MAP_DISCARDED
:
1672 config
.print_map_discarded
= FALSE
;
1675 case OPTION_PRINT_MAP_DISCARDED
:
1676 config
.print_map_discarded
= TRUE
;
1679 case OPTION_DEPENDENCY_FILE
:
1680 config
.dependency_file
= optarg
;
1683 case OPTION_CTF_VARIABLES
:
1684 config
.ctf_variables
= TRUE
;
1687 case OPTION_NO_CTF_VARIABLES
:
1688 config
.ctf_variables
= FALSE
;
1691 case OPTION_CTF_SHARE_TYPES
:
1692 if (strcmp (optarg
, "share-unconflicted") == 0)
1693 config
.ctf_share_duplicated
= FALSE
;
1694 else if (strcmp (optarg
, "share-duplicated") == 0)
1695 config
.ctf_share_duplicated
= TRUE
;
1697 einfo (_("%F%P: bad --ctf-share-types option: %s\n"), optarg
);
1702 /* Run a couple of checks on the map filename. */
1703 if (config
.map_filename
)
1705 char * new_name
= NULL
;
1709 if (config
.map_filename
[0] == 0)
1711 einfo (_("%P: no file/directory name provided for map output; ignored\n"));
1712 config
.map_filename
= NULL
;
1714 else if (strcmp (config
.map_filename
, "-") == 0)
1715 ; /* Write to stdout. Handled in main(). */
1716 else if ((percent
= strchr (config
.map_filename
, '%')) != NULL
)
1718 /* FIXME: Check for a second % character and issue an error ? */
1720 /* Construct a map file by replacing the % character with the (full)
1721 output filename. If the % character was the last character in
1722 the original map filename then add a .map extension. */
1724 res
= asprintf (&new_name
, "%s%s%s", config
.map_filename
,
1726 percent
[1] ? percent
+ 1 : ".map");
1728 /* FIXME: Should we ensure that any directory components in new_name exist ? */
1734 /* If the map filename is actually a directory then create
1735 a file inside it, based upon the output filename. */
1736 if (stat (config
.map_filename
, &s
) < 0)
1738 if (errno
!= ENOENT
)
1739 einfo (_("%P: cannot stat linker map file: %E\n"));
1741 else if (S_ISDIR (s
.st_mode
))
1743 char lastc
= config
.map_filename
[strlen (config
.map_filename
) - 1];
1744 res
= asprintf (&new_name
, "%s%s%s.map",
1745 config
.map_filename
,
1746 IS_DIR_SEPARATOR (lastc
) ? "" : "/",
1747 lbasename (output_filename
));
1749 else if (! S_ISREG (s
.st_mode
))
1751 einfo (_("%P: linker map file is not a regular file\n"));
1752 config
.map_filename
= NULL
;
1754 /* else FIXME: Check write permission ? */
1759 /* If the asprintf failed then something is probably very
1760 wrong. Better to halt now rather than continue on
1761 into more problems. */
1762 einfo (_("%P%F: cannot create name for linker map file: %E\n"));
1764 else if (new_name
!= NULL
)
1766 /* This is a trivial memory leak. */
1767 config
.map_filename
= new_name
;
1771 if (command_line
.soname
&& command_line
.soname
[0] == '\0')
1773 einfo (_("%P: SONAME must not be empty string; ignored\n"));
1774 command_line
.soname
= NULL
;
1779 einfo (_("%P: missing --end-group; added as last command line option\n"));
1780 lang_leave_group ();
1784 if (default_dirlist
!= NULL
)
1786 set_default_dirlist (default_dirlist
);
1787 free (default_dirlist
);
1790 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1791 /* FIXME: Should we allow emulations a chance to set this ? */
1792 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1794 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1795 /* FIXME: Should we allow emulations a chance to set this ? */
1796 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1798 if (bfd_link_relocatable (&link_info
)
1799 && command_line
.check_section_addresses
< 0)
1800 command_line
.check_section_addresses
= 0;
1804 struct bfd_elf_version_expr
*head
= export_list
->head
.list
;
1805 struct bfd_elf_version_expr
*next
;
1807 /* For --export-dynamic-symbol[-list]:
1808 1. When building executable, treat like --dynamic-list.
1809 2. When building shared object:
1810 a. If -Bsymbolic or --dynamic-list are used, treat like
1812 b. Otherwise, ignored.
1814 if (!bfd_link_relocatable (&link_info
)
1815 && (bfd_link_executable (&link_info
)
1816 || opt_symbolic
!= symbolic_unset
1817 || opt_dynamic_list
!= dynamic_list_unset
))
1819 /* Append the export list to link_info.dynamic_list. */
1820 if (link_info
.dynamic_list
)
1822 for (next
= head
; next
->next
!= NULL
; next
= next
->next
)
1824 next
->next
= link_info
.dynamic_list
->head
.list
;
1825 link_info
.dynamic_list
->head
.list
= head
;
1828 link_info
.dynamic_list
= export_list
;
1830 if (opt_dynamic_list
!= dynamic_list_data
)
1831 opt_dynamic_list
= dynamic_list
;
1835 /* Free the export list. */
1836 for (; head
->next
!= NULL
; head
= next
)
1845 switch (opt_dynamic_list
)
1847 case dynamic_list_unset
:
1849 case dynamic_list_data
:
1850 link_info
.dynamic_data
= TRUE
;
1853 link_info
.dynamic
= TRUE
;
1854 opt_symbolic
= symbolic_unset
;
1858 /* -Bsymbolic and -Bsymbols-functions are for shared library output. */
1859 if (bfd_link_dll (&link_info
))
1860 switch (opt_symbolic
)
1862 case symbolic_unset
:
1865 link_info
.symbolic
= TRUE
;
1866 if (link_info
.dynamic_list
)
1868 struct bfd_elf_version_expr
*ent
, *next
;
1869 for (ent
= link_info
.dynamic_list
->head
.list
; ent
; ent
= next
)
1874 free (link_info
.dynamic_list
);
1875 link_info
.dynamic_list
= NULL
;
1878 case symbolic_functions
:
1879 link_info
.dynamic
= TRUE
;
1880 link_info
.dynamic_data
= TRUE
;
1884 if (!bfd_link_dll (&link_info
))
1886 if (command_line
.filter_shlib
)
1887 einfo (_("%F%P: -F may not be used without -shared\n"));
1888 if (command_line
.auxiliary_filters
)
1889 einfo (_("%F%P: -f may not be used without -shared\n"));
1892 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
1893 don't see how else this can be handled, since in this case we
1894 must preserve all externally visible symbols. */
1895 if (bfd_link_relocatable (&link_info
) && link_info
.strip
== strip_all
)
1897 link_info
.strip
= strip_debugger
;
1898 if (link_info
.discard
== discard_sec_merge
)
1899 link_info
.discard
= discard_all
;
1903 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1904 library search path. */
1907 set_default_dirlist (char *dirlist_ptr
)
1913 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1916 if (*dirlist_ptr
!= '\0')
1917 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1920 dirlist_ptr
= p
+ 1;
1925 set_section_start (char *sect
, char *valstr
)
1928 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1930 einfo (_("%F%P: invalid hex number `%s'\n"), valstr
);
1931 lang_section_start (sect
, exp_intop (val
), NULL
);
1935 set_segment_start (const char *section
, char *valstr
)
1941 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1943 einfo (_("%F%P: invalid hex number `%s'\n"), valstr
);
1944 /* If we already have an entry for this segment, update the existing
1947 for (seg
= segments
; seg
; seg
= seg
->next
)
1948 if (strcmp (seg
->name
, name
) == 0)
1951 lang_section_start (section
, exp_intop (val
), seg
);
1954 /* There was no existing value so we must create a new segment
1956 seg
= stat_alloc (sizeof (*seg
));
1960 /* Add it to the linked list of segments. */
1961 seg
->next
= segments
;
1963 /* Historically, -Ttext and friends set the base address of a
1964 particular section. For backwards compatibility, we still do
1965 that. If a SEGMENT_START directive is seen, the section address
1966 assignment will be disabled. */
1967 lang_section_start (section
, exp_intop (val
), seg
);
1971 elf_shlib_list_options (FILE *file
)
1974 --audit=AUDITLIB Specify a library to use for auditing\n"));
1976 -Bgroup Selects group name lookup rules for DSO\n"));
1978 --disable-new-dtags Disable new dynamic tags\n"));
1980 --enable-new-dtags Enable new dynamic tags\n"));
1982 --eh-frame-hdr Create .eh_frame_hdr section\n"));
1984 --no-eh-frame-hdr Do not create .eh_frame_hdr section\n"));
1986 --exclude-libs=LIBS Make all symbols in LIBS hidden\n"));
1988 --hash-style=STYLE Set hash style to sysv/gnu/both. Default: "));
1989 if (DEFAULT_EMIT_SYSV_HASH
)
1991 /* Note - these strings are not translated as
1992 they are keywords not descriptive text. */
1993 if (DEFAULT_EMIT_GNU_HASH
)
1994 fprintf (file
, "both\n");
1996 fprintf (file
, "sysv\n");
2000 if (DEFAULT_EMIT_GNU_HASH
)
2001 fprintf (file
, "gnu\n");
2003 /* FIXME: Can this happen ? */
2004 fprintf (file
, "none\n");
2007 -P AUDITLIB, --depaudit=AUDITLIB\n" "\
2008 Specify a library to use for auditing dependencies\n"));
2010 -z combreloc Merge dynamic relocs into one section and sort\n"));
2012 -z nocombreloc Don't merge dynamic relocs into one section\n"));
2014 -z global Make symbols in DSO available for subsequently\n\
2015 loaded objects\n"));
2017 -z initfirst Mark DSO to be initialized first at runtime\n"));
2019 -z interpose Mark object to interpose all DSOs but executable\n"));
2021 -z lazy Mark object lazy runtime binding (default)\n"));
2023 -z loadfltr Mark object requiring immediate process\n"));
2025 -z nocopyreloc Don't create copy relocs\n"));
2027 -z nodefaultlib Mark object not to use default search paths\n"));
2029 -z nodelete Mark DSO non-deletable at runtime\n"));
2031 -z nodlopen Mark DSO not available to dlopen\n"));
2033 -z nodump Mark DSO not available to dldump\n"));
2035 -z now Mark object non-lazy runtime binding\n"));
2037 -z origin Mark object requiring immediate $ORIGIN\n\
2038 processing at runtime\n"));
2039 #if DEFAULT_LD_Z_RELRO
2041 -z relro Create RELRO program header (default)\n"));
2043 -z norelro Don't create RELRO program header\n"));
2046 -z relro Create RELRO program header\n"));
2048 -z norelro Don't create RELRO program header (default)\n"));
2050 #if DEFAULT_LD_Z_SEPARATE_CODE
2052 -z separate-code Create separate code program header (default)\n"));
2054 -z noseparate-code Don't create separate code program header\n"));
2057 -z separate-code Create separate code program header\n"));
2059 -z noseparate-code Don't create separate code program header (default)\n"));
2062 -z common Generate common symbols with STT_COMMON type\n"));
2064 -z nocommon Generate common symbols with STT_OBJECT type\n"));
2066 -z stack-size=SIZE Set size of stack segment\n"));
2067 if (link_info
.textrel_check
== textrel_check_error
)
2069 -z text Treat DT_TEXTREL in output as error (default)\n"));
2072 -z text Treat DT_TEXTREL in output as error\n"));
2073 if (link_info
.textrel_check
== textrel_check_none
)
2076 -z notext Don't treat DT_TEXTREL in output as error (default)\n"));
2078 -z textoff Don't treat DT_TEXTREL in output as error (default)\n"));
2083 -z notext Don't treat DT_TEXTREL in output as error\n"));
2085 -z textoff Don't treat DT_TEXTREL in output as error\n"));
2090 elf_static_list_options (FILE *file
)
2093 --build-id[=STYLE] Generate build ID note\n"));
2095 --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]\n\
2096 Compress DWARF debug sections using zlib\n"));
2097 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
2099 Default: zlib-gabi\n"));
2105 -z common-page-size=SIZE Set common page size to SIZE\n"));
2107 -z max-page-size=SIZE Set maximum page size to SIZE\n"));
2109 -z defs Report unresolved symbols in object files\n"));
2111 -z muldefs Allow multiple definitions\n"));
2113 -z execstack Mark executable as requiring executable stack\n"));
2115 -z noexecstack Mark executable as not requiring executable stack\n"));
2117 -z unique-symbol Avoid duplicated local symbol names\n"));
2119 -z nounique-symbol Keep duplicated local symbol names (default)\n"));
2121 -z globalaudit Mark executable requiring global auditing\n"));
2125 elf_plt_unwind_list_options (FILE *file
)
2128 --ld-generated-unwind-info Generate exception handling info for PLT\n"));
2130 --no-ld-generated-unwind-info\n\
2131 Don't generate exception handling info for PLT\n"));
2135 ld_list_options (FILE *file
, bfd_boolean elf
, bfd_boolean shlib
,
2136 bfd_boolean plt_unwind
)
2140 printf (_("ELF emulations:\n"));
2142 elf_plt_unwind_list_options (file
);
2143 elf_static_list_options (file
);
2145 elf_shlib_list_options (file
);
2149 /* Print help messages for the options. */
2155 const char **targets
, **pp
;
2158 printf (_("Usage: %s [options] file...\n"), program_name
);
2160 printf (_("Options:\n"));
2161 for (i
= 0; i
< OPTION_COUNT
; i
++)
2163 if (ld_options
[i
].doc
!= NULL
)
2176 if (ld_options
[j
].shortopt
!= '\0'
2177 && ld_options
[j
].control
!= NO_HELP
)
2179 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
2180 len
+= (comma
? 2 : 0) + 2;
2181 if (ld_options
[j
].arg
!= NULL
)
2183 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
2188 printf ("%s", _(ld_options
[j
].arg
));
2189 len
+= strlen (_(ld_options
[j
].arg
));
2195 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
2200 if (ld_options
[j
].opt
.name
!= NULL
2201 && ld_options
[j
].control
!= NO_HELP
)
2204 (ld_options
[j
].control
== TWO_DASHES
2205 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
2209 two_dashes
? "-" : "",
2210 ld_options
[j
].opt
.name
);
2211 len
+= ((comma
? 2 : 0)
2213 + (two_dashes
? 1 : 0)
2214 + strlen (ld_options
[j
].opt
.name
));
2215 if (ld_options
[j
].arg
!= NULL
)
2217 printf (" %s", _(ld_options
[j
].arg
));
2218 len
+= 1 + strlen (_(ld_options
[j
].arg
));
2224 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
2232 for (; len
< 30; len
++)
2235 printf ("%s\n", _(ld_options
[i
].doc
));
2238 printf (_(" @FILE"));
2239 for (len
= strlen (" @FILE"); len
< 30; len
++)
2241 printf (_("Read options from FILE\n"));
2243 /* Note: Various tools (such as libtool) depend upon the
2244 format of the listings below - do not change them. */
2245 /* xgettext:c-format */
2246 printf (_("%s: supported targets:"), program_name
);
2247 targets
= bfd_target_list ();
2248 for (pp
= targets
; *pp
!= NULL
; pp
++)
2249 printf (" %s", *pp
);
2253 /* xgettext:c-format */
2254 printf (_("%s: supported emulations: "), program_name
);
2255 ldemul_list_emulations (stdout
);
2258 /* xgettext:c-format */
2259 printf (_("%s: emulation specific options:\n"), program_name
);
2260 ld_list_options (stdout
, ELF_LIST_OPTIONS
, ELF_SHLIB_LIST_OPTIONS
,
2261 ELF_PLT_UNWIND_LIST_OPTIONS
);
2262 ldemul_list_emulation_options (stdout
);
2265 if (REPORT_BUGS_TO
[0])
2266 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);