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"
27 #include "safe-ctype.h"
42 #if BFD_SUPPORTS_PLUGINS
44 #endif /* BFD_SUPPORTS_PLUGINS */
46 #ifndef PATH_SEPARATOR
47 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
48 #define PATH_SEPARATOR ';'
50 #define PATH_SEPARATOR ':'
54 /* Somewhere above, sys/stat.h got included . . . . */
55 #if !defined(S_ISDIR) && defined(S_IFDIR)
56 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
59 static void set_default_dirlist (char *);
60 static void set_section_start (char *, char *);
61 static void set_segment_start (const char *, char *);
62 static void help (void);
64 /* The long options. This structure is used for both the option
65 parsing and the help text. */
68 /* Use one dash before long option name. */
70 /* Use two dashes before long option name. */
72 /* Only accept two dashes before the long option name.
73 This is an overloading of the use of this enum, since originally it
74 was only intended to tell the --help display function how to display
75 the long option name. This feature was added in order to resolve
76 the confusion about the -omagic command line switch. Is it setting
77 the output file name to "magic" or is it setting the NMAGIC flag on
78 the output ? It has been decided that it is setting the output file
79 name, and that if you want to set the NMAGIC flag you should use -N
82 /* Don't mention this option in --help output. */
88 /* The long option information. */
90 /* The short option with the same meaning ('\0' if none). */
92 /* The name of the argument (NULL if none). */
94 /* The documentation string. If this is NULL, this is a synonym for
95 the previous option. */
97 enum control_enum control
;
100 static const struct ld_option ld_options
[] =
102 { {NULL
, required_argument
, NULL
, '\0'},
103 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
105 { {"architecture", required_argument
, NULL
, 'A'},
106 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
107 { {"format", required_argument
, NULL
, 'b'},
108 'b', N_("TARGET"), N_("Specify target for following input files"),
110 { {"mri-script", required_argument
, NULL
, 'c'},
111 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
112 { {"dc", no_argument
, NULL
, 'd'},
113 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
114 { {"dp", no_argument
, NULL
, 'd'},
115 '\0', NULL
, NULL
, ONE_DASH
},
116 { {"dependency-file", required_argument
, NULL
, OPTION_DEPENDENCY_FILE
},
117 '\0', N_("FILE"), N_("Write dependency file"), TWO_DASHES
},
118 { {"force-group-allocation", no_argument
, NULL
,
119 OPTION_FORCE_GROUP_ALLOCATION
},
120 '\0', NULL
, N_("Force group members out of groups"), TWO_DASHES
},
121 { {"entry", required_argument
, NULL
, 'e'},
122 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
123 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
124 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
125 { {"no-export-dynamic", no_argument
, NULL
, OPTION_NO_EXPORT_DYNAMIC
},
126 '\0', NULL
, N_("Undo the effect of --export-dynamic"), TWO_DASHES
},
127 { {"enable-non-contiguous-regions", no_argument
, NULL
, OPTION_NON_CONTIGUOUS_REGIONS
},
128 '\0', NULL
, N_("Enable support of non-contiguous memory regions"), TWO_DASHES
},
129 { {"enable-non-contiguous-regions-warnings", no_argument
, NULL
, OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS
},
130 '\0', NULL
, N_("Enable warnings when --enable-non-contiguous-regions may cause unexpected behaviour"), TWO_DASHES
},
131 { {"EB", no_argument
, NULL
, OPTION_EB
},
132 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
133 { {"EL", no_argument
, NULL
, OPTION_EL
},
134 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
135 { {"auxiliary", required_argument
, NULL
, 'f'},
136 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
138 { {"filter", required_argument
, NULL
, 'F'},
139 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
141 { {NULL
, no_argument
, NULL
, '\0'},
142 'g', NULL
, N_("Ignored"), ONE_DASH
},
143 { {"gpsize", required_argument
, NULL
, 'G'},
144 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
146 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
147 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
148 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
149 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
151 { {"no-dynamic-linker", no_argument
, NULL
, OPTION_NO_DYNAMIC_LINKER
},
152 '\0', NULL
, N_("Produce an executable with no program interpreter header"),
154 { {"library", required_argument
, NULL
, 'l'},
155 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
156 { {"library-path", required_argument
, NULL
, 'L'},
157 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
159 { {"sysroot=<DIRECTORY>", required_argument
, NULL
, OPTION_SYSROOT
},
160 '\0', NULL
, N_("Override the default sysroot location"), TWO_DASHES
},
161 { {NULL
, required_argument
, NULL
, '\0'},
162 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
163 { {"print-map", no_argument
, NULL
, 'M'},
164 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
165 { {"nmagic", no_argument
, NULL
, 'n'},
166 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
167 { {"omagic", no_argument
, NULL
, 'N'},
168 'N', NULL
, N_("Do not page align data, do not make text readonly"),
169 EXACTLY_TWO_DASHES
},
170 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
171 '\0', NULL
, N_("Page align data, make text readonly"),
172 EXACTLY_TWO_DASHES
},
173 { {"output", required_argument
, NULL
, 'o'},
174 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
175 { {NULL
, required_argument
, NULL
, '\0'},
176 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
177 { {"out-implib", required_argument
, NULL
, OPTION_OUT_IMPLIB
},
178 '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES
},
179 #if BFD_SUPPORTS_PLUGINS
180 { {"plugin", required_argument
, NULL
, OPTION_PLUGIN
},
181 '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH
},
182 { {"plugin-opt", required_argument
, NULL
, OPTION_PLUGIN_OPT
},
183 '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH
},
184 { {"flto", optional_argument
, NULL
, OPTION_IGNORE
},
185 '\0', NULL
, N_("Ignored for GCC LTO option compatibility"),
187 { {"flto-partition=", required_argument
, NULL
, OPTION_IGNORE
},
188 '\0', NULL
, N_("Ignored for GCC LTO option compatibility"),
191 { {"plugin", required_argument
, NULL
, OPTION_IGNORE
},
192 '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH
},
193 { {"plugin-opt", required_argument
, NULL
, OPTION_IGNORE
},
194 '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH
},
195 #endif /* BFD_SUPPORTS_PLUGINS */
196 { {"fuse-ld=", required_argument
, NULL
, OPTION_IGNORE
},
197 '\0', NULL
, N_("Ignored for GCC linker option compatibility"),
199 { {"map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
200 '\0', NULL
, N_("Ignored for gold option compatibility"),
202 { {"no-map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
203 '\0', NULL
, N_("Ignored for gold option compatibility"),
205 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
206 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
207 { {"emit-relocs", no_argument
, NULL
, 'q'},
208 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
209 { {"relocatable", no_argument
, NULL
, 'r'},
210 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
211 { {NULL
, no_argument
, NULL
, '\0'},
212 'i', NULL
, NULL
, ONE_DASH
},
213 { {"just-symbols", required_argument
, NULL
, 'R'},
214 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
216 { {"strip-all", no_argument
, NULL
, 's'},
217 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
218 { {"strip-debug", no_argument
, NULL
, 'S'},
219 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
220 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
221 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
222 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
223 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
224 { {"trace", no_argument
, NULL
, 't'},
225 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
226 { {"script", required_argument
, NULL
, 'T'},
227 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
228 { {"default-script", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
229 '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES
},
230 { {"dT", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
231 '\0', NULL
, NULL
, ONE_DASH
},
232 { {"undefined", required_argument
, NULL
, 'u'},
233 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
235 { {"require-defined", required_argument
, NULL
, OPTION_REQUIRE_DEFINED_SYMBOL
},
236 '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
238 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
239 '\0', N_("[=SECTION]"),
240 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
241 { {"Ur", no_argument
, NULL
, OPTION_UR
},
242 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
243 { {"version", no_argument
, NULL
, OPTION_VERSION
},
244 'v', NULL
, N_("Print version information"), TWO_DASHES
},
245 { {NULL
, no_argument
, NULL
, '\0'},
246 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
247 { {"discard-all", no_argument
, NULL
, 'x'},
248 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
249 { {"discard-locals", no_argument
, NULL
, 'X'},
250 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
251 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
252 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
253 { {"trace-symbol", required_argument
, NULL
, 'y'},
254 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
255 { {NULL
, required_argument
, NULL
, '\0'},
256 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
258 { {"start-group", no_argument
, NULL
, '('},
259 '(', NULL
, N_("Start a group"), TWO_DASHES
},
260 { {"end-group", no_argument
, NULL
, ')'},
261 ')', NULL
, N_("End a group"), TWO_DASHES
},
262 { {"accept-unknown-input-arch", no_argument
, NULL
,
263 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
265 N_("Accept input files whose architecture cannot be determined"),
267 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
268 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
269 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
272 /* The next two options are deprecated because of their similarity to
273 --as-needed and --no-as-needed. They have been replaced by
274 --copy-dt-needed-entries and --no-copy-dt-needed-entries. */
275 { {"add-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
276 '\0', NULL
, NULL
, NO_HELP
},
277 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
278 '\0', NULL
, NULL
, NO_HELP
},
280 { {"as-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_REGULAR
},
281 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
283 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
},
284 '\0', NULL
, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
285 " the command line"),
287 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
288 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
289 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
290 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
291 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
292 '\0', NULL
, NULL
, ONE_DASH
},
293 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
294 '\0', NULL
, NULL
, ONE_DASH
},
295 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
296 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
297 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
298 '\0', NULL
, NULL
, ONE_DASH
},
299 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
300 '\0', NULL
, NULL
, ONE_DASH
},
301 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
302 '\0', NULL
, NULL
, ONE_DASH
},
303 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
304 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
305 { {"Bsymbolic-functions", no_argument
, NULL
, OPTION_SYMBOLIC_FUNCTIONS
},
306 '\0', NULL
, N_("Bind global function references locally"), ONE_DASH
},
307 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
308 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
310 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
311 '\0', NULL
, N_("Do not check section addresses for overlaps"),
313 { {"copy-dt-needed-entries", no_argument
, NULL
,
314 OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
315 '\0', NULL
, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
317 { {"no-copy-dt-needed-entries", no_argument
, NULL
,
318 OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
319 '\0', NULL
, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
322 { {"cref", no_argument
, NULL
, OPTION_CREF
},
323 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
324 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
325 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
326 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
327 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
329 { {"disable-multiple-abs-defs", no_argument
, NULL
,
330 OPTION_DISABLE_MULTIPLE_DEFS_ABS
},
331 '\0', NULL
, N_("Do not allow multiple definitions with symbols included\n"
332 " in filename invoked by -R or --just-symbols"),
334 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
335 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
336 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
337 '\0', NULL
, N_("Treat warnings as errors"),
339 { {"no-fatal-warnings", no_argument
, NULL
, OPTION_NO_WARN_FATAL
},
340 '\0', NULL
, N_("Do not treat warnings as errors (default)"),
342 { {"fini", required_argument
, NULL
, OPTION_FINI
},
343 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
344 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
345 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
346 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
347 '\0', NULL
, N_("Remove unused sections (on some targets)"),
349 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
350 '\0', NULL
, N_("Don't remove unused sections (default)"),
352 { {"print-gc-sections", no_argument
, NULL
, OPTION_PRINT_GC_SECTIONS
},
353 '\0', NULL
, N_("List removed unused sections on stderr"),
355 { {"no-print-gc-sections", no_argument
, NULL
, OPTION_NO_PRINT_GC_SECTIONS
},
356 '\0', NULL
, N_("Do not list removed unused sections"),
358 { {"gc-keep-exported", no_argument
, NULL
, OPTION_GC_KEEP_EXPORTED
},
359 '\0', NULL
, N_("Keep exported symbols when removing unused sections"),
361 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
362 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
364 { {"help", no_argument
, NULL
, OPTION_HELP
},
365 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
366 { {"init", required_argument
, NULL
, OPTION_INIT
},
367 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
368 { {"Map", required_argument
, NULL
, OPTION_MAP
},
369 '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH
},
370 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
371 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
372 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
373 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
374 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
375 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
376 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
377 '\0', NULL
, N_("Do not allow unresolved references in object files"),
379 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
380 '\0', NULL
, N_("Allow unresolved references in shared libraries"),
382 { {"no-allow-shlib-undefined", no_argument
, NULL
,
383 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
384 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
386 { {"allow-multiple-definition", no_argument
, NULL
,
387 OPTION_ALLOW_MULTIPLE_DEFINITION
},
388 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
389 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
390 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
391 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
392 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
393 { {"default-imported-symver", no_argument
, NULL
,
394 OPTION_DEFAULT_IMPORTED_SYMVER
},
395 '\0', NULL
, N_("Create default symbol version for imported symbols"),
397 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
398 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
399 { {"no-warn-search-mismatch", no_argument
, NULL
,
400 OPTION_NO_WARN_SEARCH_MISMATCH
},
401 '\0', NULL
, N_("Don't warn on finding an incompatible library"),
403 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
404 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
405 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
406 '\0', NULL
, N_("Create an output file even if errors occur"),
408 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
409 '\0', NULL
, NULL
, NO_HELP
},
410 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
411 '\0', NULL
, N_("Only use library directories specified on\n"
412 " the command line"),
414 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
415 '\0', N_("TARGET"), N_("Specify target of output file"),
416 EXACTLY_TWO_DASHES
},
417 { {"print-output-format", no_argument
, NULL
, OPTION_PRINT_OUTPUT_FORMAT
},
418 '\0', NULL
, N_("Print default output format"), TWO_DASHES
},
419 { {"print-sysroot", no_argument
, NULL
, OPTION_PRINT_SYSROOT
},
420 '\0', NULL
, N_("Print current sysroot"), TWO_DASHES
},
421 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
422 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
423 { {"reduce-memory-overheads", no_argument
, NULL
,
424 OPTION_REDUCE_MEMORY_OVERHEADS
},
425 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
427 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
428 '\0', NULL
, N_("Reduce code size by using target specific optimizations"), TWO_DASHES
},
429 { {"no-relax", no_argument
, NULL
, OPTION_NO_RELAX
},
430 '\0', NULL
, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES
},
431 { {"retain-symbols-file", required_argument
, NULL
,
432 OPTION_RETAIN_SYMBOLS_FILE
},
433 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
434 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
435 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
436 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
437 '\0', N_("PATH"), N_("Set link time shared library search path"),
439 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
440 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
441 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
442 '\0', NULL
, NULL
, ONE_DASH
},
443 { {"pie", no_argument
, NULL
, OPTION_PIE
},
444 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
445 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
446 '\0', NULL
, NULL
, TWO_DASHES
},
447 { {"sort-common", optional_argument
, NULL
, OPTION_SORT_COMMON
},
448 '\0', N_("[=ascending|descending]"),
449 N_("Sort common symbols by alignment [in specified order]"),
451 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
452 '\0', NULL
, NULL
, NO_HELP
},
453 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
454 '\0', N_("name|alignment"),
455 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
456 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
457 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
459 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
460 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
462 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
463 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
465 { {"stats", no_argument
, NULL
, OPTION_STATS
},
466 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
467 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
468 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
469 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
470 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
471 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
472 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
473 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
474 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
476 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
477 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
478 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
479 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
480 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
481 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
482 { {"Ttext-segment", required_argument
, NULL
, OPTION_TTEXT_SEGMENT
},
483 '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH
},
484 { {"Trodata-segment", required_argument
, NULL
, OPTION_TRODATA_SEGMENT
},
485 '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH
},
486 { {"Tldata-segment", required_argument
, NULL
, OPTION_TLDATA_SEGMENT
},
487 '\0', N_("ADDRESS"), N_("Set address of ldata segment"), ONE_DASH
},
488 { {"unresolved-symbols=<method>", required_argument
, NULL
,
489 OPTION_UNRESOLVED_SYMBOLS
},
490 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
491 " ignore-all, report-all, ignore-in-object-files,\n"
492 " ignore-in-shared-libs"),
494 { {"verbose", optional_argument
, NULL
, OPTION_VERBOSE
},
495 '\0', N_("[=NUMBER]"),
496 N_("Output lots of information during link"), TWO_DASHES
},
497 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
498 '\0', NULL
, NULL
, NO_HELP
},
499 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
500 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
501 { {"version-exports-section", required_argument
, NULL
,
502 OPTION_VERSION_EXPORTS_SECTION
},
503 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
504 " SYMBOL as the version."),
506 { {"dynamic-list-data", no_argument
, NULL
, OPTION_DYNAMIC_LIST_DATA
},
507 '\0', NULL
, N_("Add data symbols to dynamic list"), TWO_DASHES
},
508 { {"dynamic-list-cpp-new", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_NEW
},
509 '\0', NULL
, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES
},
510 { {"dynamic-list-cpp-typeinfo", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_TYPEINFO
},
511 '\0', NULL
, N_("Use C++ typeinfo dynamic list"), TWO_DASHES
},
512 { {"dynamic-list", required_argument
, NULL
, OPTION_DYNAMIC_LIST
},
513 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES
},
514 { {"export-dynamic-symbol", required_argument
, NULL
, OPTION_EXPORT_DYNAMIC_SYMBOL
},
515 '\0', N_("SYMBOL"), N_("Export the specified symbol"), EXACTLY_TWO_DASHES
},
516 { {"export-dynamic-symbol-list", required_argument
, NULL
, OPTION_EXPORT_DYNAMIC_SYMBOL_LIST
},
517 '\0', N_("FILE"), N_("Read export dynamic symbol list"), EXACTLY_TWO_DASHES
},
518 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
519 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
520 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
521 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
523 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
524 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
525 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
526 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
527 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
528 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
530 { {"warn-textrel", no_argument
, NULL
, OPTION_WARN_TEXTREL
},
532 #if DEFAULT_LD_TEXTREL_CHECK_WARNING
533 N_("Warn if output has DT_TEXTREL (default)"),
535 N_("Warn if output has DT_TEXTREL"),
538 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_TEXTREL
},
539 '\0', NULL
, NULL
, NO_HELP
},
540 { {"warn-alternate-em", no_argument
, NULL
, OPTION_WARN_ALTERNATE_EM
},
541 '\0', NULL
, N_("Warn if an object has alternate ELF machine code"),
543 { {"warn-unresolved-symbols", no_argument
, NULL
,
544 OPTION_WARN_UNRESOLVED_SYMBOLS
},
545 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
546 { {"error-unresolved-symbols", no_argument
, NULL
,
547 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
548 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
549 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
550 '\0', NULL
, N_("Include all objects from following archives"),
552 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
553 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
554 { {"ignore-unresolved-symbol", required_argument
, NULL
,
555 OPTION_IGNORE_UNRESOLVED_SYMBOL
},
557 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES
},
558 { {"push-state", no_argument
, NULL
, OPTION_PUSH_STATE
},
559 '\0', NULL
, N_("Push state of flags governing input file handling"),
561 { {"pop-state", no_argument
, NULL
, OPTION_POP_STATE
},
562 '\0', NULL
, N_("Pop state of flags governing input file handling"),
564 { {"print-memory-usage", no_argument
, NULL
, OPTION_PRINT_MEMORY_USAGE
},
565 '\0', NULL
, N_("Report target memory usage"), TWO_DASHES
},
566 { {"orphan-handling", required_argument
, NULL
, OPTION_ORPHAN_HANDLING
},
567 '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
569 { {"print-map-discarded", no_argument
, NULL
, OPTION_PRINT_MAP_DISCARDED
},
570 '\0', NULL
, N_("Show discarded sections in map file output (default)"),
572 { {"no-print-map-discarded", no_argument
, NULL
, OPTION_NO_PRINT_MAP_DISCARDED
},
573 '\0', NULL
, N_("Do not show discarded sections in map file output"),
577 #define OPTION_COUNT ARRAY_SIZE (ld_options)
580 parse_args (unsigned argc
, char **argv
)
585 char *default_dirlist
= NULL
;
587 struct option
*longopts
;
588 struct option
*really_longopts
;
595 } opt_symbolic
= symbolic_unset
;
596 enum dynamic_list_enum
598 dynamic_list_unset
= 0,
601 } opt_dynamic_list
= dynamic_list_unset
;
602 struct bfd_elf_dynamic_list
*export_list
= NULL
;
604 shortopts
= (char *) xmalloc (OPTION_COUNT
* 3 + 2);
605 longopts
= (struct option
*)
606 xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
607 really_longopts
= (struct option
*)
608 malloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
610 /* Starting the short option string with '-' is for programs that
611 expect options and other ARGV-elements in any order and that care about
612 the ordering of the two. We describe each non-option ARGV-element
613 as if it were the argument of an option with character code 1. */
618 for (i
= 0; i
< OPTION_COUNT
; i
++)
620 if (ld_options
[i
].shortopt
!= '\0')
622 shortopts
[is
] = ld_options
[i
].shortopt
;
624 if (ld_options
[i
].opt
.has_arg
== required_argument
625 || ld_options
[i
].opt
.has_arg
== optional_argument
)
629 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
636 if (ld_options
[i
].opt
.name
!= NULL
)
638 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
640 really_longopts
[irl
] = ld_options
[i
].opt
;
645 longopts
[il
] = ld_options
[i
].opt
;
650 shortopts
[is
] = '\0';
651 longopts
[il
].name
= NULL
;
652 really_longopts
[irl
].name
= NULL
;
654 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
656 /* The -G option is ambiguous on different platforms. Sometimes it
657 specifies the largest data size to put into the small data
658 section. Sometimes it is equivalent to --shared. Unfortunately,
659 the first form takes an argument, while the second does not.
661 We need to permit the --shared form because on some platforms,
662 such as Solaris, gcc -shared will pass -G to the linker.
664 To permit either usage, we look through the argument list. If we
665 find -G not followed by a number, we change it into --shared.
666 This will work for most normal cases. */
667 for (i
= 1; i
< argc
; i
++)
668 if (strcmp (argv
[i
], "-G") == 0
670 || ! ISDIGIT (argv
[i
+ 1][0])))
671 argv
[i
] = (char *) "--shared";
673 /* Because we permit long options to start with a single dash, and
674 we have a --library option, and the -l option is conventionally
675 used with an immediately following argument, we can have bad
676 results if somebody tries to use -l with a library whose name
677 happens to start with "ibrary", as in -li. We avoid problems by
678 simply turning -l into --library. This means that users will
679 have to use two dashes in order to use --library, which is OK
680 since that's how it is documented.
682 FIXME: It's possible that this problem can arise for other short
683 options as well, although the user does always have the recourse
684 of adding a space between the option and the argument. */
685 for (i
= 1; i
< argc
; i
++)
687 if (argv
[i
][0] == '-'
689 && argv
[i
][2] != '\0')
693 n
= (char *) xmalloc (strlen (argv
[i
]) + 20);
694 sprintf (n
, "--library=%s", argv
[i
] + 2);
704 static unsigned int defsym_count
;
706 /* Using last_optind lets us avoid calling ldemul_parse_args
707 multiple times on a single option, which would lead to
708 confusion in the internal static variables maintained by
709 getopt. This could otherwise happen for an argument like
710 -nx, in which the -n is parsed as a single option, and we
711 loop around to pick up the -x. */
712 if (optind
!= last_optind
)
713 if (ldemul_parse_args (argc
, argv
))
716 /* getopt_long_only is like getopt_long, but '-' as well as '--'
717 can indicate a long option. */
719 last_optind
= optind
;
720 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
723 optind
= last_optind
;
724 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
727 if (ldemul_handle_option (optc
))
737 /* If the last word on the command line is an option that
738 requires an argument, getopt will refuse to recognise it.
739 Try to catch such options here and issue a more helpful
740 error message than just "unrecognized option". */
743 for (opt
= ARRAY_SIZE (ld_options
); opt
--;)
744 if (ld_options
[opt
].opt
.has_arg
== required_argument
745 /* FIXME: There are a few short options that do not
746 have long equivalents, but which require arguments.
747 We should handle them too. */
748 && ld_options
[opt
].opt
.name
!= NULL
749 && strcmp (argv
[last_optind
] + ld_options
[opt
].control
, ld_options
[opt
].opt
.name
) == 0)
751 einfo (_("%P: %s: missing argument\n"), argv
[last_optind
]);
756 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
761 einfo (_("%F%P: use the --help option for usage information\n"));
764 case 1: /* File name. */
765 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
771 /* For HP/UX compatibility. Actually -a shared should mean
772 ``use only shared libraries'' but, then, we don't
773 currently support shared libraries on HP/UX anyhow. */
774 if (strcmp (optarg
, "archive") == 0)
775 input_flags
.dynamic
= FALSE
;
776 else if (strcmp (optarg
, "shared") == 0
777 || strcmp (optarg
, "default") == 0)
778 input_flags
.dynamic
= TRUE
;
780 einfo (_("%F%P: unrecognized -a option `%s'\n"), optarg
);
783 /* FIXME: We just ignore these, but we should handle them. */
784 if (strcmp (optarg
, "definitions") == 0)
786 else if (strcmp (optarg
, "nodefinitions") == 0)
788 else if (strcmp (optarg
, "nosymbolic") == 0)
790 else if (strcmp (optarg
, "pure-text") == 0)
793 einfo (_("%F%P: unrecognized -assert option `%s'\n"), optarg
);
796 ldfile_add_arch (optarg
);
799 lang_add_target (optarg
);
802 ldfile_open_command_file (optarg
);
803 parser_input
= input_mri_script
;
806 case OPTION_CALL_SHARED
:
807 input_flags
.dynamic
= TRUE
;
809 case OPTION_NON_SHARED
:
810 input_flags
.dynamic
= FALSE
;
813 command_line
.cref
= TRUE
;
814 link_info
.notice_all
= TRUE
;
817 command_line
.force_common_definition
= TRUE
;
819 case OPTION_FORCE_GROUP_ALLOCATION
:
820 command_line
.force_group_allocation
= TRUE
;
824 lex_redirect (optarg
, "--defsym", ++defsym_count
);
825 parser_input
= input_defsym
;
829 case OPTION_DEMANGLE
:
833 enum demangling_styles style
;
835 style
= cplus_demangle_name_to_style (optarg
);
836 if (style
== unknown_demangling
)
837 einfo (_("%F%P: unknown demangling style `%s'\n"),
840 cplus_demangle_set_style (style
);
843 case 'I': /* Used on Solaris. */
844 case OPTION_DYNAMIC_LINKER
:
845 command_line
.interpreter
= optarg
;
846 link_info
.nointerp
= 0;
848 case OPTION_NO_DYNAMIC_LINKER
:
849 link_info
.nointerp
= 1;
852 /* Already handled in ldmain.c. */
855 command_line
.endian
= ENDIAN_BIG
;
858 command_line
.endian
= ENDIAN_LITTLE
;
860 case OPTION_EMBEDDED_RELOCS
:
861 command_line
.embedded_relocs
= TRUE
;
863 case OPTION_EXPORT_DYNAMIC
:
864 case 'E': /* HP/UX compatibility. */
865 link_info
.export_dynamic
= TRUE
;
867 case OPTION_NO_EXPORT_DYNAMIC
:
868 link_info
.export_dynamic
= FALSE
;
870 case OPTION_NON_CONTIGUOUS_REGIONS
:
871 link_info
.non_contiguous_regions
= TRUE
;
873 case OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS
:
874 link_info
.non_contiguous_regions_warnings
= TRUE
;
877 lang_add_entry (optarg
, TRUE
);
880 if (command_line
.auxiliary_filters
== NULL
)
882 command_line
.auxiliary_filters
= (char **)
883 xmalloc (2 * sizeof (char *));
884 command_line
.auxiliary_filters
[0] = optarg
;
885 command_line
.auxiliary_filters
[1] = NULL
;
893 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
895 command_line
.auxiliary_filters
= (char **)
896 xrealloc (command_line
.auxiliary_filters
,
897 (c
+ 2) * sizeof (char *));
898 command_line
.auxiliary_filters
[c
] = optarg
;
899 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
903 command_line
.filter_shlib
= optarg
;
905 case OPTION_FORCE_EXE_SUFFIX
:
906 command_line
.force_exe_suffix
= TRUE
;
911 g_switch_value
= strtoul (optarg
, &end
, 0);
913 einfo (_("%F%P: invalid number `%s'\n"), optarg
);
919 case OPTION_GC_SECTIONS
:
920 link_info
.gc_sections
= TRUE
;
922 case OPTION_PRINT_GC_SECTIONS
:
923 link_info
.print_gc_sections
= TRUE
;
925 case OPTION_GC_KEEP_EXPORTED
:
926 link_info
.gc_keep_exported
= TRUE
;
933 ldfile_add_library_path (optarg
, TRUE
);
936 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
939 config
.map_filename
= "-";
942 /* Ignore. Was handled in a pre-parse. */
945 config
.map_filename
= optarg
;
948 config
.text_read_only
= FALSE
;
949 config
.magic_demand_paged
= FALSE
;
950 input_flags
.dynamic
= FALSE
;
952 case OPTION_NO_OMAGIC
:
953 config
.text_read_only
= TRUE
;
954 config
.magic_demand_paged
= TRUE
;
955 /* NB/ Does not set input_flags.dynamic to TRUE.
956 Use --call-shared or -Bdynamic for this. */
959 config
.text_read_only
= TRUE
;
960 config
.magic_demand_paged
= FALSE
;
961 input_flags
.dynamic
= FALSE
;
963 case OPTION_NO_DEFINE_COMMON
:
964 link_info
.inhibit_common_definition
= TRUE
;
966 case OPTION_NO_DEMANGLE
:
969 case OPTION_NO_GC_SECTIONS
:
970 link_info
.gc_sections
= FALSE
;
972 case OPTION_NO_PRINT_GC_SECTIONS
:
973 link_info
.print_gc_sections
= FALSE
;
975 case OPTION_NO_KEEP_MEMORY
:
976 link_info
.keep_memory
= FALSE
;
978 case OPTION_NO_UNDEFINED
:
979 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
981 case OPTION_ALLOW_SHLIB_UNDEFINED
:
982 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
984 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
985 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
987 case OPTION_UNRESOLVED_SYMBOLS
:
988 if (strcmp (optarg
, "ignore-all") == 0)
990 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
991 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
993 else if (strcmp (optarg
, "report-all") == 0)
995 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
996 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
998 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
1000 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1001 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1003 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
1005 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1006 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1009 einfo (_("%F%P: bad --unresolved-symbols option: %s\n"), optarg
);
1011 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
1012 link_info
.warn_unresolved_syms
= TRUE
;
1014 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
1015 link_info
.warn_unresolved_syms
= FALSE
;
1017 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
1018 link_info
.allow_multiple_definition
= TRUE
;
1020 case OPTION_NO_UNDEFINED_VERSION
:
1021 link_info
.allow_undefined_version
= FALSE
;
1023 case OPTION_DEFAULT_SYMVER
:
1024 link_info
.create_default_symver
= TRUE
;
1026 case OPTION_DEFAULT_IMPORTED_SYMVER
:
1027 link_info
.default_imported_symver
= TRUE
;
1029 case OPTION_NO_WARN_MISMATCH
:
1030 command_line
.warn_mismatch
= FALSE
;
1032 case OPTION_NO_WARN_SEARCH_MISMATCH
:
1033 command_line
.warn_search_mismatch
= FALSE
;
1035 case OPTION_NOINHIBIT_EXEC
:
1036 force_make_executable
= TRUE
;
1038 case OPTION_NOSTDLIB
:
1039 config
.only_cmd_line_lib_dirs
= TRUE
;
1041 case OPTION_NO_WHOLE_ARCHIVE
:
1042 input_flags
.whole_archive
= FALSE
;
1045 /* FIXME "-O<non-digits> <value>" used to set the address of
1046 section <non-digits>. Was this for compatibility with
1047 something, or can we create a new option to do that
1048 (with a syntax similar to -defsym)?
1049 getopt can't handle two args to an option without kludges. */
1051 /* Enable optimizations of output files. */
1052 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
1055 lang_add_output (optarg
, 0);
1057 case OPTION_OFORMAT
:
1058 lang_add_output_format (optarg
, NULL
, NULL
, 0);
1060 case OPTION_OUT_IMPLIB
:
1061 command_line
.out_implib_filename
= xstrdup (optarg
);
1063 case OPTION_PRINT_SYSROOT
:
1068 case OPTION_PRINT_OUTPUT_FORMAT
:
1069 command_line
.print_output_format
= TRUE
;
1071 #if BFD_SUPPORTS_PLUGINS
1073 plugin_opt_plugin (optarg
);
1075 case OPTION_PLUGIN_OPT
:
1076 if (plugin_opt_plugin_arg (optarg
))
1077 einfo (_("%F%P: bad -plugin-opt option\n"));
1079 #endif /* BFD_SUPPORTS_PLUGINS */
1081 link_info
.emitrelocations
= TRUE
;
1085 if (optind
== last_optind
)
1086 /* This can happen if the user put "-rpath,a" on the command
1087 line. (Or something similar. The comma is important).
1088 Getopt becomes confused and thinks that this is a -r option
1089 but it cannot parse the text after the -r so it refuses to
1090 increment the optind counter. Detect this case and issue
1091 an error message here. We cannot just make this a warning,
1092 increment optind, and continue because getopt is too confused
1093 and will seg-fault the next time around. */
1094 einfo(_("%F%P: unrecognised option: %s\n"), argv
[optind
]);
1096 if (bfd_link_pic (&link_info
))
1097 einfo (_("%F%P: -r and %s may not be used together\n"),
1098 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1100 link_info
.type
= type_relocatable
;
1101 config
.build_constructors
= FALSE
;
1102 config
.magic_demand_paged
= FALSE
;
1103 config
.text_read_only
= FALSE
;
1104 input_flags
.dynamic
= FALSE
;
1107 /* The GNU linker traditionally uses -R to mean to include
1108 only the symbols from a file. The Solaris linker uses -R
1109 to set the path used by the runtime linker to find
1110 libraries. This is the GNU linker -rpath argument. We
1111 try to support both simultaneously by checking the file
1112 named. If it is a directory, rather than a regular file,
1113 we assume -rpath was meant. */
1117 if (stat (optarg
, &s
) >= 0
1118 && ! S_ISDIR (s
.st_mode
))
1120 lang_add_input_file (optarg
,
1121 lang_input_file_is_symbols_only_enum
,
1128 if (command_line
.rpath
== NULL
)
1129 command_line
.rpath
= xstrdup (optarg
);
1132 size_t rpath_len
= strlen (command_line
.rpath
);
1133 size_t optarg_len
= strlen (optarg
);
1135 char *cp
= command_line
.rpath
;
1137 /* First see whether OPTARG is already in the path. */
1140 if (strncmp (optarg
, cp
, optarg_len
) == 0
1141 && (cp
[optarg_len
] == 0
1142 || cp
[optarg_len
] == config
.rpath_separator
))
1146 /* Not yet found. */
1147 cp
= strchr (cp
, config
.rpath_separator
);
1155 buf
= (char *) xmalloc (rpath_len
+ optarg_len
+ 2);
1156 sprintf (buf
, "%s%c%s", command_line
.rpath
,
1157 config
.rpath_separator
, optarg
);
1158 free (command_line
.rpath
);
1159 command_line
.rpath
= buf
;
1163 case OPTION_RPATH_LINK
:
1164 if (command_line
.rpath_link
== NULL
)
1165 command_line
.rpath_link
= xstrdup (optarg
);
1170 buf
= (char *) xmalloc (strlen (command_line
.rpath_link
)
1173 sprintf (buf
, "%s%c%s", command_line
.rpath_link
,
1174 config
.rpath_separator
, optarg
);
1175 free (command_line
.rpath_link
);
1176 command_line
.rpath_link
= buf
;
1179 case OPTION_NO_RELAX
:
1185 case OPTION_RETAIN_SYMBOLS_FILE
:
1186 add_keepsyms_file (optarg
);
1189 link_info
.strip
= strip_debugger
;
1192 link_info
.strip
= strip_all
;
1194 case OPTION_STRIP_DISCARDED
:
1195 link_info
.strip_discarded
= TRUE
;
1197 case OPTION_NO_STRIP_DISCARDED
:
1198 link_info
.strip_discarded
= FALSE
;
1200 case OPTION_DISABLE_MULTIPLE_DEFS_ABS
:
1201 link_info
.prohibit_multiple_definition_absolute
= TRUE
;
1204 if (config
.has_shared
)
1206 if (bfd_link_relocatable (&link_info
))
1207 einfo (_("%F%P: -r and %s may not be used together\n"),
1210 link_info
.type
= type_dll
;
1211 /* When creating a shared library, the default
1212 behaviour is to ignore any unresolved references. */
1213 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1214 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1215 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1216 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1219 einfo (_("%F%P: -shared not supported\n"));
1222 if (config
.has_shared
)
1224 if (bfd_link_relocatable (&link_info
))
1225 einfo (_("%F%P: -r and %s may not be used together\n"), "-pie");
1227 link_info
.type
= type_pie
;
1230 einfo (_("%F%P: -pie not supported\n"));
1232 case 'h': /* Used on Solaris. */
1234 if (optarg
[0] == '\0' && command_line
.soname
1235 && command_line
.soname
[0])
1236 einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
1238 command_line
.soname
= optarg
;
1240 case OPTION_SORT_COMMON
:
1242 || strcmp (optarg
, N_("descending")) == 0)
1243 config
.sort_common
= sort_descending
;
1244 else if (strcmp (optarg
, N_("ascending")) == 0)
1245 config
.sort_common
= sort_ascending
;
1247 einfo (_("%F%P: invalid common section sorting option: %s\n"),
1250 case OPTION_SORT_SECTION
:
1251 if (strcmp (optarg
, N_("name")) == 0)
1252 sort_section
= by_name
;
1253 else if (strcmp (optarg
, N_("alignment")) == 0)
1254 sort_section
= by_alignment
;
1256 einfo (_("%F%P: invalid section sorting option: %s\n"),
1260 config
.stats
= TRUE
;
1262 case OPTION_SYMBOLIC
:
1263 opt_symbolic
= symbolic
;
1265 case OPTION_SYMBOLIC_FUNCTIONS
:
1266 opt_symbolic
= symbolic_functions
;
1272 previous_script_handle
= saved_script_handle
;
1273 ldfile_open_script_file (optarg
);
1274 parser_input
= input_script
;
1276 previous_script_handle
= NULL
;
1278 case OPTION_DEFAULT_SCRIPT
:
1279 command_line
.default_script
= optarg
;
1281 case OPTION_SECTION_START
:
1287 /* Check for <something>=<somthing>... */
1288 optarg2
= strchr (optarg
, '=');
1289 if (optarg2
== NULL
)
1290 einfo (_("%F%P: invalid argument to option"
1291 " \"--section-start\"\n"));
1295 /* So far so good. Are all the args present? */
1296 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1297 einfo (_("%F%P: missing argument(s) to option"
1298 " \"--section-start\"\n"));
1300 /* We must copy the section name as set_section_start
1301 doesn't do it for us. */
1302 len
= optarg2
- optarg
;
1303 sec_name
= (char *) xmalloc (len
);
1304 memcpy (sec_name
, optarg
, len
- 1);
1305 sec_name
[len
- 1] = 0;
1307 /* Then set it... */
1308 set_section_start (sec_name
, optarg2
);
1311 case OPTION_TARGET_HELP
:
1312 /* Mention any target specific options. */
1313 ldemul_list_emulation_options (stdout
);
1316 set_segment_start (".bss", optarg
);
1319 set_segment_start (".data", optarg
);
1322 set_segment_start (".text", optarg
);
1324 case OPTION_TTEXT_SEGMENT
:
1325 set_segment_start (".text-segment", optarg
);
1327 case OPTION_TRODATA_SEGMENT
:
1328 set_segment_start (".rodata-segment", optarg
);
1330 case OPTION_TLDATA_SEGMENT
:
1331 set_segment_start (".ldata-segment", optarg
);
1333 case OPTION_TRADITIONAL_FORMAT
:
1334 link_info
.traditional_format
= TRUE
;
1336 case OPTION_TASK_LINK
:
1337 link_info
.task_link
= TRUE
;
1340 if (bfd_link_pic (&link_info
))
1341 einfo (_("%F%P: -r and %s may not be used together\n"),
1342 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1344 link_info
.type
= type_relocatable
;
1345 config
.build_constructors
= TRUE
;
1346 config
.magic_demand_paged
= FALSE
;
1347 config
.text_read_only
= FALSE
;
1348 input_flags
.dynamic
= FALSE
;
1351 ldlang_add_undef (optarg
, TRUE
);
1353 case OPTION_REQUIRE_DEFINED_SYMBOL
:
1354 ldlang_add_require_defined (optarg
);
1358 lang_add_unique (optarg
);
1360 config
.unique_orphan_sections
= TRUE
;
1362 case OPTION_VERBOSE
:
1364 version_printed
= TRUE
;
1366 overflow_cutoff_limit
= -2;
1370 int level ATTRIBUTE_UNUSED
= strtoul (optarg
, &end
, 0);
1372 einfo (_("%F%P: invalid number `%s'\n"), optarg
);
1373 #if BFD_SUPPORTS_PLUGINS
1374 report_plugin_symbols
= level
> 1;
1375 #endif /* BFD_SUPPORTS_PLUGINS */
1380 version_printed
= TRUE
;
1384 version_printed
= TRUE
;
1386 case OPTION_VERSION
:
1390 case OPTION_VERSION_SCRIPT
:
1391 /* This option indicates a small script that only specifies
1392 version information. Read it, but don't assume that
1393 we've seen a linker script. */
1395 FILE *hold_script_handle
;
1397 hold_script_handle
= saved_script_handle
;
1398 ldfile_open_command_file (optarg
);
1399 saved_script_handle
= hold_script_handle
;
1400 parser_input
= input_version_script
;
1404 case OPTION_VERSION_EXPORTS_SECTION
:
1405 /* This option records a version symbol to be applied to the
1406 symbols listed for export to be found in the object files
1407 .exports sections. */
1408 command_line
.version_exports_section
= optarg
;
1410 case OPTION_DYNAMIC_LIST_DATA
:
1411 opt_dynamic_list
= dynamic_list_data
;
1413 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO
:
1414 lang_append_dynamic_list_cpp_typeinfo ();
1415 if (opt_dynamic_list
!= dynamic_list_data
)
1416 opt_dynamic_list
= dynamic_list
;
1418 case OPTION_DYNAMIC_LIST_CPP_NEW
:
1419 lang_append_dynamic_list_cpp_new ();
1420 if (opt_dynamic_list
!= dynamic_list_data
)
1421 opt_dynamic_list
= dynamic_list
;
1423 case OPTION_DYNAMIC_LIST
:
1424 /* This option indicates a small script that only specifies
1425 a dynamic list. Read it, but don't assume that we've
1426 seen a linker script. */
1428 FILE *hold_script_handle
;
1430 hold_script_handle
= saved_script_handle
;
1431 ldfile_open_command_file (optarg
);
1432 saved_script_handle
= hold_script_handle
;
1433 parser_input
= input_dynamic_list
;
1434 current_dynamic_list_p
= &link_info
.dynamic_list
;
1437 if (opt_dynamic_list
!= dynamic_list_data
)
1438 opt_dynamic_list
= dynamic_list
;
1440 case OPTION_EXPORT_DYNAMIC_SYMBOL
:
1442 struct bfd_elf_version_expr
*expr
1443 = lang_new_vers_pattern (NULL
, xstrdup (optarg
), NULL
,
1445 lang_append_dynamic_list (&export_list
, expr
);
1448 case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST
:
1449 /* This option indicates a small script that only specifies
1450 an export list. Read it, but don't assume that we've
1451 seen a linker script. */
1453 FILE *hold_script_handle
;
1455 hold_script_handle
= saved_script_handle
;
1456 ldfile_open_command_file (optarg
);
1457 saved_script_handle
= hold_script_handle
;
1458 parser_input
= input_dynamic_list
;
1459 current_dynamic_list_p
= &export_list
;
1463 case OPTION_WARN_COMMON
:
1464 config
.warn_common
= TRUE
;
1466 case OPTION_WARN_CONSTRUCTORS
:
1467 config
.warn_constructors
= TRUE
;
1469 case OPTION_WARN_FATAL
:
1470 config
.fatal_warnings
= TRUE
;
1472 case OPTION_NO_WARN_FATAL
:
1473 config
.fatal_warnings
= FALSE
;
1475 case OPTION_WARN_MULTIPLE_GP
:
1476 config
.warn_multiple_gp
= TRUE
;
1478 case OPTION_WARN_ONCE
:
1479 config
.warn_once
= TRUE
;
1481 case OPTION_WARN_SECTION_ALIGN
:
1482 config
.warn_section_align
= TRUE
;
1484 case OPTION_WARN_TEXTREL
:
1485 link_info
.textrel_check
= textrel_check_warning
;
1487 case OPTION_WARN_ALTERNATE_EM
:
1488 link_info
.warn_alternate_em
= TRUE
;
1490 case OPTION_WHOLE_ARCHIVE
:
1491 input_flags
.whole_archive
= TRUE
;
1493 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
:
1494 input_flags
.add_DT_NEEDED_for_dynamic
= TRUE
;
1496 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
:
1497 input_flags
.add_DT_NEEDED_for_dynamic
= FALSE
;
1499 case OPTION_ADD_DT_NEEDED_FOR_REGULAR
:
1500 input_flags
.add_DT_NEEDED_for_regular
= TRUE
;
1502 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
:
1503 input_flags
.add_DT_NEEDED_for_regular
= FALSE
;
1508 case OPTION_IGNORE_UNRESOLVED_SYMBOL
:
1509 add_ignoresym (&link_info
, optarg
);
1511 case OPTION_DISCARD_NONE
:
1512 link_info
.discard
= discard_none
;
1515 link_info
.discard
= discard_l
;
1518 link_info
.discard
= discard_all
;
1521 if (CONST_STRNEQ (optarg
, "P,"))
1523 free (default_dirlist
);
1524 default_dirlist
= xstrdup (optarg
);
1529 case OPTION_SPARE_DYNAMIC_TAGS
:
1530 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1532 case OPTION_SPLIT_BY_RELOC
:
1534 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1536 config
.split_by_reloc
= 32768;
1538 case OPTION_SPLIT_BY_FILE
:
1540 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1542 config
.split_by_file
= 1;
1544 case OPTION_CHECK_SECTIONS
:
1545 command_line
.check_section_addresses
= 1;
1547 case OPTION_NO_CHECK_SECTIONS
:
1548 command_line
.check_section_addresses
= 0;
1550 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1551 command_line
.accept_unknown_input_arch
= TRUE
;
1553 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1554 command_line
.accept_unknown_input_arch
= FALSE
;
1557 lang_enter_group ();
1562 einfo (_("%F%P: group ended before it began (--help for usage)\n"));
1564 lang_leave_group ();
1569 link_info
.init_function
= optarg
;
1573 link_info
.fini_function
= optarg
;
1576 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1577 link_info
.reduce_memory_overheads
= TRUE
;
1578 if (config
.hash_table_size
== 0)
1579 config
.hash_table_size
= 1021;
1582 case OPTION_HASH_SIZE
:
1584 bfd_size_type new_size
;
1586 new_size
= strtoul (optarg
, NULL
, 0);
1588 config
.hash_table_size
= new_size
;
1590 einfo (_("%X%P: --hash-size needs a numeric argument\n"));
1594 case OPTION_PUSH_STATE
:
1595 input_flags
.pushed
= xmemdup (&input_flags
,
1596 sizeof (input_flags
),
1597 sizeof (input_flags
));
1600 case OPTION_POP_STATE
:
1601 if (input_flags
.pushed
== NULL
)
1602 einfo (_("%F%P: no state pushed before popping\n"));
1605 struct lang_input_statement_flags
*oldp
= input_flags
.pushed
;
1606 memcpy (&input_flags
, oldp
, sizeof (input_flags
));
1611 case OPTION_PRINT_MEMORY_USAGE
:
1612 command_line
.print_memory_usage
= TRUE
;
1615 case OPTION_ORPHAN_HANDLING
:
1616 if (strcasecmp (optarg
, "place") == 0)
1617 config
.orphan_handling
= orphan_handling_place
;
1618 else if (strcasecmp (optarg
, "warn") == 0)
1619 config
.orphan_handling
= orphan_handling_warn
;
1620 else if (strcasecmp (optarg
, "error") == 0)
1621 config
.orphan_handling
= orphan_handling_error
;
1622 else if (strcasecmp (optarg
, "discard") == 0)
1623 config
.orphan_handling
= orphan_handling_discard
;
1625 einfo (_("%F%P: invalid argument to option"
1626 " \"--orphan-handling\"\n"));
1629 case OPTION_NO_PRINT_MAP_DISCARDED
:
1630 config
.print_map_discarded
= FALSE
;
1633 case OPTION_PRINT_MAP_DISCARDED
:
1634 config
.print_map_discarded
= TRUE
;
1637 case OPTION_DEPENDENCY_FILE
:
1638 config
.dependency_file
= optarg
;
1643 /* Run a couple of checks on the map filename. */
1644 if (config
.map_filename
)
1646 if (config
.map_filename
[0] == 0)
1648 einfo (_("%P: no file/directory name provided for map output; ignored\n"));
1649 config
.map_filename
= NULL
;
1655 /* If the map filename is actually a directory then create
1656 a file inside it, based upon the output filename. */
1657 if (stat (config
.map_filename
, &s
) >= 0
1658 && S_ISDIR (s
.st_mode
))
1662 /* FIXME: This is a (trivial) memory leak. */
1663 if (asprintf (&new_name
, "%s/%s.map",
1664 config
.map_filename
, output_filename
) < 0)
1666 /* If this alloc fails then something is probably very
1667 wrong. Better to halt now rather than continue on
1668 into more problems. */
1669 einfo (_("%P%F: cannot create name for linker map file: %E\n"));
1673 config
.map_filename
= new_name
;
1678 if (command_line
.soname
&& command_line
.soname
[0] == '\0')
1680 einfo (_("%P: SONAME must not be empty string; ignored\n"));
1681 command_line
.soname
= NULL
;
1686 einfo (_("%P: missing --end-group; added as last command line option\n"));
1687 lang_leave_group ();
1691 if (default_dirlist
!= NULL
)
1693 set_default_dirlist (default_dirlist
);
1694 free (default_dirlist
);
1697 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1698 /* FIXME: Should we allow emulations a chance to set this ? */
1699 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1701 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1702 /* FIXME: Should we allow emulations a chance to set this ? */
1703 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1705 if (bfd_link_relocatable (&link_info
)
1706 && command_line
.check_section_addresses
< 0)
1707 command_line
.check_section_addresses
= 0;
1711 struct bfd_elf_version_expr
*head
= export_list
->head
.list
;
1712 struct bfd_elf_version_expr
*next
;
1714 /* For --export-dynamic-symbol[-list]:
1715 1. When building executable, treat like --dynamic-list.
1716 2. When building shared object:
1717 a. If -Bsymbolic or --dynamic-list are used, treat like
1719 b. Otherwise, ignored.
1721 if (!bfd_link_relocatable (&link_info
)
1722 && (bfd_link_executable (&link_info
)
1723 || opt_symbolic
!= symbolic_unset
1724 || opt_dynamic_list
!= dynamic_list_unset
))
1726 /* Append the export list to link_info.dynamic_list. */
1727 if (link_info
.dynamic_list
)
1729 for (next
= head
; next
->next
!= NULL
; next
= next
->next
)
1731 next
->next
= link_info
.dynamic_list
->head
.list
;
1732 link_info
.dynamic_list
->head
.list
= head
;
1735 link_info
.dynamic_list
= export_list
;
1737 if (opt_dynamic_list
!= dynamic_list_data
)
1738 opt_dynamic_list
= dynamic_list
;
1742 /* Free the export list. */
1743 for (; head
->next
!= NULL
; head
= next
)
1752 switch (opt_dynamic_list
)
1754 case dynamic_list_unset
:
1756 case dynamic_list_data
:
1757 link_info
.dynamic_data
= TRUE
;
1760 link_info
.dynamic
= TRUE
;
1761 opt_symbolic
= symbolic_unset
;
1765 /* -Bsymbolic and -Bsymbols-functions are for shared library output. */
1766 if (bfd_link_dll (&link_info
))
1767 switch (opt_symbolic
)
1769 case symbolic_unset
:
1772 link_info
.symbolic
= TRUE
;
1773 if (link_info
.dynamic_list
)
1775 struct bfd_elf_version_expr
*ent
, *next
;
1776 for (ent
= link_info
.dynamic_list
->head
.list
; ent
; ent
= next
)
1781 free (link_info
.dynamic_list
);
1782 link_info
.dynamic_list
= NULL
;
1785 case symbolic_functions
:
1786 link_info
.dynamic
= TRUE
;
1787 link_info
.dynamic_data
= TRUE
;
1791 if (!bfd_link_dll (&link_info
))
1793 if (command_line
.filter_shlib
)
1794 einfo (_("%F%P: -F may not be used without -shared\n"));
1795 if (command_line
.auxiliary_filters
)
1796 einfo (_("%F%P: -f may not be used without -shared\n"));
1799 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
1800 don't see how else this can be handled, since in this case we
1801 must preserve all externally visible symbols. */
1802 if (bfd_link_relocatable (&link_info
) && link_info
.strip
== strip_all
)
1804 link_info
.strip
= strip_debugger
;
1805 if (link_info
.discard
== discard_sec_merge
)
1806 link_info
.discard
= discard_all
;
1810 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1811 library search path. */
1814 set_default_dirlist (char *dirlist_ptr
)
1820 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1823 if (*dirlist_ptr
!= '\0')
1824 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1827 dirlist_ptr
= p
+ 1;
1832 set_section_start (char *sect
, char *valstr
)
1835 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1837 einfo (_("%F%P: invalid hex number `%s'\n"), valstr
);
1838 lang_section_start (sect
, exp_intop (val
), NULL
);
1842 set_segment_start (const char *section
, char *valstr
)
1848 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1850 einfo (_("%F%P: invalid hex number `%s'\n"), valstr
);
1851 /* If we already have an entry for this segment, update the existing
1854 for (seg
= segments
; seg
; seg
= seg
->next
)
1855 if (strcmp (seg
->name
, name
) == 0)
1858 lang_section_start (section
, exp_intop (val
), seg
);
1861 /* There was no existing value so we must create a new segment
1863 seg
= stat_alloc (sizeof (*seg
));
1867 /* Add it to the linked list of segments. */
1868 seg
->next
= segments
;
1870 /* Historically, -Ttext and friends set the base address of a
1871 particular section. For backwards compatibility, we still do
1872 that. If a SEGMENT_START directive is seen, the section address
1873 assignment will be disabled. */
1874 lang_section_start (section
, exp_intop (val
), seg
);
1878 elf_shlib_list_options (FILE *file
)
1881 --audit=AUDITLIB Specify a library to use for auditing\n"));
1883 -Bgroup Selects group name lookup rules for DSO\n"));
1885 --disable-new-dtags Disable new dynamic tags\n"));
1887 --enable-new-dtags Enable new dynamic tags\n"));
1889 --eh-frame-hdr Create .eh_frame_hdr section\n"));
1891 --no-eh-frame-hdr Do not create .eh_frame_hdr section\n"));
1893 --exclude-libs=LIBS Make all symbols in LIBS hidden\n"));
1895 --hash-style=STYLE Set hash style to sysv/gnu/both. Default: "));
1896 if (DEFAULT_EMIT_SYSV_HASH
)
1898 /* Note - these strings are not translated as
1899 they are keywords not descriptive text. */
1900 if (DEFAULT_EMIT_GNU_HASH
)
1901 fprintf (file
, "both\n");
1903 fprintf (file
, "sysv\n");
1907 if (DEFAULT_EMIT_GNU_HASH
)
1908 fprintf (file
, "gnu\n");
1910 /* FIXME: Can this happen ? */
1911 fprintf (file
, "none\n");
1914 -P AUDITLIB, --depaudit=AUDITLIB\n" "\
1915 Specify a library to use for auditing dependencies\n"));
1917 -z combreloc Merge dynamic relocs into one section and sort\n"));
1919 -z nocombreloc Don't merge dynamic relocs into one section\n"));
1921 -z global Make symbols in DSO available for subsequently\n\
1922 loaded objects\n"));
1924 -z initfirst Mark DSO to be initialized first at runtime\n"));
1926 -z interpose Mark object to interpose all DSOs but executable\n"));
1928 -z lazy Mark object lazy runtime binding (default)\n"));
1930 -z loadfltr Mark object requiring immediate process\n"));
1932 -z nocopyreloc Don't create copy relocs\n"));
1934 -z nodefaultlib Mark object not to use default search paths\n"));
1936 -z nodelete Mark DSO non-deletable at runtime\n"));
1938 -z nodlopen Mark DSO not available to dlopen\n"));
1940 -z nodump Mark DSO not available to dldump\n"));
1942 -z now Mark object non-lazy runtime binding\n"));
1944 -z origin Mark object requiring immediate $ORIGIN\n\
1945 processing at runtime\n"));
1946 #if DEFAULT_LD_Z_RELRO
1948 -z relro Create RELRO program header (default)\n"));
1950 -z norelro Don't create RELRO program header\n"));
1953 -z relro Create RELRO program header\n"));
1955 -z norelro Don't create RELRO program header (default)\n"));
1957 #if DEFAULT_LD_Z_SEPARATE_CODE
1959 -z separate-code Create separate code program header (default)\n"));
1961 -z noseparate-code Don't create separate code program header\n"));
1964 -z separate-code Create separate code program header\n"));
1966 -z noseparate-code Don't create separate code program header (default)\n"));
1969 -z common Generate common symbols with STT_COMMON type\n"));
1971 -z nocommon Generate common symbols with STT_OBJECT type\n"));
1973 -z stack-size=SIZE Set size of stack segment\n"));
1974 if (link_info
.textrel_check
== textrel_check_error
)
1976 -z text Treat DT_TEXTREL in output as error (default)\n"));
1979 -z text Treat DT_TEXTREL in output as error\n"));
1980 if (link_info
.textrel_check
== textrel_check_none
)
1983 -z notext Don't treat DT_TEXTREL in output as error (default)\n"));
1985 -z textoff Don't treat DT_TEXTREL in output as error (default)\n"));
1990 -z notext Don't treat DT_TEXTREL in output as error\n"));
1992 -z textoff Don't treat DT_TEXTREL in output as error\n"));
1997 elf_static_list_options (FILE *file
)
2000 --build-id[=STYLE] Generate build ID note\n"));
2002 --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]\n\
2003 Compress DWARF debug sections using zlib\n"));
2004 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
2006 Default: zlib-gabi\n"));
2012 -z common-page-size=SIZE Set common page size to SIZE\n"));
2014 -z max-page-size=SIZE Set maximum page size to SIZE\n"));
2016 -z defs Report unresolved symbols in object files\n"));
2018 -z muldefs Allow multiple definitions\n"));
2020 -z execstack Mark executable as requiring executable stack\n"));
2022 -z noexecstack Mark executable as not requiring executable stack\n"));
2024 -z globalaudit Mark executable requiring global auditing\n"));
2028 elf_plt_unwind_list_options (FILE *file
)
2031 --ld-generated-unwind-info Generate exception handling info for PLT\n"));
2033 --no-ld-generated-unwind-info\n\
2034 Don't generate exception handling info for PLT\n"));
2038 ld_list_options (FILE *file
, bfd_boolean elf
, bfd_boolean shlib
,
2039 bfd_boolean plt_unwind
)
2043 printf (_("ELF emulations:\n"));
2045 elf_plt_unwind_list_options (file
);
2046 elf_static_list_options (file
);
2048 elf_shlib_list_options (file
);
2052 /* Print help messages for the options. */
2058 const char **targets
, **pp
;
2061 printf (_("Usage: %s [options] file...\n"), program_name
);
2063 printf (_("Options:\n"));
2064 for (i
= 0; i
< OPTION_COUNT
; i
++)
2066 if (ld_options
[i
].doc
!= NULL
)
2079 if (ld_options
[j
].shortopt
!= '\0'
2080 && ld_options
[j
].control
!= NO_HELP
)
2082 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
2083 len
+= (comma
? 2 : 0) + 2;
2084 if (ld_options
[j
].arg
!= NULL
)
2086 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
2091 printf ("%s", _(ld_options
[j
].arg
));
2092 len
+= strlen (_(ld_options
[j
].arg
));
2098 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
2103 if (ld_options
[j
].opt
.name
!= NULL
2104 && ld_options
[j
].control
!= NO_HELP
)
2107 (ld_options
[j
].control
== TWO_DASHES
2108 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
2112 two_dashes
? "-" : "",
2113 ld_options
[j
].opt
.name
);
2114 len
+= ((comma
? 2 : 0)
2116 + (two_dashes
? 1 : 0)
2117 + strlen (ld_options
[j
].opt
.name
));
2118 if (ld_options
[j
].arg
!= NULL
)
2120 printf (" %s", _(ld_options
[j
].arg
));
2121 len
+= 1 + strlen (_(ld_options
[j
].arg
));
2127 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
2135 for (; len
< 30; len
++)
2138 printf ("%s\n", _(ld_options
[i
].doc
));
2141 printf (_(" @FILE"));
2142 for (len
= strlen (" @FILE"); len
< 30; len
++)
2144 printf (_("Read options from FILE\n"));
2146 /* Note: Various tools (such as libtool) depend upon the
2147 format of the listings below - do not change them. */
2148 /* xgettext:c-format */
2149 printf (_("%s: supported targets:"), program_name
);
2150 targets
= bfd_target_list ();
2151 for (pp
= targets
; *pp
!= NULL
; pp
++)
2152 printf (" %s", *pp
);
2156 /* xgettext:c-format */
2157 printf (_("%s: supported emulations: "), program_name
);
2158 ldemul_list_emulations (stdout
);
2161 /* xgettext:c-format */
2162 printf (_("%s: emulation specific options:\n"), program_name
);
2163 ld_list_options (stdout
, ELF_LIST_OPTIONS
, ELF_SHLIB_LIST_OPTIONS
,
2164 ELF_PLT_UNWIND_LIST_OPTIONS
);
2165 ldemul_list_emulation_options (stdout
);
2168 if (REPORT_BUGS_TO
[0])
2169 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);