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"
44 #endif /* ENABLE_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 { {"force-group-allocation", no_argument
, NULL
,
117 OPTION_FORCE_GROUP_ALLOCATION
},
118 '\0', NULL
, N_("Force group members out of groups"), TWO_DASHES
},
119 { {"entry", required_argument
, NULL
, 'e'},
120 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
121 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
122 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
123 { {"no-export-dynamic", no_argument
, NULL
, OPTION_NO_EXPORT_DYNAMIC
},
124 '\0', NULL
, N_("Undo the effect of --export-dynamic"), TWO_DASHES
},
125 { {"enable-non-contiguous-regions", no_argument
, NULL
, OPTION_NON_CONTIGUOUS_REGIONS
},
126 '\0', NULL
, N_("Enable support of non-contiguous memory regions"), TWO_DASHES
},
127 { {"enable-non-contiguous-regions-warnings", no_argument
, NULL
, OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS
},
128 '\0', NULL
, N_("Enable warnings when --enable-non-contiguous-regions may cause unexpected behaviour"), TWO_DASHES
},
129 { {"EB", no_argument
, NULL
, OPTION_EB
},
130 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
131 { {"EL", no_argument
, NULL
, OPTION_EL
},
132 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
133 { {"auxiliary", required_argument
, NULL
, 'f'},
134 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
136 { {"filter", required_argument
, NULL
, 'F'},
137 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
139 { {NULL
, no_argument
, NULL
, '\0'},
140 'g', NULL
, N_("Ignored"), ONE_DASH
},
141 { {"gpsize", required_argument
, NULL
, 'G'},
142 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
144 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
145 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
146 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
147 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
149 { {"no-dynamic-linker", no_argument
, NULL
, OPTION_NO_DYNAMIC_LINKER
},
150 '\0', NULL
, N_("Produce an executable with no program interpreter header"),
152 { {"library", required_argument
, NULL
, 'l'},
153 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
154 { {"library-path", required_argument
, NULL
, 'L'},
155 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
157 { {"sysroot=<DIRECTORY>", required_argument
, NULL
, OPTION_SYSROOT
},
158 '\0', NULL
, N_("Override the default sysroot location"), TWO_DASHES
},
159 { {NULL
, required_argument
, NULL
, '\0'},
160 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
161 { {"print-map", no_argument
, NULL
, 'M'},
162 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
163 { {"nmagic", no_argument
, NULL
, 'n'},
164 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
165 { {"omagic", no_argument
, NULL
, 'N'},
166 'N', NULL
, N_("Do not page align data, do not make text readonly"),
167 EXACTLY_TWO_DASHES
},
168 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
169 '\0', NULL
, N_("Page align data, make text readonly"),
170 EXACTLY_TWO_DASHES
},
171 { {"output", required_argument
, NULL
, 'o'},
172 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
173 { {NULL
, required_argument
, NULL
, '\0'},
174 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
175 { {"out-implib", required_argument
, NULL
, OPTION_OUT_IMPLIB
},
176 '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES
},
177 #ifdef ENABLE_PLUGINS
178 { {"plugin", required_argument
, NULL
, OPTION_PLUGIN
},
179 '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH
},
180 { {"plugin-opt", required_argument
, NULL
, OPTION_PLUGIN_OPT
},
181 '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH
},
182 { {"flto", optional_argument
, NULL
, OPTION_IGNORE
},
183 '\0', NULL
, N_("Ignored for GCC LTO option compatibility"),
185 { {"flto-partition=", required_argument
, NULL
, OPTION_IGNORE
},
186 '\0', NULL
, N_("Ignored for GCC LTO option compatibility"),
188 #endif /* ENABLE_PLUGINS */
189 { {"fuse-ld=", required_argument
, NULL
, OPTION_IGNORE
},
190 '\0', NULL
, N_("Ignored for GCC linker option compatibility"),
192 { {"map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
193 '\0', NULL
, N_("Ignored for gold option compatibility"),
195 { {"no-map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
196 '\0', NULL
, N_("Ignored for gold option compatibility"),
198 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
199 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
200 { {"emit-relocs", no_argument
, NULL
, 'q'},
201 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
202 { {"relocatable", no_argument
, NULL
, 'r'},
203 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
204 { {NULL
, no_argument
, NULL
, '\0'},
205 'i', NULL
, NULL
, ONE_DASH
},
206 { {"just-symbols", required_argument
, NULL
, 'R'},
207 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
209 { {"strip-all", no_argument
, NULL
, 's'},
210 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
211 { {"strip-debug", no_argument
, NULL
, 'S'},
212 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
213 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
214 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
215 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
216 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
217 { {"trace", no_argument
, NULL
, 't'},
218 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
219 { {"script", required_argument
, NULL
, 'T'},
220 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
221 { {"default-script", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
222 '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES
},
223 { {"dT", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
224 '\0', NULL
, NULL
, ONE_DASH
},
225 { {"undefined", required_argument
, NULL
, 'u'},
226 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
228 { {"require-defined", required_argument
, NULL
, OPTION_REQUIRE_DEFINED_SYMBOL
},
229 '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
231 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
232 '\0', N_("[=SECTION]"),
233 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
234 { {"Ur", no_argument
, NULL
, OPTION_UR
},
235 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
236 { {"version", no_argument
, NULL
, OPTION_VERSION
},
237 'v', NULL
, N_("Print version information"), TWO_DASHES
},
238 { {NULL
, no_argument
, NULL
, '\0'},
239 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
240 { {"discard-all", no_argument
, NULL
, 'x'},
241 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
242 { {"discard-locals", no_argument
, NULL
, 'X'},
243 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
244 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
245 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
246 { {"trace-symbol", required_argument
, NULL
, 'y'},
247 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
248 { {NULL
, required_argument
, NULL
, '\0'},
249 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
251 { {"start-group", no_argument
, NULL
, '('},
252 '(', NULL
, N_("Start a group"), TWO_DASHES
},
253 { {"end-group", no_argument
, NULL
, ')'},
254 ')', NULL
, N_("End a group"), TWO_DASHES
},
255 { {"accept-unknown-input-arch", no_argument
, NULL
,
256 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
258 N_("Accept input files whose architecture cannot be determined"),
260 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
261 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
262 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
265 /* The next two options are deprecated because of their similarity to
266 --as-needed and --no-as-needed. They have been replaced by
267 --copy-dt-needed-entries and --no-copy-dt-needed-entries. */
268 { {"add-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
269 '\0', NULL
, NULL
, NO_HELP
},
270 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
271 '\0', NULL
, NULL
, NO_HELP
},
273 { {"as-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_REGULAR
},
274 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
276 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
},
277 '\0', NULL
, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
278 " the command line"),
280 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
281 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
282 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
283 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
284 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
285 '\0', NULL
, NULL
, ONE_DASH
},
286 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
287 '\0', NULL
, NULL
, ONE_DASH
},
288 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
289 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
290 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
291 '\0', NULL
, NULL
, ONE_DASH
},
292 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
293 '\0', NULL
, NULL
, ONE_DASH
},
294 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
295 '\0', NULL
, NULL
, ONE_DASH
},
296 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
297 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
298 { {"Bsymbolic-functions", no_argument
, NULL
, OPTION_SYMBOLIC_FUNCTIONS
},
299 '\0', NULL
, N_("Bind global function references locally"), ONE_DASH
},
300 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
301 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
303 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
304 '\0', NULL
, N_("Do not check section addresses for overlaps"),
306 { {"copy-dt-needed-entries", no_argument
, NULL
,
307 OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
308 '\0', NULL
, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
310 { {"no-copy-dt-needed-entries", no_argument
, NULL
,
311 OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
312 '\0', NULL
, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
315 { {"cref", no_argument
, NULL
, OPTION_CREF
},
316 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
317 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
318 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
319 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
320 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
322 { {"disable-multiple-abs-defs", no_argument
, NULL
,
323 OPTION_DISABLE_MULTIPLE_DEFS_ABS
},
324 '\0', NULL
, N_("Do not allow multiple definitions with symbols included\n"
325 " in filename invoked by -R or --just-symbols"),
327 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
328 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
329 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
330 '\0', NULL
, N_("Treat warnings as errors"),
332 { {"no-fatal-warnings", no_argument
, NULL
, OPTION_NO_WARN_FATAL
},
333 '\0', NULL
, N_("Do not treat warnings as errors (default)"),
335 { {"fini", required_argument
, NULL
, OPTION_FINI
},
336 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
337 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
338 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
339 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
340 '\0', NULL
, N_("Remove unused sections (on some targets)"),
342 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
343 '\0', NULL
, N_("Don't remove unused sections (default)"),
345 { {"print-gc-sections", no_argument
, NULL
, OPTION_PRINT_GC_SECTIONS
},
346 '\0', NULL
, N_("List removed unused sections on stderr"),
348 { {"no-print-gc-sections", no_argument
, NULL
, OPTION_NO_PRINT_GC_SECTIONS
},
349 '\0', NULL
, N_("Do not list removed unused sections"),
351 { {"gc-keep-exported", no_argument
, NULL
, OPTION_GC_KEEP_EXPORTED
},
352 '\0', NULL
, N_("Keep exported symbols when removing unused sections"),
354 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
355 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
357 { {"help", no_argument
, NULL
, OPTION_HELP
},
358 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
359 { {"init", required_argument
, NULL
, OPTION_INIT
},
360 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
361 { {"Map", required_argument
, NULL
, OPTION_MAP
},
362 '\0', N_("[FILE]"), N_("Write a map file (default: <outputname>.map)"), ONE_DASH
},
363 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
364 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
365 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
366 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
367 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
368 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
369 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
370 '\0', NULL
, N_("Do not allow unresolved references in object files"),
372 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
373 '\0', NULL
, N_("Allow unresolved references in shared libraries"),
375 { {"no-allow-shlib-undefined", no_argument
, NULL
,
376 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
377 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
379 { {"allow-multiple-definition", no_argument
, NULL
,
380 OPTION_ALLOW_MULTIPLE_DEFINITION
},
381 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
382 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
383 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
384 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
385 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
386 { {"default-imported-symver", no_argument
, NULL
,
387 OPTION_DEFAULT_IMPORTED_SYMVER
},
388 '\0', NULL
, N_("Create default symbol version for imported symbols"),
390 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
391 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
392 { {"no-warn-search-mismatch", no_argument
, NULL
,
393 OPTION_NO_WARN_SEARCH_MISMATCH
},
394 '\0', NULL
, N_("Don't warn on finding an incompatible library"),
396 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
397 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
398 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
399 '\0', NULL
, N_("Create an output file even if errors occur"),
401 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
402 '\0', NULL
, NULL
, NO_HELP
},
403 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
404 '\0', NULL
, N_("Only use library directories specified on\n"
405 " the command line"),
407 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
408 '\0', N_("TARGET"), N_("Specify target of output file"),
409 EXACTLY_TWO_DASHES
},
410 { {"print-output-format", no_argument
, NULL
, OPTION_PRINT_OUTPUT_FORMAT
},
411 '\0', NULL
, N_("Print default output format"), TWO_DASHES
},
412 { {"print-sysroot", no_argument
, NULL
, OPTION_PRINT_SYSROOT
},
413 '\0', NULL
, N_("Print current sysroot"), TWO_DASHES
},
414 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
415 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
416 { {"reduce-memory-overheads", no_argument
, NULL
,
417 OPTION_REDUCE_MEMORY_OVERHEADS
},
418 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
420 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
421 '\0', NULL
, N_("Reduce code size by using target specific optimizations"), TWO_DASHES
},
422 { {"no-relax", no_argument
, NULL
, OPTION_NO_RELAX
},
423 '\0', NULL
, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES
},
424 { {"retain-symbols-file", required_argument
, NULL
,
425 OPTION_RETAIN_SYMBOLS_FILE
},
426 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
427 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
428 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
429 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
430 '\0', N_("PATH"), N_("Set link time shared library search path"),
432 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
433 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
434 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
435 '\0', NULL
, NULL
, ONE_DASH
},
436 { {"pie", no_argument
, NULL
, OPTION_PIE
},
437 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
438 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
439 '\0', NULL
, NULL
, TWO_DASHES
},
440 { {"sort-common", optional_argument
, NULL
, OPTION_SORT_COMMON
},
441 '\0', N_("[=ascending|descending]"),
442 N_("Sort common symbols by alignment [in specified order]"),
444 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
445 '\0', NULL
, NULL
, NO_HELP
},
446 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
447 '\0', N_("name|alignment"),
448 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
449 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
450 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
452 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
453 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
455 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
456 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
458 { {"stats", no_argument
, NULL
, OPTION_STATS
},
459 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
460 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
461 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
462 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
463 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
464 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
465 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
466 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
467 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
469 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
470 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
471 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
472 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
473 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
474 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
475 { {"Ttext-segment", required_argument
, NULL
, OPTION_TTEXT_SEGMENT
},
476 '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH
},
477 { {"Trodata-segment", required_argument
, NULL
, OPTION_TRODATA_SEGMENT
},
478 '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH
},
479 { {"Tldata-segment", required_argument
, NULL
, OPTION_TLDATA_SEGMENT
},
480 '\0', N_("ADDRESS"), N_("Set address of ldata segment"), ONE_DASH
},
481 { {"unresolved-symbols=<method>", required_argument
, NULL
,
482 OPTION_UNRESOLVED_SYMBOLS
},
483 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
484 " ignore-all, report-all, ignore-in-object-files,\n"
485 " ignore-in-shared-libs"),
487 { {"verbose", optional_argument
, NULL
, OPTION_VERBOSE
},
488 '\0', N_("[=NUMBER]"),
489 N_("Output lots of information during link"), TWO_DASHES
},
490 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
491 '\0', NULL
, NULL
, NO_HELP
},
492 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
493 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
494 { {"version-exports-section", required_argument
, NULL
,
495 OPTION_VERSION_EXPORTS_SECTION
},
496 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
497 " SYMBOL as the version."),
499 { {"dynamic-list-data", no_argument
, NULL
, OPTION_DYNAMIC_LIST_DATA
},
500 '\0', NULL
, N_("Add data symbols to dynamic list"), TWO_DASHES
},
501 { {"dynamic-list-cpp-new", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_NEW
},
502 '\0', NULL
, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES
},
503 { {"dynamic-list-cpp-typeinfo", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_TYPEINFO
},
504 '\0', NULL
, N_("Use C++ typeinfo dynamic list"), TWO_DASHES
},
505 { {"dynamic-list", required_argument
, NULL
, OPTION_DYNAMIC_LIST
},
506 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES
},
507 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
508 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
509 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
510 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
512 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
513 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
514 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
515 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
516 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
517 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
519 { {"warn-textrel", no_argument
, NULL
, OPTION_WARN_TEXTREL
},
520 '\0', NULL
, N_("Warn if outpout has DT_TEXTREL"),
522 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_TEXTREL
},
523 '\0', NULL
, NULL
, NO_HELP
},
524 { {"warn-alternate-em", no_argument
, NULL
, OPTION_WARN_ALTERNATE_EM
},
525 '\0', NULL
, N_("Warn if an object has alternate ELF machine code"),
527 { {"warn-unresolved-symbols", no_argument
, NULL
,
528 OPTION_WARN_UNRESOLVED_SYMBOLS
},
529 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
530 { {"error-unresolved-symbols", no_argument
, NULL
,
531 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
532 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
533 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
534 '\0', NULL
, N_("Include all objects from following archives"),
536 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
537 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
538 { {"ignore-unresolved-symbol", required_argument
, NULL
,
539 OPTION_IGNORE_UNRESOLVED_SYMBOL
},
541 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES
},
542 { {"push-state", no_argument
, NULL
, OPTION_PUSH_STATE
},
543 '\0', NULL
, N_("Push state of flags governing input file handling"),
545 { {"pop-state", no_argument
, NULL
, OPTION_POP_STATE
},
546 '\0', NULL
, N_("Pop state of flags governing input file handling"),
548 { {"print-memory-usage", no_argument
, NULL
, OPTION_PRINT_MEMORY_USAGE
},
549 '\0', NULL
, N_("Report target memory usage"), TWO_DASHES
},
550 { {"orphan-handling", required_argument
, NULL
, OPTION_ORPHAN_HANDLING
},
551 '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
553 { {"print-map-discarded", no_argument
, NULL
, OPTION_PRINT_MAP_DISCARDED
},
554 '\0', NULL
, N_("Show discarded sections in map file output (default)"),
556 { {"no-print-map-discarded", no_argument
, NULL
, OPTION_NO_PRINT_MAP_DISCARDED
},
557 '\0', NULL
, N_("Do not show discarded sections in map file output"),
561 #define OPTION_COUNT ARRAY_SIZE (ld_options)
564 parse_args (unsigned argc
, char **argv
)
569 char *default_dirlist
= NULL
;
571 struct option
*longopts
;
572 struct option
*really_longopts
;
579 } opt_symbolic
= symbolic_unset
;
580 enum dynamic_list_enum
582 dynamic_list_unset
= 0,
585 } opt_dynamic_list
= dynamic_list_unset
;
587 shortopts
= (char *) xmalloc (OPTION_COUNT
* 3 + 2);
588 longopts
= (struct option
*)
589 xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
590 really_longopts
= (struct option
*)
591 malloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
593 /* Starting the short option string with '-' is for programs that
594 expect options and other ARGV-elements in any order and that care about
595 the ordering of the two. We describe each non-option ARGV-element
596 as if it were the argument of an option with character code 1. */
601 for (i
= 0; i
< OPTION_COUNT
; i
++)
603 if (ld_options
[i
].shortopt
!= '\0')
605 shortopts
[is
] = ld_options
[i
].shortopt
;
607 if (ld_options
[i
].opt
.has_arg
== required_argument
608 || ld_options
[i
].opt
.has_arg
== optional_argument
)
612 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
619 if (ld_options
[i
].opt
.name
!= NULL
)
621 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
623 really_longopts
[irl
] = ld_options
[i
].opt
;
628 longopts
[il
] = ld_options
[i
].opt
;
633 shortopts
[is
] = '\0';
634 longopts
[il
].name
= NULL
;
635 really_longopts
[irl
].name
= NULL
;
637 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
639 /* The -G option is ambiguous on different platforms. Sometimes it
640 specifies the largest data size to put into the small data
641 section. Sometimes it is equivalent to --shared. Unfortunately,
642 the first form takes an argument, while the second does not.
644 We need to permit the --shared form because on some platforms,
645 such as Solaris, gcc -shared will pass -G to the linker.
647 To permit either usage, we look through the argument list. If we
648 find -G not followed by a number, we change it into --shared.
649 This will work for most normal cases. */
650 for (i
= 1; i
< argc
; i
++)
651 if (strcmp (argv
[i
], "-G") == 0
653 || ! ISDIGIT (argv
[i
+ 1][0])))
654 argv
[i
] = (char *) "--shared";
656 /* Because we permit long options to start with a single dash, and
657 we have a --library option, and the -l option is conventionally
658 used with an immediately following argument, we can have bad
659 results if somebody tries to use -l with a library whose name
660 happens to start with "ibrary", as in -li. We avoid problems by
661 simply turning -l into --library. This means that users will
662 have to use two dashes in order to use --library, which is OK
663 since that's how it is documented.
665 FIXME: It's possible that this problem can arise for other short
666 options as well, although the user does always have the recourse
667 of adding a space between the option and the argument. */
668 for (i
= 1; i
< argc
; i
++)
670 if (argv
[i
][0] == '-'
672 && argv
[i
][2] != '\0')
676 n
= (char *) xmalloc (strlen (argv
[i
]) + 20);
677 sprintf (n
, "--library=%s", argv
[i
] + 2);
687 static unsigned int defsym_count
;
689 /* Using last_optind lets us avoid calling ldemul_parse_args
690 multiple times on a single option, which would lead to
691 confusion in the internal static variables maintained by
692 getopt. This could otherwise happen for an argument like
693 -nx, in which the -n is parsed as a single option, and we
694 loop around to pick up the -x. */
695 if (optind
!= last_optind
)
696 if (ldemul_parse_args (argc
, argv
))
699 /* getopt_long_only is like getopt_long, but '-' as well as '--'
700 can indicate a long option. */
702 last_optind
= optind
;
703 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
706 optind
= last_optind
;
707 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
710 if (ldemul_handle_option (optc
))
720 /* If the last word on the command line is an option that
721 requires an argument, getopt will refuse to recognise it.
722 Try to catch such options here and issue a more helpful
723 error message than just "unrecognized option". */
726 for (opt
= ARRAY_SIZE (ld_options
); opt
--;)
727 if (ld_options
[opt
].opt
.has_arg
== required_argument
728 /* FIXME: There are a few short options that do not
729 have long equivalents, but which require arguments.
730 We should handle them too. */
731 && ld_options
[opt
].opt
.name
!= NULL
732 && strcmp (argv
[last_optind
] + ld_options
[opt
].control
, ld_options
[opt
].opt
.name
) == 0)
734 einfo (_("%P: %s: missing argument\n"), argv
[last_optind
]);
739 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
744 einfo (_("%F%P: use the --help option for usage information\n"));
747 case 1: /* File name. */
748 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
754 /* For HP/UX compatibility. Actually -a shared should mean
755 ``use only shared libraries'' but, then, we don't
756 currently support shared libraries on HP/UX anyhow. */
757 if (strcmp (optarg
, "archive") == 0)
758 input_flags
.dynamic
= FALSE
;
759 else if (strcmp (optarg
, "shared") == 0
760 || strcmp (optarg
, "default") == 0)
761 input_flags
.dynamic
= TRUE
;
763 einfo (_("%F%P: unrecognized -a option `%s'\n"), optarg
);
766 /* FIXME: We just ignore these, but we should handle them. */
767 if (strcmp (optarg
, "definitions") == 0)
769 else if (strcmp (optarg
, "nodefinitions") == 0)
771 else if (strcmp (optarg
, "nosymbolic") == 0)
773 else if (strcmp (optarg
, "pure-text") == 0)
776 einfo (_("%F%P: unrecognized -assert option `%s'\n"), optarg
);
779 ldfile_add_arch (optarg
);
782 lang_add_target (optarg
);
785 ldfile_open_command_file (optarg
);
786 parser_input
= input_mri_script
;
789 case OPTION_CALL_SHARED
:
790 input_flags
.dynamic
= TRUE
;
792 case OPTION_NON_SHARED
:
793 input_flags
.dynamic
= FALSE
;
796 command_line
.cref
= TRUE
;
797 link_info
.notice_all
= TRUE
;
800 command_line
.force_common_definition
= TRUE
;
802 case OPTION_FORCE_GROUP_ALLOCATION
:
803 command_line
.force_group_allocation
= TRUE
;
807 lex_redirect (optarg
, "--defsym", ++defsym_count
);
808 parser_input
= input_defsym
;
812 case OPTION_DEMANGLE
:
816 enum demangling_styles style
;
818 style
= cplus_demangle_name_to_style (optarg
);
819 if (style
== unknown_demangling
)
820 einfo (_("%F%P: unknown demangling style `%s'\n"),
823 cplus_demangle_set_style (style
);
826 case 'I': /* Used on Solaris. */
827 case OPTION_DYNAMIC_LINKER
:
828 command_line
.interpreter
= optarg
;
829 link_info
.nointerp
= 0;
831 case OPTION_NO_DYNAMIC_LINKER
:
832 link_info
.nointerp
= 1;
835 /* Already handled in ldmain.c. */
838 command_line
.endian
= ENDIAN_BIG
;
841 command_line
.endian
= ENDIAN_LITTLE
;
843 case OPTION_EMBEDDED_RELOCS
:
844 command_line
.embedded_relocs
= TRUE
;
846 case OPTION_EXPORT_DYNAMIC
:
847 case 'E': /* HP/UX compatibility. */
848 link_info
.export_dynamic
= TRUE
;
850 case OPTION_NO_EXPORT_DYNAMIC
:
851 link_info
.export_dynamic
= FALSE
;
853 case OPTION_NON_CONTIGUOUS_REGIONS
:
854 link_info
.non_contiguous_regions
= TRUE
;
856 case OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS
:
857 link_info
.non_contiguous_regions_warnings
= TRUE
;
860 lang_add_entry (optarg
, TRUE
);
863 if (command_line
.auxiliary_filters
== NULL
)
865 command_line
.auxiliary_filters
= (char **)
866 xmalloc (2 * sizeof (char *));
867 command_line
.auxiliary_filters
[0] = optarg
;
868 command_line
.auxiliary_filters
[1] = NULL
;
876 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
878 command_line
.auxiliary_filters
= (char **)
879 xrealloc (command_line
.auxiliary_filters
,
880 (c
+ 2) * sizeof (char *));
881 command_line
.auxiliary_filters
[c
] = optarg
;
882 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
886 command_line
.filter_shlib
= optarg
;
888 case OPTION_FORCE_EXE_SUFFIX
:
889 command_line
.force_exe_suffix
= TRUE
;
894 g_switch_value
= strtoul (optarg
, &end
, 0);
896 einfo (_("%F%P: invalid number `%s'\n"), optarg
);
902 case OPTION_GC_SECTIONS
:
903 link_info
.gc_sections
= TRUE
;
905 case OPTION_PRINT_GC_SECTIONS
:
906 link_info
.print_gc_sections
= TRUE
;
908 case OPTION_GC_KEEP_EXPORTED
:
909 link_info
.gc_keep_exported
= TRUE
;
916 ldfile_add_library_path (optarg
, TRUE
);
919 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
922 config
.map_filename
= "-";
925 /* Ignore. Was handled in a pre-parse. */
928 config
.map_filename
= optarg
;
931 config
.text_read_only
= FALSE
;
932 config
.magic_demand_paged
= FALSE
;
933 input_flags
.dynamic
= FALSE
;
935 case OPTION_NO_OMAGIC
:
936 config
.text_read_only
= TRUE
;
937 config
.magic_demand_paged
= TRUE
;
938 /* NB/ Does not set input_flags.dynamic to TRUE.
939 Use --call-shared or -Bdynamic for this. */
942 config
.text_read_only
= TRUE
;
943 config
.magic_demand_paged
= FALSE
;
944 input_flags
.dynamic
= FALSE
;
946 case OPTION_NO_DEFINE_COMMON
:
947 link_info
.inhibit_common_definition
= TRUE
;
949 case OPTION_NO_DEMANGLE
:
952 case OPTION_NO_GC_SECTIONS
:
953 link_info
.gc_sections
= FALSE
;
955 case OPTION_NO_PRINT_GC_SECTIONS
:
956 link_info
.print_gc_sections
= FALSE
;
958 case OPTION_NO_KEEP_MEMORY
:
959 link_info
.keep_memory
= FALSE
;
961 case OPTION_NO_UNDEFINED
:
962 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
964 case OPTION_ALLOW_SHLIB_UNDEFINED
:
965 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
967 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
968 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
970 case OPTION_UNRESOLVED_SYMBOLS
:
971 if (strcmp (optarg
, "ignore-all") == 0)
973 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
974 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
976 else if (strcmp (optarg
, "report-all") == 0)
978 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
979 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
981 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
983 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
984 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
986 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
988 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
989 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
992 einfo (_("%F%P: bad --unresolved-symbols option: %s\n"), optarg
);
994 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
995 link_info
.warn_unresolved_syms
= TRUE
;
997 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
998 link_info
.warn_unresolved_syms
= FALSE
;
1000 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
1001 link_info
.allow_multiple_definition
= TRUE
;
1003 case OPTION_NO_UNDEFINED_VERSION
:
1004 link_info
.allow_undefined_version
= FALSE
;
1006 case OPTION_DEFAULT_SYMVER
:
1007 link_info
.create_default_symver
= TRUE
;
1009 case OPTION_DEFAULT_IMPORTED_SYMVER
:
1010 link_info
.default_imported_symver
= TRUE
;
1012 case OPTION_NO_WARN_MISMATCH
:
1013 command_line
.warn_mismatch
= FALSE
;
1015 case OPTION_NO_WARN_SEARCH_MISMATCH
:
1016 command_line
.warn_search_mismatch
= FALSE
;
1018 case OPTION_NOINHIBIT_EXEC
:
1019 force_make_executable
= TRUE
;
1021 case OPTION_NOSTDLIB
:
1022 config
.only_cmd_line_lib_dirs
= TRUE
;
1024 case OPTION_NO_WHOLE_ARCHIVE
:
1025 input_flags
.whole_archive
= FALSE
;
1028 /* FIXME "-O<non-digits> <value>" used to set the address of
1029 section <non-digits>. Was this for compatibility with
1030 something, or can we create a new option to do that
1031 (with a syntax similar to -defsym)?
1032 getopt can't handle two args to an option without kludges. */
1034 /* Enable optimizations of output files. */
1035 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
1038 lang_add_output (optarg
, 0);
1040 case OPTION_OFORMAT
:
1041 lang_add_output_format (optarg
, NULL
, NULL
, 0);
1043 case OPTION_OUT_IMPLIB
:
1044 command_line
.out_implib_filename
= xstrdup (optarg
);
1046 case OPTION_PRINT_SYSROOT
:
1051 case OPTION_PRINT_OUTPUT_FORMAT
:
1052 command_line
.print_output_format
= TRUE
;
1054 #ifdef ENABLE_PLUGINS
1056 plugin_opt_plugin (optarg
);
1058 case OPTION_PLUGIN_OPT
:
1059 if (plugin_opt_plugin_arg (optarg
))
1060 einfo (_("%F%P: bad -plugin-opt option\n"));
1062 #endif /* ENABLE_PLUGINS */
1064 link_info
.emitrelocations
= TRUE
;
1068 if (optind
== last_optind
)
1069 /* This can happen if the user put "-rpath,a" on the command
1070 line. (Or something similar. The comma is important).
1071 Getopt becomes confused and thinks that this is a -r option
1072 but it cannot parse the text after the -r so it refuses to
1073 increment the optind counter. Detect this case and issue
1074 an error message here. We cannot just make this a warning,
1075 increment optind, and continue because getopt is too confused
1076 and will seg-fault the next time around. */
1077 einfo(_("%F%P: unrecognised option: %s\n"), argv
[optind
]);
1079 if (bfd_link_pic (&link_info
))
1080 einfo (_("%F%P: -r and %s may not be used together\n"),
1081 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1083 link_info
.type
= type_relocatable
;
1084 config
.build_constructors
= FALSE
;
1085 config
.magic_demand_paged
= FALSE
;
1086 config
.text_read_only
= FALSE
;
1087 input_flags
.dynamic
= FALSE
;
1090 /* The GNU linker traditionally uses -R to mean to include
1091 only the symbols from a file. The Solaris linker uses -R
1092 to set the path used by the runtime linker to find
1093 libraries. This is the GNU linker -rpath argument. We
1094 try to support both simultaneously by checking the file
1095 named. If it is a directory, rather than a regular file,
1096 we assume -rpath was meant. */
1100 if (stat (optarg
, &s
) >= 0
1101 && ! S_ISDIR (s
.st_mode
))
1103 lang_add_input_file (optarg
,
1104 lang_input_file_is_symbols_only_enum
,
1111 if (command_line
.rpath
== NULL
)
1112 command_line
.rpath
= xstrdup (optarg
);
1115 size_t rpath_len
= strlen (command_line
.rpath
);
1116 size_t optarg_len
= strlen (optarg
);
1118 char *cp
= command_line
.rpath
;
1120 /* First see whether OPTARG is already in the path. */
1123 if (strncmp (optarg
, cp
, optarg_len
) == 0
1124 && (cp
[optarg_len
] == 0
1125 || cp
[optarg_len
] == config
.rpath_separator
))
1129 /* Not yet found. */
1130 cp
= strchr (cp
, config
.rpath_separator
);
1138 buf
= (char *) xmalloc (rpath_len
+ optarg_len
+ 2);
1139 sprintf (buf
, "%s%c%s", command_line
.rpath
,
1140 config
.rpath_separator
, optarg
);
1141 free (command_line
.rpath
);
1142 command_line
.rpath
= buf
;
1146 case OPTION_RPATH_LINK
:
1147 if (command_line
.rpath_link
== NULL
)
1148 command_line
.rpath_link
= xstrdup (optarg
);
1153 buf
= (char *) xmalloc (strlen (command_line
.rpath_link
)
1156 sprintf (buf
, "%s%c%s", command_line
.rpath_link
,
1157 config
.rpath_separator
, optarg
);
1158 free (command_line
.rpath_link
);
1159 command_line
.rpath_link
= buf
;
1162 case OPTION_NO_RELAX
:
1168 case OPTION_RETAIN_SYMBOLS_FILE
:
1169 add_keepsyms_file (optarg
);
1172 link_info
.strip
= strip_debugger
;
1175 link_info
.strip
= strip_all
;
1177 case OPTION_STRIP_DISCARDED
:
1178 link_info
.strip_discarded
= TRUE
;
1180 case OPTION_NO_STRIP_DISCARDED
:
1181 link_info
.strip_discarded
= FALSE
;
1183 case OPTION_DISABLE_MULTIPLE_DEFS_ABS
:
1184 link_info
.prohibit_multiple_definition_absolute
= TRUE
;
1187 if (config
.has_shared
)
1189 if (bfd_link_relocatable (&link_info
))
1190 einfo (_("%F%P: -r and %s may not be used together\n"),
1193 link_info
.type
= type_dll
;
1194 /* When creating a shared library, the default
1195 behaviour is to ignore any unresolved references. */
1196 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1197 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1198 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1199 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1202 einfo (_("%F%P: -shared not supported\n"));
1205 if (config
.has_shared
)
1207 if (bfd_link_relocatable (&link_info
))
1208 einfo (_("%F%P: -r and %s may not be used together\n"), "-pie");
1210 link_info
.type
= type_pie
;
1213 einfo (_("%F%P: -pie not supported\n"));
1215 case 'h': /* Used on Solaris. */
1217 if (optarg
[0] == '\0' && command_line
.soname
1218 && command_line
.soname
[0])
1219 einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
1221 command_line
.soname
= optarg
;
1223 case OPTION_SORT_COMMON
:
1225 || strcmp (optarg
, N_("descending")) == 0)
1226 config
.sort_common
= sort_descending
;
1227 else if (strcmp (optarg
, N_("ascending")) == 0)
1228 config
.sort_common
= sort_ascending
;
1230 einfo (_("%F%P: invalid common section sorting option: %s\n"),
1233 case OPTION_SORT_SECTION
:
1234 if (strcmp (optarg
, N_("name")) == 0)
1235 sort_section
= by_name
;
1236 else if (strcmp (optarg
, N_("alignment")) == 0)
1237 sort_section
= by_alignment
;
1239 einfo (_("%F%P: invalid section sorting option: %s\n"),
1243 config
.stats
= TRUE
;
1245 case OPTION_SYMBOLIC
:
1246 opt_symbolic
= symbolic
;
1248 case OPTION_SYMBOLIC_FUNCTIONS
:
1249 opt_symbolic
= symbolic_functions
;
1255 previous_script_handle
= saved_script_handle
;
1256 ldfile_open_script_file (optarg
);
1257 parser_input
= input_script
;
1259 previous_script_handle
= NULL
;
1261 case OPTION_DEFAULT_SCRIPT
:
1262 command_line
.default_script
= optarg
;
1264 case OPTION_SECTION_START
:
1270 /* Check for <something>=<somthing>... */
1271 optarg2
= strchr (optarg
, '=');
1272 if (optarg2
== NULL
)
1273 einfo (_("%F%P: invalid argument to option"
1274 " \"--section-start\"\n"));
1278 /* So far so good. Are all the args present? */
1279 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1280 einfo (_("%F%P: missing argument(s) to option"
1281 " \"--section-start\"\n"));
1283 /* We must copy the section name as set_section_start
1284 doesn't do it for us. */
1285 len
= optarg2
- optarg
;
1286 sec_name
= (char *) xmalloc (len
);
1287 memcpy (sec_name
, optarg
, len
- 1);
1288 sec_name
[len
- 1] = 0;
1290 /* Then set it... */
1291 set_section_start (sec_name
, optarg2
);
1294 case OPTION_TARGET_HELP
:
1295 /* Mention any target specific options. */
1296 ldemul_list_emulation_options (stdout
);
1299 set_segment_start (".bss", optarg
);
1302 set_segment_start (".data", optarg
);
1305 set_segment_start (".text", optarg
);
1307 case OPTION_TTEXT_SEGMENT
:
1308 set_segment_start (".text-segment", optarg
);
1310 case OPTION_TRODATA_SEGMENT
:
1311 set_segment_start (".rodata-segment", optarg
);
1313 case OPTION_TLDATA_SEGMENT
:
1314 set_segment_start (".ldata-segment", optarg
);
1316 case OPTION_TRADITIONAL_FORMAT
:
1317 link_info
.traditional_format
= TRUE
;
1319 case OPTION_TASK_LINK
:
1320 link_info
.task_link
= TRUE
;
1323 if (bfd_link_pic (&link_info
))
1324 einfo (_("%F%P: -r and %s may not be used together\n"),
1325 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1327 link_info
.type
= type_relocatable
;
1328 config
.build_constructors
= TRUE
;
1329 config
.magic_demand_paged
= FALSE
;
1330 config
.text_read_only
= FALSE
;
1331 input_flags
.dynamic
= FALSE
;
1334 ldlang_add_undef (optarg
, TRUE
);
1336 case OPTION_REQUIRE_DEFINED_SYMBOL
:
1337 ldlang_add_require_defined (optarg
);
1341 lang_add_unique (optarg
);
1343 config
.unique_orphan_sections
= TRUE
;
1345 case OPTION_VERBOSE
:
1347 version_printed
= TRUE
;
1349 overflow_cutoff_limit
= -2;
1353 int level ATTRIBUTE_UNUSED
= strtoul (optarg
, &end
, 0);
1355 einfo (_("%F%P: invalid number `%s'\n"), optarg
);
1356 #ifdef ENABLE_PLUGINS
1357 report_plugin_symbols
= level
> 1;
1358 #endif /* ENABLE_PLUGINS */
1363 version_printed
= TRUE
;
1367 version_printed
= TRUE
;
1369 case OPTION_VERSION
:
1373 case OPTION_VERSION_SCRIPT
:
1374 /* This option indicates a small script that only specifies
1375 version information. Read it, but don't assume that
1376 we've seen a linker script. */
1378 FILE *hold_script_handle
;
1380 hold_script_handle
= saved_script_handle
;
1381 ldfile_open_command_file (optarg
);
1382 saved_script_handle
= hold_script_handle
;
1383 parser_input
= input_version_script
;
1387 case OPTION_VERSION_EXPORTS_SECTION
:
1388 /* This option records a version symbol to be applied to the
1389 symbols listed for export to be found in the object files
1390 .exports sections. */
1391 command_line
.version_exports_section
= optarg
;
1393 case OPTION_DYNAMIC_LIST_DATA
:
1394 opt_dynamic_list
= dynamic_list_data
;
1396 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO
:
1397 lang_append_dynamic_list_cpp_typeinfo ();
1398 if (opt_dynamic_list
!= dynamic_list_data
)
1399 opt_dynamic_list
= dynamic_list
;
1401 case OPTION_DYNAMIC_LIST_CPP_NEW
:
1402 lang_append_dynamic_list_cpp_new ();
1403 if (opt_dynamic_list
!= dynamic_list_data
)
1404 opt_dynamic_list
= dynamic_list
;
1406 case OPTION_DYNAMIC_LIST
:
1407 /* This option indicates a small script that only specifies
1408 a dynamic list. Read it, but don't assume that we've
1409 seen a linker script. */
1411 FILE *hold_script_handle
;
1413 hold_script_handle
= saved_script_handle
;
1414 ldfile_open_command_file (optarg
);
1415 saved_script_handle
= hold_script_handle
;
1416 parser_input
= input_dynamic_list
;
1419 if (opt_dynamic_list
!= dynamic_list_data
)
1420 opt_dynamic_list
= dynamic_list
;
1422 case OPTION_WARN_COMMON
:
1423 config
.warn_common
= TRUE
;
1425 case OPTION_WARN_CONSTRUCTORS
:
1426 config
.warn_constructors
= TRUE
;
1428 case OPTION_WARN_FATAL
:
1429 config
.fatal_warnings
= TRUE
;
1431 case OPTION_NO_WARN_FATAL
:
1432 config
.fatal_warnings
= FALSE
;
1434 case OPTION_WARN_MULTIPLE_GP
:
1435 config
.warn_multiple_gp
= TRUE
;
1437 case OPTION_WARN_ONCE
:
1438 config
.warn_once
= TRUE
;
1440 case OPTION_WARN_SECTION_ALIGN
:
1441 config
.warn_section_align
= TRUE
;
1443 case OPTION_WARN_TEXTREL
:
1444 link_info
.textrel_check
= textrel_check_warning
;
1446 case OPTION_WARN_ALTERNATE_EM
:
1447 link_info
.warn_alternate_em
= TRUE
;
1449 case OPTION_WHOLE_ARCHIVE
:
1450 input_flags
.whole_archive
= TRUE
;
1452 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
:
1453 input_flags
.add_DT_NEEDED_for_dynamic
= TRUE
;
1455 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
:
1456 input_flags
.add_DT_NEEDED_for_dynamic
= FALSE
;
1458 case OPTION_ADD_DT_NEEDED_FOR_REGULAR
:
1459 input_flags
.add_DT_NEEDED_for_regular
= TRUE
;
1461 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
:
1462 input_flags
.add_DT_NEEDED_for_regular
= FALSE
;
1467 case OPTION_IGNORE_UNRESOLVED_SYMBOL
:
1468 add_ignoresym (&link_info
, optarg
);
1470 case OPTION_DISCARD_NONE
:
1471 link_info
.discard
= discard_none
;
1474 link_info
.discard
= discard_l
;
1477 link_info
.discard
= discard_all
;
1480 if (CONST_STRNEQ (optarg
, "P,"))
1482 free (default_dirlist
);
1483 default_dirlist
= xstrdup (optarg
);
1488 case OPTION_SPARE_DYNAMIC_TAGS
:
1489 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1491 case OPTION_SPLIT_BY_RELOC
:
1493 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1495 config
.split_by_reloc
= 32768;
1497 case OPTION_SPLIT_BY_FILE
:
1499 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1501 config
.split_by_file
= 1;
1503 case OPTION_CHECK_SECTIONS
:
1504 command_line
.check_section_addresses
= 1;
1506 case OPTION_NO_CHECK_SECTIONS
:
1507 command_line
.check_section_addresses
= 0;
1509 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1510 command_line
.accept_unknown_input_arch
= TRUE
;
1512 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1513 command_line
.accept_unknown_input_arch
= FALSE
;
1516 lang_enter_group ();
1521 einfo (_("%F%P: group ended before it began (--help for usage)\n"));
1523 lang_leave_group ();
1528 link_info
.init_function
= optarg
;
1532 link_info
.fini_function
= optarg
;
1535 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1536 link_info
.reduce_memory_overheads
= TRUE
;
1537 if (config
.hash_table_size
== 0)
1538 config
.hash_table_size
= 1021;
1541 case OPTION_HASH_SIZE
:
1543 bfd_size_type new_size
;
1545 new_size
= strtoul (optarg
, NULL
, 0);
1547 config
.hash_table_size
= new_size
;
1549 einfo (_("%X%P: --hash-size needs a numeric argument\n"));
1553 case OPTION_PUSH_STATE
:
1554 input_flags
.pushed
= xmemdup (&input_flags
,
1555 sizeof (input_flags
),
1556 sizeof (input_flags
));
1559 case OPTION_POP_STATE
:
1560 if (input_flags
.pushed
== NULL
)
1561 einfo (_("%F%P: no state pushed before popping\n"));
1564 struct lang_input_statement_flags
*oldp
= input_flags
.pushed
;
1565 memcpy (&input_flags
, oldp
, sizeof (input_flags
));
1570 case OPTION_PRINT_MEMORY_USAGE
:
1571 command_line
.print_memory_usage
= TRUE
;
1574 case OPTION_ORPHAN_HANDLING
:
1575 if (strcasecmp (optarg
, "place") == 0)
1576 config
.orphan_handling
= orphan_handling_place
;
1577 else if (strcasecmp (optarg
, "warn") == 0)
1578 config
.orphan_handling
= orphan_handling_warn
;
1579 else if (strcasecmp (optarg
, "error") == 0)
1580 config
.orphan_handling
= orphan_handling_error
;
1581 else if (strcasecmp (optarg
, "discard") == 0)
1582 config
.orphan_handling
= orphan_handling_discard
;
1584 einfo (_("%F%P: invalid argument to option"
1585 " \"--orphan-handling\"\n"));
1588 case OPTION_NO_PRINT_MAP_DISCARDED
:
1589 config
.print_map_discarded
= FALSE
;
1592 case OPTION_PRINT_MAP_DISCARDED
:
1593 config
.print_map_discarded
= TRUE
;
1598 /* Run a couple of checks on the map filename. */
1599 if (config
.map_filename
)
1601 /* If name has been provided then use the
1602 output filename with a .map extension. */
1603 if (config
.map_filename
[0] == 0)
1605 /* FIXME: This is a memory leak as the string is never freed. */
1606 if (asprintf (&config
.map_filename
, "%s.map", output_filename
) < 0)
1607 einfo (_("%F%P: %s: can not create name of map file: %E\n"));
1613 /* If the map filename is actually a directory then create
1614 a file inside it, again based upon the output filename. */
1615 if (stat (config
.map_filename
, &s
) >= 0
1616 && S_ISDIR (s
.st_mode
))
1620 /* FIXME: Another memory leak. */
1621 if (asprintf (&new_name
, "%s/%s.map",
1622 config
.map_filename
, output_filename
) < 0)
1623 einfo (_("%F%P: %s: can not create name of map file: %E\n"));
1624 config
.map_filename
= new_name
;
1629 if (command_line
.soname
&& command_line
.soname
[0] == '\0')
1631 einfo (_("%P: SONAME must not be empty string; ignored\n"));
1632 command_line
.soname
= NULL
;
1637 einfo (_("%P: missing --end-group; added as last command line option\n"));
1638 lang_leave_group ();
1642 if (default_dirlist
!= NULL
)
1644 set_default_dirlist (default_dirlist
);
1645 free (default_dirlist
);
1648 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1649 /* FIXME: Should we allow emulations a chance to set this ? */
1650 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1652 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1653 /* FIXME: Should we allow emulations a chance to set this ? */
1654 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1656 if (bfd_link_relocatable (&link_info
)
1657 && command_line
.check_section_addresses
< 0)
1658 command_line
.check_section_addresses
= 0;
1660 switch (opt_dynamic_list
)
1662 case dynamic_list_unset
:
1664 case dynamic_list_data
:
1665 link_info
.dynamic_data
= TRUE
;
1668 link_info
.dynamic
= TRUE
;
1669 opt_symbolic
= symbolic_unset
;
1673 /* -Bsymbolic and -Bsymbols-functions are for shared library output. */
1674 if (bfd_link_dll (&link_info
))
1675 switch (opt_symbolic
)
1677 case symbolic_unset
:
1680 link_info
.symbolic
= TRUE
;
1681 if (link_info
.dynamic_list
)
1683 struct bfd_elf_version_expr
*ent
, *next
;
1684 for (ent
= link_info
.dynamic_list
->head
.list
; ent
; ent
= next
)
1689 free (link_info
.dynamic_list
);
1690 link_info
.dynamic_list
= NULL
;
1693 case symbolic_functions
:
1694 link_info
.dynamic
= TRUE
;
1695 link_info
.dynamic_data
= TRUE
;
1699 if (!bfd_link_dll (&link_info
))
1701 if (command_line
.filter_shlib
)
1702 einfo (_("%F%P: -F may not be used without -shared\n"));
1703 if (command_line
.auxiliary_filters
)
1704 einfo (_("%F%P: -f may not be used without -shared\n"));
1707 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
1708 don't see how else this can be handled, since in this case we
1709 must preserve all externally visible symbols. */
1710 if (bfd_link_relocatable (&link_info
) && link_info
.strip
== strip_all
)
1712 link_info
.strip
= strip_debugger
;
1713 if (link_info
.discard
== discard_sec_merge
)
1714 link_info
.discard
= discard_all
;
1718 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1719 library search path. */
1722 set_default_dirlist (char *dirlist_ptr
)
1728 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1731 if (*dirlist_ptr
!= '\0')
1732 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1735 dirlist_ptr
= p
+ 1;
1740 set_section_start (char *sect
, char *valstr
)
1743 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1745 einfo (_("%F%P: invalid hex number `%s'\n"), valstr
);
1746 lang_section_start (sect
, exp_intop (val
), NULL
);
1750 set_segment_start (const char *section
, char *valstr
)
1756 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1758 einfo (_("%F%P: invalid hex number `%s'\n"), valstr
);
1759 /* If we already have an entry for this segment, update the existing
1762 for (seg
= segments
; seg
; seg
= seg
->next
)
1763 if (strcmp (seg
->name
, name
) == 0)
1766 lang_section_start (section
, exp_intop (val
), seg
);
1769 /* There was no existing value so we must create a new segment
1771 seg
= stat_alloc (sizeof (*seg
));
1775 /* Add it to the linked list of segments. */
1776 seg
->next
= segments
;
1778 /* Historically, -Ttext and friends set the base address of a
1779 particular section. For backwards compatibility, we still do
1780 that. If a SEGMENT_START directive is seen, the section address
1781 assignment will be disabled. */
1782 lang_section_start (section
, exp_intop (val
), seg
);
1786 elf_shlib_list_options (FILE *file
)
1789 --audit=AUDITLIB Specify a library to use for auditing\n"));
1791 -Bgroup Selects group name lookup rules for DSO\n"));
1793 --disable-new-dtags Disable new dynamic tags\n"));
1795 --enable-new-dtags Enable new dynamic tags\n"));
1797 --eh-frame-hdr Create .eh_frame_hdr section\n"));
1799 --no-eh-frame-hdr Do not create .eh_frame_hdr section\n"));
1801 --exclude-libs=LIBS Make all symbols in LIBS hidden\n"));
1803 --hash-style=STYLE Set hash style to sysv/gnu/both. Default: "));
1804 if (DEFAULT_EMIT_SYSV_HASH
)
1806 /* Note - these strings are not translated as
1807 they are keywords not descriptive text. */
1808 if (DEFAULT_EMIT_GNU_HASH
)
1809 fprintf (file
, "both\n");
1811 fprintf (file
, "sysv\n");
1815 if (DEFAULT_EMIT_GNU_HASH
)
1816 fprintf (file
, "gnu\n");
1818 /* FIXME: Can this happen ? */
1819 fprintf (file
, "none\n");
1822 -P AUDITLIB, --depaudit=AUDITLIB\n" "\
1823 Specify a library to use for auditing dependencies\n"));
1825 -z combreloc Merge dynamic relocs into one section and sort\n"));
1827 -z nocombreloc Don't merge dynamic relocs into one section\n"));
1829 -z global Make symbols in DSO available for subsequently\n\
1830 loaded objects\n"));
1832 -z initfirst Mark DSO to be initialized first at runtime\n"));
1834 -z interpose Mark object to interpose all DSOs but executable\n"));
1836 -z lazy Mark object lazy runtime binding (default)\n"));
1838 -z loadfltr Mark object requiring immediate process\n"));
1840 -z nocopyreloc Don't create copy relocs\n"));
1842 -z nodefaultlib Mark object not to use default search paths\n"));
1844 -z nodelete Mark DSO non-deletable at runtime\n"));
1846 -z nodlopen Mark DSO not available to dlopen\n"));
1848 -z nodump Mark DSO not available to dldump\n"));
1850 -z now Mark object non-lazy runtime binding\n"));
1852 -z origin Mark object requiring immediate $ORIGIN\n\
1853 processing at runtime\n"));
1854 #if DEFAULT_LD_Z_RELRO
1856 -z relro Create RELRO program header (default)\n"));
1858 -z norelro Don't create RELRO program header\n"));
1861 -z relro Create RELRO program header\n"));
1863 -z norelro Don't create RELRO program header (default)\n"));
1865 #if DEFAULT_LD_Z_SEPARATE_CODE
1867 -z separate-code Create separate code program header (default)\n"));
1869 -z noseparate-code Don't create separate code program header\n"));
1872 -z separate-code Create separate code program header\n"));
1874 -z noseparate-code Don't create separate code program header (default)\n"));
1877 -z common Generate common symbols with STT_COMMON type\n"));
1879 -z nocommon Generate common symbols with STT_OBJECT type\n"));
1881 -z stack-size=SIZE Set size of stack segment\n"));
1882 if (link_info
.textrel_check
== textrel_check_error
)
1884 -z text Treat DT_TEXTREL in output as error (default)\n"));
1887 -z text Treat DT_TEXTREL in output as error\n"));
1888 if (link_info
.textrel_check
== textrel_check_none
)
1891 -z notext Don't treat DT_TEXTREL in output as error (default)\n"));
1893 -z textoff Don't treat DT_TEXTREL in output as error (default)\n"));
1898 -z notext Don't treat DT_TEXTREL in output as error\n"));
1900 -z textoff Don't treat DT_TEXTREL in output as error\n"));
1905 elf_static_list_options (FILE *file
)
1908 --build-id[=STYLE] Generate build ID note\n"));
1910 --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]\n\
1911 Compress DWARF debug sections using zlib\n"));
1912 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
1914 Default: zlib-gabi\n"));
1920 -z common-page-size=SIZE Set common page size to SIZE\n"));
1922 -z max-page-size=SIZE Set maximum page size to SIZE\n"));
1924 -z defs Report unresolved symbols in object files\n"));
1926 -z muldefs Allow multiple definitions\n"));
1928 -z execstack Mark executable as requiring executable stack\n"));
1930 -z noexecstack Mark executable as not requiring executable stack\n"));
1932 -z globalaudit Mark executable requiring global auditing\n"));
1936 elf_plt_unwind_list_options (FILE *file
)
1939 --ld-generated-unwind-info Generate exception handling info for PLT\n"));
1941 --no-ld-generated-unwind-info\n\
1942 Don't generate exception handling info for PLT\n"));
1946 ld_list_options (FILE *file
, bfd_boolean elf
, bfd_boolean shlib
,
1947 bfd_boolean plt_unwind
)
1951 printf (_("ELF emulations:\n"));
1953 elf_plt_unwind_list_options (file
);
1954 elf_static_list_options (file
);
1956 elf_shlib_list_options (file
);
1960 /* Print help messages for the options. */
1966 const char **targets
, **pp
;
1969 printf (_("Usage: %s [options] file...\n"), program_name
);
1971 printf (_("Options:\n"));
1972 for (i
= 0; i
< OPTION_COUNT
; i
++)
1974 if (ld_options
[i
].doc
!= NULL
)
1987 if (ld_options
[j
].shortopt
!= '\0'
1988 && ld_options
[j
].control
!= NO_HELP
)
1990 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1991 len
+= (comma
? 2 : 0) + 2;
1992 if (ld_options
[j
].arg
!= NULL
)
1994 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1999 printf ("%s", _(ld_options
[j
].arg
));
2000 len
+= strlen (_(ld_options
[j
].arg
));
2006 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
2011 if (ld_options
[j
].opt
.name
!= NULL
2012 && ld_options
[j
].control
!= NO_HELP
)
2015 (ld_options
[j
].control
== TWO_DASHES
2016 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
2020 two_dashes
? "-" : "",
2021 ld_options
[j
].opt
.name
);
2022 len
+= ((comma
? 2 : 0)
2024 + (two_dashes
? 1 : 0)
2025 + strlen (ld_options
[j
].opt
.name
));
2026 if (ld_options
[j
].arg
!= NULL
)
2028 printf (" %s", _(ld_options
[j
].arg
));
2029 len
+= 1 + strlen (_(ld_options
[j
].arg
));
2035 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
2043 for (; len
< 30; len
++)
2046 printf ("%s\n", _(ld_options
[i
].doc
));
2049 printf (_(" @FILE"));
2050 for (len
= strlen (" @FILE"); len
< 30; len
++)
2052 printf (_("Read options from FILE\n"));
2054 /* Note: Various tools (such as libtool) depend upon the
2055 format of the listings below - do not change them. */
2056 /* xgettext:c-format */
2057 printf (_("%s: supported targets:"), program_name
);
2058 targets
= bfd_target_list ();
2059 for (pp
= targets
; *pp
!= NULL
; pp
++)
2060 printf (" %s", *pp
);
2064 /* xgettext:c-format */
2065 printf (_("%s: supported emulations: "), program_name
);
2066 ldemul_list_emulations (stdout
);
2069 /* xgettext:c-format */
2070 printf (_("%s: emulation specific options:\n"), program_name
);
2071 ld_list_options (stdout
, ELF_LIST_OPTIONS
, ELF_SHLIB_LIST_OPTIONS
,
2072 ELF_PLT_UNWIND_LIST_OPTIONS
);
2073 ldemul_list_emulation_options (stdout
);
2076 if (REPORT_BUGS_TO
[0])
2077 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);