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"),
189 { {"plugin", required_argument
, NULL
, OPTION_IGNORE
},
190 '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH
},
191 { {"plugin-opt", required_argument
, NULL
, OPTION_IGNORE
},
192 '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH
},
193 #endif /* ENABLE_PLUGINS */
194 { {"fuse-ld=", required_argument
, NULL
, OPTION_IGNORE
},
195 '\0', NULL
, N_("Ignored for GCC linker option compatibility"),
197 { {"map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
198 '\0', NULL
, N_("Ignored for gold option compatibility"),
200 { {"no-map-whole-files", optional_argument
, NULL
, OPTION_IGNORE
},
201 '\0', NULL
, N_("Ignored for gold option compatibility"),
203 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
204 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
205 { {"emit-relocs", no_argument
, NULL
, 'q'},
206 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
207 { {"relocatable", no_argument
, NULL
, 'r'},
208 'r', NULL
, N_("Generate relocatable output"), TWO_DASHES
},
209 { {NULL
, no_argument
, NULL
, '\0'},
210 'i', NULL
, NULL
, ONE_DASH
},
211 { {"just-symbols", required_argument
, NULL
, 'R'},
212 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
214 { {"strip-all", no_argument
, NULL
, 's'},
215 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
216 { {"strip-debug", no_argument
, NULL
, 'S'},
217 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
218 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
219 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
220 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
221 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
222 { {"trace", no_argument
, NULL
, 't'},
223 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
224 { {"script", required_argument
, NULL
, 'T'},
225 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
226 { {"default-script", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
227 '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES
},
228 { {"dT", required_argument
, NULL
, OPTION_DEFAULT_SCRIPT
},
229 '\0', NULL
, NULL
, ONE_DASH
},
230 { {"undefined", required_argument
, NULL
, 'u'},
231 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
233 { {"require-defined", required_argument
, NULL
, OPTION_REQUIRE_DEFINED_SYMBOL
},
234 '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
236 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
237 '\0', N_("[=SECTION]"),
238 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
239 { {"Ur", no_argument
, NULL
, OPTION_UR
},
240 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
241 { {"version", no_argument
, NULL
, OPTION_VERSION
},
242 'v', NULL
, N_("Print version information"), TWO_DASHES
},
243 { {NULL
, no_argument
, NULL
, '\0'},
244 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
245 { {"discard-all", no_argument
, NULL
, 'x'},
246 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
247 { {"discard-locals", no_argument
, NULL
, 'X'},
248 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
249 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
250 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
251 { {"trace-symbol", required_argument
, NULL
, 'y'},
252 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
253 { {NULL
, required_argument
, NULL
, '\0'},
254 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
256 { {"start-group", no_argument
, NULL
, '('},
257 '(', NULL
, N_("Start a group"), TWO_DASHES
},
258 { {"end-group", no_argument
, NULL
, ')'},
259 ')', NULL
, N_("End a group"), TWO_DASHES
},
260 { {"accept-unknown-input-arch", no_argument
, NULL
,
261 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
263 N_("Accept input files whose architecture cannot be determined"),
265 { {"no-accept-unknown-input-arch", no_argument
, NULL
,
266 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
267 '\0', NULL
, N_("Reject input files whose architecture is unknown"),
270 /* The next two options are deprecated because of their similarity to
271 --as-needed and --no-as-needed. They have been replaced by
272 --copy-dt-needed-entries and --no-copy-dt-needed-entries. */
273 { {"add-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
274 '\0', NULL
, NULL
, NO_HELP
},
275 { {"no-add-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
276 '\0', NULL
, NULL
, NO_HELP
},
278 { {"as-needed", no_argument
, NULL
, OPTION_ADD_DT_NEEDED_FOR_REGULAR
},
279 '\0', NULL
, N_("Only set DT_NEEDED for following dynamic libs if used"),
281 { {"no-as-needed", no_argument
, NULL
, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
},
282 '\0', NULL
, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
283 " the command line"),
285 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
286 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
287 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
288 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
289 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
290 '\0', NULL
, NULL
, ONE_DASH
},
291 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
292 '\0', NULL
, NULL
, ONE_DASH
},
293 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
294 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
295 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
296 '\0', NULL
, NULL
, ONE_DASH
},
297 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
298 '\0', NULL
, NULL
, ONE_DASH
},
299 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
300 '\0', NULL
, NULL
, ONE_DASH
},
301 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
302 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
303 { {"Bsymbolic-functions", no_argument
, NULL
, OPTION_SYMBOLIC_FUNCTIONS
},
304 '\0', NULL
, N_("Bind global function references locally"), ONE_DASH
},
305 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
306 '\0', NULL
, N_("Check section addresses for overlaps (default)"),
308 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
309 '\0', NULL
, N_("Do not check section addresses for overlaps"),
311 { {"copy-dt-needed-entries", no_argument
, NULL
,
312 OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
},
313 '\0', NULL
, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
315 { {"no-copy-dt-needed-entries", no_argument
, NULL
,
316 OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
},
317 '\0', NULL
, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
320 { {"cref", no_argument
, NULL
, OPTION_CREF
},
321 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
322 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
323 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
324 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
325 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
327 { {"disable-multiple-abs-defs", no_argument
, NULL
,
328 OPTION_DISABLE_MULTIPLE_DEFS_ABS
},
329 '\0', NULL
, N_("Do not allow multiple definitions with symbols included\n"
330 " in filename invoked by -R or --just-symbols"),
332 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
333 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
334 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
335 '\0', NULL
, N_("Treat warnings as errors"),
337 { {"no-fatal-warnings", no_argument
, NULL
, OPTION_NO_WARN_FATAL
},
338 '\0', NULL
, N_("Do not treat warnings as errors (default)"),
340 { {"fini", required_argument
, NULL
, OPTION_FINI
},
341 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
342 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
343 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
344 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
345 '\0', NULL
, N_("Remove unused sections (on some targets)"),
347 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
348 '\0', NULL
, N_("Don't remove unused sections (default)"),
350 { {"print-gc-sections", no_argument
, NULL
, OPTION_PRINT_GC_SECTIONS
},
351 '\0', NULL
, N_("List removed unused sections on stderr"),
353 { {"no-print-gc-sections", no_argument
, NULL
, OPTION_NO_PRINT_GC_SECTIONS
},
354 '\0', NULL
, N_("Do not list removed unused sections"),
356 { {"gc-keep-exported", no_argument
, NULL
, OPTION_GC_KEEP_EXPORTED
},
357 '\0', NULL
, N_("Keep exported symbols when removing unused sections"),
359 { {"hash-size=<NUMBER>", required_argument
, NULL
, OPTION_HASH_SIZE
},
360 '\0', NULL
, N_("Set default hash table size close to <NUMBER>"),
362 { {"help", no_argument
, NULL
, OPTION_HELP
},
363 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
364 { {"init", required_argument
, NULL
, OPTION_INIT
},
365 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
366 { {"Map", required_argument
, NULL
, OPTION_MAP
},
367 '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH
},
368 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
369 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
370 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
371 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
372 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
373 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
374 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
375 '\0', NULL
, N_("Do not allow unresolved references in object files"),
377 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
378 '\0', NULL
, N_("Allow unresolved references in shared libraries"),
380 { {"no-allow-shlib-undefined", no_argument
, NULL
,
381 OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
382 '\0', NULL
, N_("Do not allow unresolved references in shared libs"),
384 { {"allow-multiple-definition", no_argument
, NULL
,
385 OPTION_ALLOW_MULTIPLE_DEFINITION
},
386 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
387 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
388 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
389 { {"default-symver", no_argument
, NULL
, OPTION_DEFAULT_SYMVER
},
390 '\0', NULL
, N_("Create default symbol version"), TWO_DASHES
},
391 { {"default-imported-symver", no_argument
, NULL
,
392 OPTION_DEFAULT_IMPORTED_SYMVER
},
393 '\0', NULL
, N_("Create default symbol version for imported symbols"),
395 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
396 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
397 { {"no-warn-search-mismatch", no_argument
, NULL
,
398 OPTION_NO_WARN_SEARCH_MISMATCH
},
399 '\0', NULL
, N_("Don't warn on finding an incompatible library"),
401 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
402 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
403 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
404 '\0', NULL
, N_("Create an output file even if errors occur"),
406 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
407 '\0', NULL
, NULL
, NO_HELP
},
408 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
409 '\0', NULL
, N_("Only use library directories specified on\n"
410 " the command line"),
412 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
413 '\0', N_("TARGET"), N_("Specify target of output file"),
414 EXACTLY_TWO_DASHES
},
415 { {"print-output-format", no_argument
, NULL
, OPTION_PRINT_OUTPUT_FORMAT
},
416 '\0', NULL
, N_("Print default output format"), TWO_DASHES
},
417 { {"print-sysroot", no_argument
, NULL
, OPTION_PRINT_SYSROOT
},
418 '\0', NULL
, N_("Print current sysroot"), TWO_DASHES
},
419 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
420 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
421 { {"reduce-memory-overheads", no_argument
, NULL
,
422 OPTION_REDUCE_MEMORY_OVERHEADS
},
423 '\0', NULL
, N_("Reduce memory overheads, possibly taking much longer"),
425 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
426 '\0', NULL
, N_("Reduce code size by using target specific optimizations"), TWO_DASHES
},
427 { {"no-relax", no_argument
, NULL
, OPTION_NO_RELAX
},
428 '\0', NULL
, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES
},
429 { {"retain-symbols-file", required_argument
, NULL
,
430 OPTION_RETAIN_SYMBOLS_FILE
},
431 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
432 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
433 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
434 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
435 '\0', N_("PATH"), N_("Set link time shared library search path"),
437 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
438 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
439 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
440 '\0', NULL
, NULL
, ONE_DASH
},
441 { {"pie", no_argument
, NULL
, OPTION_PIE
},
442 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
443 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
444 '\0', NULL
, NULL
, TWO_DASHES
},
445 { {"sort-common", optional_argument
, NULL
, OPTION_SORT_COMMON
},
446 '\0', N_("[=ascending|descending]"),
447 N_("Sort common symbols by alignment [in specified order]"),
449 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
450 '\0', NULL
, NULL
, NO_HELP
},
451 { {"sort-section", required_argument
, NULL
, OPTION_SORT_SECTION
},
452 '\0', N_("name|alignment"),
453 N_("Sort sections by name or maximum alignment"), TWO_DASHES
},
454 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
455 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
457 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
458 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
460 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
461 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
463 { {"stats", no_argument
, NULL
, OPTION_STATS
},
464 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
465 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
466 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
467 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
468 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
469 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
470 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
471 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
472 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
474 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
475 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
476 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
477 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
478 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
479 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
480 { {"Ttext-segment", required_argument
, NULL
, OPTION_TTEXT_SEGMENT
},
481 '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH
},
482 { {"Trodata-segment", required_argument
, NULL
, OPTION_TRODATA_SEGMENT
},
483 '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH
},
484 { {"Tldata-segment", required_argument
, NULL
, OPTION_TLDATA_SEGMENT
},
485 '\0', N_("ADDRESS"), N_("Set address of ldata segment"), ONE_DASH
},
486 { {"unresolved-symbols=<method>", required_argument
, NULL
,
487 OPTION_UNRESOLVED_SYMBOLS
},
488 '\0', NULL
, N_("How to handle unresolved symbols. <method> is:\n"
489 " ignore-all, report-all, ignore-in-object-files,\n"
490 " ignore-in-shared-libs"),
492 { {"verbose", optional_argument
, NULL
, OPTION_VERBOSE
},
493 '\0', N_("[=NUMBER]"),
494 N_("Output lots of information during link"), TWO_DASHES
},
495 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
496 '\0', NULL
, NULL
, NO_HELP
},
497 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
498 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
499 { {"version-exports-section", required_argument
, NULL
,
500 OPTION_VERSION_EXPORTS_SECTION
},
501 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
502 " SYMBOL as the version."),
504 { {"dynamic-list-data", no_argument
, NULL
, OPTION_DYNAMIC_LIST_DATA
},
505 '\0', NULL
, N_("Add data symbols to dynamic list"), TWO_DASHES
},
506 { {"dynamic-list-cpp-new", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_NEW
},
507 '\0', NULL
, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES
},
508 { {"dynamic-list-cpp-typeinfo", no_argument
, NULL
, OPTION_DYNAMIC_LIST_CPP_TYPEINFO
},
509 '\0', NULL
, N_("Use C++ typeinfo dynamic list"), TWO_DASHES
},
510 { {"dynamic-list", required_argument
, NULL
, OPTION_DYNAMIC_LIST
},
511 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES
},
512 { {"export-dynamic-symbol", required_argument
, NULL
, OPTION_EXPORT_DYNAMIC_SYMBOL
},
513 '\0', N_("SYMBOL"), N_("Export the specified symbol"), EXACTLY_TWO_DASHES
},
514 { {"export-dynamic-symbol-list", required_argument
, NULL
, OPTION_EXPORT_DYNAMIC_SYMBOL_LIST
},
515 '\0', N_("FILE"), N_("Read export dynamic symbol list"), EXACTLY_TWO_DASHES
},
516 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
517 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
518 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
519 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
521 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
522 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
523 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
524 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
525 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
526 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
528 { {"warn-textrel", no_argument
, NULL
, OPTION_WARN_TEXTREL
},
530 #if DEFAULT_LD_TEXTREL_CHECK_WARNING
531 N_("Warn if outpout has DT_TEXTREL (default)"),
533 N_("Warn if outpout has DT_TEXTREL"),
536 { {"warn-shared-textrel", no_argument
, NULL
, OPTION_WARN_TEXTREL
},
537 '\0', NULL
, NULL
, NO_HELP
},
538 { {"warn-alternate-em", no_argument
, NULL
, OPTION_WARN_ALTERNATE_EM
},
539 '\0', NULL
, N_("Warn if an object has alternate ELF machine code"),
541 { {"warn-unresolved-symbols", no_argument
, NULL
,
542 OPTION_WARN_UNRESOLVED_SYMBOLS
},
543 '\0', NULL
, N_("Report unresolved symbols as warnings"), TWO_DASHES
},
544 { {"error-unresolved-symbols", no_argument
, NULL
,
545 OPTION_ERROR_UNRESOLVED_SYMBOLS
},
546 '\0', NULL
, N_("Report unresolved symbols as errors"), TWO_DASHES
},
547 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
548 '\0', NULL
, N_("Include all objects from following archives"),
550 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
551 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
552 { {"ignore-unresolved-symbol", required_argument
, NULL
,
553 OPTION_IGNORE_UNRESOLVED_SYMBOL
},
555 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES
},
556 { {"push-state", no_argument
, NULL
, OPTION_PUSH_STATE
},
557 '\0', NULL
, N_("Push state of flags governing input file handling"),
559 { {"pop-state", no_argument
, NULL
, OPTION_POP_STATE
},
560 '\0', NULL
, N_("Pop state of flags governing input file handling"),
562 { {"print-memory-usage", no_argument
, NULL
, OPTION_PRINT_MEMORY_USAGE
},
563 '\0', NULL
, N_("Report target memory usage"), TWO_DASHES
},
564 { {"orphan-handling", required_argument
, NULL
, OPTION_ORPHAN_HANDLING
},
565 '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
567 { {"print-map-discarded", no_argument
, NULL
, OPTION_PRINT_MAP_DISCARDED
},
568 '\0', NULL
, N_("Show discarded sections in map file output (default)"),
570 { {"no-print-map-discarded", no_argument
, NULL
, OPTION_NO_PRINT_MAP_DISCARDED
},
571 '\0', NULL
, N_("Do not show discarded sections in map file output"),
575 #define OPTION_COUNT ARRAY_SIZE (ld_options)
578 parse_args (unsigned argc
, char **argv
)
583 char *default_dirlist
= NULL
;
585 struct option
*longopts
;
586 struct option
*really_longopts
;
593 } opt_symbolic
= symbolic_unset
;
594 enum dynamic_list_enum
596 dynamic_list_unset
= 0,
599 } opt_dynamic_list
= dynamic_list_unset
;
600 struct bfd_elf_dynamic_list
*export_list
= NULL
;
602 shortopts
= (char *) xmalloc (OPTION_COUNT
* 3 + 2);
603 longopts
= (struct option
*)
604 xmalloc (sizeof (*longopts
) * (OPTION_COUNT
+ 1));
605 really_longopts
= (struct option
*)
606 malloc (sizeof (*really_longopts
) * (OPTION_COUNT
+ 1));
608 /* Starting the short option string with '-' is for programs that
609 expect options and other ARGV-elements in any order and that care about
610 the ordering of the two. We describe each non-option ARGV-element
611 as if it were the argument of an option with character code 1. */
616 for (i
= 0; i
< OPTION_COUNT
; i
++)
618 if (ld_options
[i
].shortopt
!= '\0')
620 shortopts
[is
] = ld_options
[i
].shortopt
;
622 if (ld_options
[i
].opt
.has_arg
== required_argument
623 || ld_options
[i
].opt
.has_arg
== optional_argument
)
627 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
634 if (ld_options
[i
].opt
.name
!= NULL
)
636 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
638 really_longopts
[irl
] = ld_options
[i
].opt
;
643 longopts
[il
] = ld_options
[i
].opt
;
648 shortopts
[is
] = '\0';
649 longopts
[il
].name
= NULL
;
650 really_longopts
[irl
].name
= NULL
;
652 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
654 /* The -G option is ambiguous on different platforms. Sometimes it
655 specifies the largest data size to put into the small data
656 section. Sometimes it is equivalent to --shared. Unfortunately,
657 the first form takes an argument, while the second does not.
659 We need to permit the --shared form because on some platforms,
660 such as Solaris, gcc -shared will pass -G to the linker.
662 To permit either usage, we look through the argument list. If we
663 find -G not followed by a number, we change it into --shared.
664 This will work for most normal cases. */
665 for (i
= 1; i
< argc
; i
++)
666 if (strcmp (argv
[i
], "-G") == 0
668 || ! ISDIGIT (argv
[i
+ 1][0])))
669 argv
[i
] = (char *) "--shared";
671 /* Because we permit long options to start with a single dash, and
672 we have a --library option, and the -l option is conventionally
673 used with an immediately following argument, we can have bad
674 results if somebody tries to use -l with a library whose name
675 happens to start with "ibrary", as in -li. We avoid problems by
676 simply turning -l into --library. This means that users will
677 have to use two dashes in order to use --library, which is OK
678 since that's how it is documented.
680 FIXME: It's possible that this problem can arise for other short
681 options as well, although the user does always have the recourse
682 of adding a space between the option and the argument. */
683 for (i
= 1; i
< argc
; i
++)
685 if (argv
[i
][0] == '-'
687 && argv
[i
][2] != '\0')
691 n
= (char *) xmalloc (strlen (argv
[i
]) + 20);
692 sprintf (n
, "--library=%s", argv
[i
] + 2);
702 static unsigned int defsym_count
;
704 /* Using last_optind lets us avoid calling ldemul_parse_args
705 multiple times on a single option, which would lead to
706 confusion in the internal static variables maintained by
707 getopt. This could otherwise happen for an argument like
708 -nx, in which the -n is parsed as a single option, and we
709 loop around to pick up the -x. */
710 if (optind
!= last_optind
)
711 if (ldemul_parse_args (argc
, argv
))
714 /* getopt_long_only is like getopt_long, but '-' as well as '--'
715 can indicate a long option. */
717 last_optind
= optind
;
718 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
721 optind
= last_optind
;
722 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
725 if (ldemul_handle_option (optc
))
735 /* If the last word on the command line is an option that
736 requires an argument, getopt will refuse to recognise it.
737 Try to catch such options here and issue a more helpful
738 error message than just "unrecognized option". */
741 for (opt
= ARRAY_SIZE (ld_options
); opt
--;)
742 if (ld_options
[opt
].opt
.has_arg
== required_argument
743 /* FIXME: There are a few short options that do not
744 have long equivalents, but which require arguments.
745 We should handle them too. */
746 && ld_options
[opt
].opt
.name
!= NULL
747 && strcmp (argv
[last_optind
] + ld_options
[opt
].control
, ld_options
[opt
].opt
.name
) == 0)
749 einfo (_("%P: %s: missing argument\n"), argv
[last_optind
]);
754 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
759 einfo (_("%F%P: use the --help option for usage information\n"));
762 case 1: /* File name. */
763 lang_add_input_file (optarg
, lang_input_file_is_file_enum
, NULL
);
769 /* For HP/UX compatibility. Actually -a shared should mean
770 ``use only shared libraries'' but, then, we don't
771 currently support shared libraries on HP/UX anyhow. */
772 if (strcmp (optarg
, "archive") == 0)
773 input_flags
.dynamic
= FALSE
;
774 else if (strcmp (optarg
, "shared") == 0
775 || strcmp (optarg
, "default") == 0)
776 input_flags
.dynamic
= TRUE
;
778 einfo (_("%F%P: unrecognized -a option `%s'\n"), optarg
);
781 /* FIXME: We just ignore these, but we should handle them. */
782 if (strcmp (optarg
, "definitions") == 0)
784 else if (strcmp (optarg
, "nodefinitions") == 0)
786 else if (strcmp (optarg
, "nosymbolic") == 0)
788 else if (strcmp (optarg
, "pure-text") == 0)
791 einfo (_("%F%P: unrecognized -assert option `%s'\n"), optarg
);
794 ldfile_add_arch (optarg
);
797 lang_add_target (optarg
);
800 ldfile_open_command_file (optarg
);
801 parser_input
= input_mri_script
;
804 case OPTION_CALL_SHARED
:
805 input_flags
.dynamic
= TRUE
;
807 case OPTION_NON_SHARED
:
808 input_flags
.dynamic
= FALSE
;
811 command_line
.cref
= TRUE
;
812 link_info
.notice_all
= TRUE
;
815 command_line
.force_common_definition
= TRUE
;
817 case OPTION_FORCE_GROUP_ALLOCATION
:
818 command_line
.force_group_allocation
= TRUE
;
822 lex_redirect (optarg
, "--defsym", ++defsym_count
);
823 parser_input
= input_defsym
;
827 case OPTION_DEMANGLE
:
831 enum demangling_styles style
;
833 style
= cplus_demangle_name_to_style (optarg
);
834 if (style
== unknown_demangling
)
835 einfo (_("%F%P: unknown demangling style `%s'\n"),
838 cplus_demangle_set_style (style
);
841 case 'I': /* Used on Solaris. */
842 case OPTION_DYNAMIC_LINKER
:
843 command_line
.interpreter
= optarg
;
844 link_info
.nointerp
= 0;
846 case OPTION_NO_DYNAMIC_LINKER
:
847 link_info
.nointerp
= 1;
850 /* Already handled in ldmain.c. */
853 command_line
.endian
= ENDIAN_BIG
;
856 command_line
.endian
= ENDIAN_LITTLE
;
858 case OPTION_EMBEDDED_RELOCS
:
859 command_line
.embedded_relocs
= TRUE
;
861 case OPTION_EXPORT_DYNAMIC
:
862 case 'E': /* HP/UX compatibility. */
863 link_info
.export_dynamic
= TRUE
;
865 case OPTION_NO_EXPORT_DYNAMIC
:
866 link_info
.export_dynamic
= FALSE
;
868 case OPTION_NON_CONTIGUOUS_REGIONS
:
869 link_info
.non_contiguous_regions
= TRUE
;
871 case OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS
:
872 link_info
.non_contiguous_regions_warnings
= TRUE
;
875 lang_add_entry (optarg
, TRUE
);
878 if (command_line
.auxiliary_filters
== NULL
)
880 command_line
.auxiliary_filters
= (char **)
881 xmalloc (2 * sizeof (char *));
882 command_line
.auxiliary_filters
[0] = optarg
;
883 command_line
.auxiliary_filters
[1] = NULL
;
891 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
893 command_line
.auxiliary_filters
= (char **)
894 xrealloc (command_line
.auxiliary_filters
,
895 (c
+ 2) * sizeof (char *));
896 command_line
.auxiliary_filters
[c
] = optarg
;
897 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
901 command_line
.filter_shlib
= optarg
;
903 case OPTION_FORCE_EXE_SUFFIX
:
904 command_line
.force_exe_suffix
= TRUE
;
909 g_switch_value
= strtoul (optarg
, &end
, 0);
911 einfo (_("%F%P: invalid number `%s'\n"), optarg
);
917 case OPTION_GC_SECTIONS
:
918 link_info
.gc_sections
= TRUE
;
920 case OPTION_PRINT_GC_SECTIONS
:
921 link_info
.print_gc_sections
= TRUE
;
923 case OPTION_GC_KEEP_EXPORTED
:
924 link_info
.gc_keep_exported
= TRUE
;
931 ldfile_add_library_path (optarg
, TRUE
);
934 lang_add_input_file (optarg
, lang_input_file_is_l_enum
, NULL
);
937 config
.map_filename
= "-";
940 /* Ignore. Was handled in a pre-parse. */
943 config
.map_filename
= optarg
;
946 config
.text_read_only
= FALSE
;
947 config
.magic_demand_paged
= FALSE
;
948 input_flags
.dynamic
= FALSE
;
950 case OPTION_NO_OMAGIC
:
951 config
.text_read_only
= TRUE
;
952 config
.magic_demand_paged
= TRUE
;
953 /* NB/ Does not set input_flags.dynamic to TRUE.
954 Use --call-shared or -Bdynamic for this. */
957 config
.text_read_only
= TRUE
;
958 config
.magic_demand_paged
= FALSE
;
959 input_flags
.dynamic
= FALSE
;
961 case OPTION_NO_DEFINE_COMMON
:
962 link_info
.inhibit_common_definition
= TRUE
;
964 case OPTION_NO_DEMANGLE
:
967 case OPTION_NO_GC_SECTIONS
:
968 link_info
.gc_sections
= FALSE
;
970 case OPTION_NO_PRINT_GC_SECTIONS
:
971 link_info
.print_gc_sections
= FALSE
;
973 case OPTION_NO_KEEP_MEMORY
:
974 link_info
.keep_memory
= FALSE
;
976 case OPTION_NO_UNDEFINED
:
977 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
979 case OPTION_ALLOW_SHLIB_UNDEFINED
:
980 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
982 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
983 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
985 case OPTION_UNRESOLVED_SYMBOLS
:
986 if (strcmp (optarg
, "ignore-all") == 0)
988 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
989 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
991 else if (strcmp (optarg
, "report-all") == 0)
993 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
994 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
996 else if (strcmp (optarg
, "ignore-in-object-files") == 0)
998 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
999 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1001 else if (strcmp (optarg
, "ignore-in-shared-libs") == 0)
1003 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1004 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1007 einfo (_("%F%P: bad --unresolved-symbols option: %s\n"), optarg
);
1009 case OPTION_WARN_UNRESOLVED_SYMBOLS
:
1010 link_info
.warn_unresolved_syms
= TRUE
;
1012 case OPTION_ERROR_UNRESOLVED_SYMBOLS
:
1013 link_info
.warn_unresolved_syms
= FALSE
;
1015 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
1016 link_info
.allow_multiple_definition
= TRUE
;
1018 case OPTION_NO_UNDEFINED_VERSION
:
1019 link_info
.allow_undefined_version
= FALSE
;
1021 case OPTION_DEFAULT_SYMVER
:
1022 link_info
.create_default_symver
= TRUE
;
1024 case OPTION_DEFAULT_IMPORTED_SYMVER
:
1025 link_info
.default_imported_symver
= TRUE
;
1027 case OPTION_NO_WARN_MISMATCH
:
1028 command_line
.warn_mismatch
= FALSE
;
1030 case OPTION_NO_WARN_SEARCH_MISMATCH
:
1031 command_line
.warn_search_mismatch
= FALSE
;
1033 case OPTION_NOINHIBIT_EXEC
:
1034 force_make_executable
= TRUE
;
1036 case OPTION_NOSTDLIB
:
1037 config
.only_cmd_line_lib_dirs
= TRUE
;
1039 case OPTION_NO_WHOLE_ARCHIVE
:
1040 input_flags
.whole_archive
= FALSE
;
1043 /* FIXME "-O<non-digits> <value>" used to set the address of
1044 section <non-digits>. Was this for compatibility with
1045 something, or can we create a new option to do that
1046 (with a syntax similar to -defsym)?
1047 getopt can't handle two args to an option without kludges. */
1049 /* Enable optimizations of output files. */
1050 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
1053 lang_add_output (optarg
, 0);
1055 case OPTION_OFORMAT
:
1056 lang_add_output_format (optarg
, NULL
, NULL
, 0);
1058 case OPTION_OUT_IMPLIB
:
1059 command_line
.out_implib_filename
= xstrdup (optarg
);
1061 case OPTION_PRINT_SYSROOT
:
1066 case OPTION_PRINT_OUTPUT_FORMAT
:
1067 command_line
.print_output_format
= TRUE
;
1069 #ifdef ENABLE_PLUGINS
1071 plugin_opt_plugin (optarg
);
1073 case OPTION_PLUGIN_OPT
:
1074 if (plugin_opt_plugin_arg (optarg
))
1075 einfo (_("%F%P: bad -plugin-opt option\n"));
1077 #endif /* ENABLE_PLUGINS */
1079 link_info
.emitrelocations
= TRUE
;
1083 if (optind
== last_optind
)
1084 /* This can happen if the user put "-rpath,a" on the command
1085 line. (Or something similar. The comma is important).
1086 Getopt becomes confused and thinks that this is a -r option
1087 but it cannot parse the text after the -r so it refuses to
1088 increment the optind counter. Detect this case and issue
1089 an error message here. We cannot just make this a warning,
1090 increment optind, and continue because getopt is too confused
1091 and will seg-fault the next time around. */
1092 einfo(_("%F%P: unrecognised option: %s\n"), argv
[optind
]);
1094 if (bfd_link_pic (&link_info
))
1095 einfo (_("%F%P: -r and %s may not be used together\n"),
1096 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1098 link_info
.type
= type_relocatable
;
1099 config
.build_constructors
= FALSE
;
1100 config
.magic_demand_paged
= FALSE
;
1101 config
.text_read_only
= FALSE
;
1102 input_flags
.dynamic
= FALSE
;
1105 /* The GNU linker traditionally uses -R to mean to include
1106 only the symbols from a file. The Solaris linker uses -R
1107 to set the path used by the runtime linker to find
1108 libraries. This is the GNU linker -rpath argument. We
1109 try to support both simultaneously by checking the file
1110 named. If it is a directory, rather than a regular file,
1111 we assume -rpath was meant. */
1115 if (stat (optarg
, &s
) >= 0
1116 && ! S_ISDIR (s
.st_mode
))
1118 lang_add_input_file (optarg
,
1119 lang_input_file_is_symbols_only_enum
,
1126 if (command_line
.rpath
== NULL
)
1127 command_line
.rpath
= xstrdup (optarg
);
1130 size_t rpath_len
= strlen (command_line
.rpath
);
1131 size_t optarg_len
= strlen (optarg
);
1133 char *cp
= command_line
.rpath
;
1135 /* First see whether OPTARG is already in the path. */
1138 if (strncmp (optarg
, cp
, optarg_len
) == 0
1139 && (cp
[optarg_len
] == 0
1140 || cp
[optarg_len
] == config
.rpath_separator
))
1144 /* Not yet found. */
1145 cp
= strchr (cp
, config
.rpath_separator
);
1153 buf
= (char *) xmalloc (rpath_len
+ optarg_len
+ 2);
1154 sprintf (buf
, "%s%c%s", command_line
.rpath
,
1155 config
.rpath_separator
, optarg
);
1156 free (command_line
.rpath
);
1157 command_line
.rpath
= buf
;
1161 case OPTION_RPATH_LINK
:
1162 if (command_line
.rpath_link
== NULL
)
1163 command_line
.rpath_link
= xstrdup (optarg
);
1168 buf
= (char *) xmalloc (strlen (command_line
.rpath_link
)
1171 sprintf (buf
, "%s%c%s", command_line
.rpath_link
,
1172 config
.rpath_separator
, optarg
);
1173 free (command_line
.rpath_link
);
1174 command_line
.rpath_link
= buf
;
1177 case OPTION_NO_RELAX
:
1183 case OPTION_RETAIN_SYMBOLS_FILE
:
1184 add_keepsyms_file (optarg
);
1187 link_info
.strip
= strip_debugger
;
1190 link_info
.strip
= strip_all
;
1192 case OPTION_STRIP_DISCARDED
:
1193 link_info
.strip_discarded
= TRUE
;
1195 case OPTION_NO_STRIP_DISCARDED
:
1196 link_info
.strip_discarded
= FALSE
;
1198 case OPTION_DISABLE_MULTIPLE_DEFS_ABS
:
1199 link_info
.prohibit_multiple_definition_absolute
= TRUE
;
1202 if (config
.has_shared
)
1204 if (bfd_link_relocatable (&link_info
))
1205 einfo (_("%F%P: -r and %s may not be used together\n"),
1208 link_info
.type
= type_dll
;
1209 /* When creating a shared library, the default
1210 behaviour is to ignore any unresolved references. */
1211 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1212 link_info
.unresolved_syms_in_objects
= RM_IGNORE
;
1213 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1214 link_info
.unresolved_syms_in_shared_libs
= RM_IGNORE
;
1217 einfo (_("%F%P: -shared not supported\n"));
1220 if (config
.has_shared
)
1222 if (bfd_link_relocatable (&link_info
))
1223 einfo (_("%F%P: -r and %s may not be used together\n"), "-pie");
1225 link_info
.type
= type_pie
;
1228 einfo (_("%F%P: -pie not supported\n"));
1230 case 'h': /* Used on Solaris. */
1232 if (optarg
[0] == '\0' && command_line
.soname
1233 && command_line
.soname
[0])
1234 einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
1236 command_line
.soname
= optarg
;
1238 case OPTION_SORT_COMMON
:
1240 || strcmp (optarg
, N_("descending")) == 0)
1241 config
.sort_common
= sort_descending
;
1242 else if (strcmp (optarg
, N_("ascending")) == 0)
1243 config
.sort_common
= sort_ascending
;
1245 einfo (_("%F%P: invalid common section sorting option: %s\n"),
1248 case OPTION_SORT_SECTION
:
1249 if (strcmp (optarg
, N_("name")) == 0)
1250 sort_section
= by_name
;
1251 else if (strcmp (optarg
, N_("alignment")) == 0)
1252 sort_section
= by_alignment
;
1254 einfo (_("%F%P: invalid section sorting option: %s\n"),
1258 config
.stats
= TRUE
;
1260 case OPTION_SYMBOLIC
:
1261 opt_symbolic
= symbolic
;
1263 case OPTION_SYMBOLIC_FUNCTIONS
:
1264 opt_symbolic
= symbolic_functions
;
1270 previous_script_handle
= saved_script_handle
;
1271 ldfile_open_script_file (optarg
);
1272 parser_input
= input_script
;
1274 previous_script_handle
= NULL
;
1276 case OPTION_DEFAULT_SCRIPT
:
1277 command_line
.default_script
= optarg
;
1279 case OPTION_SECTION_START
:
1285 /* Check for <something>=<somthing>... */
1286 optarg2
= strchr (optarg
, '=');
1287 if (optarg2
== NULL
)
1288 einfo (_("%F%P: invalid argument to option"
1289 " \"--section-start\"\n"));
1293 /* So far so good. Are all the args present? */
1294 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1295 einfo (_("%F%P: missing argument(s) to option"
1296 " \"--section-start\"\n"));
1298 /* We must copy the section name as set_section_start
1299 doesn't do it for us. */
1300 len
= optarg2
- optarg
;
1301 sec_name
= (char *) xmalloc (len
);
1302 memcpy (sec_name
, optarg
, len
- 1);
1303 sec_name
[len
- 1] = 0;
1305 /* Then set it... */
1306 set_section_start (sec_name
, optarg2
);
1309 case OPTION_TARGET_HELP
:
1310 /* Mention any target specific options. */
1311 ldemul_list_emulation_options (stdout
);
1314 set_segment_start (".bss", optarg
);
1317 set_segment_start (".data", optarg
);
1320 set_segment_start (".text", optarg
);
1322 case OPTION_TTEXT_SEGMENT
:
1323 set_segment_start (".text-segment", optarg
);
1325 case OPTION_TRODATA_SEGMENT
:
1326 set_segment_start (".rodata-segment", optarg
);
1328 case OPTION_TLDATA_SEGMENT
:
1329 set_segment_start (".ldata-segment", optarg
);
1331 case OPTION_TRADITIONAL_FORMAT
:
1332 link_info
.traditional_format
= TRUE
;
1334 case OPTION_TASK_LINK
:
1335 link_info
.task_link
= TRUE
;
1338 if (bfd_link_pic (&link_info
))
1339 einfo (_("%F%P: -r and %s may not be used together\n"),
1340 bfd_link_dll (&link_info
) ? "-shared" : "-pie");
1342 link_info
.type
= type_relocatable
;
1343 config
.build_constructors
= TRUE
;
1344 config
.magic_demand_paged
= FALSE
;
1345 config
.text_read_only
= FALSE
;
1346 input_flags
.dynamic
= FALSE
;
1349 ldlang_add_undef (optarg
, TRUE
);
1351 case OPTION_REQUIRE_DEFINED_SYMBOL
:
1352 ldlang_add_require_defined (optarg
);
1356 lang_add_unique (optarg
);
1358 config
.unique_orphan_sections
= TRUE
;
1360 case OPTION_VERBOSE
:
1362 version_printed
= TRUE
;
1364 overflow_cutoff_limit
= -2;
1368 int level ATTRIBUTE_UNUSED
= strtoul (optarg
, &end
, 0);
1370 einfo (_("%F%P: invalid number `%s'\n"), optarg
);
1371 #ifdef ENABLE_PLUGINS
1372 report_plugin_symbols
= level
> 1;
1373 #endif /* ENABLE_PLUGINS */
1378 version_printed
= TRUE
;
1382 version_printed
= TRUE
;
1384 case OPTION_VERSION
:
1388 case OPTION_VERSION_SCRIPT
:
1389 /* This option indicates a small script that only specifies
1390 version information. Read it, but don't assume that
1391 we've seen a linker script. */
1393 FILE *hold_script_handle
;
1395 hold_script_handle
= saved_script_handle
;
1396 ldfile_open_command_file (optarg
);
1397 saved_script_handle
= hold_script_handle
;
1398 parser_input
= input_version_script
;
1402 case OPTION_VERSION_EXPORTS_SECTION
:
1403 /* This option records a version symbol to be applied to the
1404 symbols listed for export to be found in the object files
1405 .exports sections. */
1406 command_line
.version_exports_section
= optarg
;
1408 case OPTION_DYNAMIC_LIST_DATA
:
1409 opt_dynamic_list
= dynamic_list_data
;
1411 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO
:
1412 lang_append_dynamic_list_cpp_typeinfo ();
1413 if (opt_dynamic_list
!= dynamic_list_data
)
1414 opt_dynamic_list
= dynamic_list
;
1416 case OPTION_DYNAMIC_LIST_CPP_NEW
:
1417 lang_append_dynamic_list_cpp_new ();
1418 if (opt_dynamic_list
!= dynamic_list_data
)
1419 opt_dynamic_list
= dynamic_list
;
1421 case OPTION_DYNAMIC_LIST
:
1422 /* This option indicates a small script that only specifies
1423 a dynamic list. Read it, but don't assume that we've
1424 seen a linker script. */
1426 FILE *hold_script_handle
;
1428 hold_script_handle
= saved_script_handle
;
1429 ldfile_open_command_file (optarg
);
1430 saved_script_handle
= hold_script_handle
;
1431 parser_input
= input_dynamic_list
;
1432 current_dynamic_list_p
= &link_info
.dynamic_list
;
1435 if (opt_dynamic_list
!= dynamic_list_data
)
1436 opt_dynamic_list
= dynamic_list
;
1438 case OPTION_EXPORT_DYNAMIC_SYMBOL
:
1440 struct bfd_elf_version_expr
*expr
1441 = lang_new_vers_pattern (NULL
, xstrdup (optarg
), NULL
,
1443 lang_append_dynamic_list (&export_list
, expr
);
1446 case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST
:
1447 /* This option indicates a small script that only specifies
1448 an export list. Read it, but don't assume that we've
1449 seen a linker script. */
1451 FILE *hold_script_handle
;
1453 hold_script_handle
= saved_script_handle
;
1454 ldfile_open_command_file (optarg
);
1455 saved_script_handle
= hold_script_handle
;
1456 parser_input
= input_dynamic_list
;
1457 current_dynamic_list_p
= &export_list
;
1461 case OPTION_WARN_COMMON
:
1462 config
.warn_common
= TRUE
;
1464 case OPTION_WARN_CONSTRUCTORS
:
1465 config
.warn_constructors
= TRUE
;
1467 case OPTION_WARN_FATAL
:
1468 config
.fatal_warnings
= TRUE
;
1470 case OPTION_NO_WARN_FATAL
:
1471 config
.fatal_warnings
= FALSE
;
1473 case OPTION_WARN_MULTIPLE_GP
:
1474 config
.warn_multiple_gp
= TRUE
;
1476 case OPTION_WARN_ONCE
:
1477 config
.warn_once
= TRUE
;
1479 case OPTION_WARN_SECTION_ALIGN
:
1480 config
.warn_section_align
= TRUE
;
1482 case OPTION_WARN_TEXTREL
:
1483 link_info
.textrel_check
= textrel_check_warning
;
1485 case OPTION_WARN_ALTERNATE_EM
:
1486 link_info
.warn_alternate_em
= TRUE
;
1488 case OPTION_WHOLE_ARCHIVE
:
1489 input_flags
.whole_archive
= TRUE
;
1491 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC
:
1492 input_flags
.add_DT_NEEDED_for_dynamic
= TRUE
;
1494 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC
:
1495 input_flags
.add_DT_NEEDED_for_dynamic
= FALSE
;
1497 case OPTION_ADD_DT_NEEDED_FOR_REGULAR
:
1498 input_flags
.add_DT_NEEDED_for_regular
= TRUE
;
1500 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR
:
1501 input_flags
.add_DT_NEEDED_for_regular
= FALSE
;
1506 case OPTION_IGNORE_UNRESOLVED_SYMBOL
:
1507 add_ignoresym (&link_info
, optarg
);
1509 case OPTION_DISCARD_NONE
:
1510 link_info
.discard
= discard_none
;
1513 link_info
.discard
= discard_l
;
1516 link_info
.discard
= discard_all
;
1519 if (CONST_STRNEQ (optarg
, "P,"))
1521 free (default_dirlist
);
1522 default_dirlist
= xstrdup (optarg
);
1527 case OPTION_SPARE_DYNAMIC_TAGS
:
1528 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1530 case OPTION_SPLIT_BY_RELOC
:
1532 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1534 config
.split_by_reloc
= 32768;
1536 case OPTION_SPLIT_BY_FILE
:
1538 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1540 config
.split_by_file
= 1;
1542 case OPTION_CHECK_SECTIONS
:
1543 command_line
.check_section_addresses
= 1;
1545 case OPTION_NO_CHECK_SECTIONS
:
1546 command_line
.check_section_addresses
= 0;
1548 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1549 command_line
.accept_unknown_input_arch
= TRUE
;
1551 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1552 command_line
.accept_unknown_input_arch
= FALSE
;
1555 lang_enter_group ();
1560 einfo (_("%F%P: group ended before it began (--help for usage)\n"));
1562 lang_leave_group ();
1567 link_info
.init_function
= optarg
;
1571 link_info
.fini_function
= optarg
;
1574 case OPTION_REDUCE_MEMORY_OVERHEADS
:
1575 link_info
.reduce_memory_overheads
= TRUE
;
1576 if (config
.hash_table_size
== 0)
1577 config
.hash_table_size
= 1021;
1580 case OPTION_HASH_SIZE
:
1582 bfd_size_type new_size
;
1584 new_size
= strtoul (optarg
, NULL
, 0);
1586 config
.hash_table_size
= new_size
;
1588 einfo (_("%X%P: --hash-size needs a numeric argument\n"));
1592 case OPTION_PUSH_STATE
:
1593 input_flags
.pushed
= xmemdup (&input_flags
,
1594 sizeof (input_flags
),
1595 sizeof (input_flags
));
1598 case OPTION_POP_STATE
:
1599 if (input_flags
.pushed
== NULL
)
1600 einfo (_("%F%P: no state pushed before popping\n"));
1603 struct lang_input_statement_flags
*oldp
= input_flags
.pushed
;
1604 memcpy (&input_flags
, oldp
, sizeof (input_flags
));
1609 case OPTION_PRINT_MEMORY_USAGE
:
1610 command_line
.print_memory_usage
= TRUE
;
1613 case OPTION_ORPHAN_HANDLING
:
1614 if (strcasecmp (optarg
, "place") == 0)
1615 config
.orphan_handling
= orphan_handling_place
;
1616 else if (strcasecmp (optarg
, "warn") == 0)
1617 config
.orphan_handling
= orphan_handling_warn
;
1618 else if (strcasecmp (optarg
, "error") == 0)
1619 config
.orphan_handling
= orphan_handling_error
;
1620 else if (strcasecmp (optarg
, "discard") == 0)
1621 config
.orphan_handling
= orphan_handling_discard
;
1623 einfo (_("%F%P: invalid argument to option"
1624 " \"--orphan-handling\"\n"));
1627 case OPTION_NO_PRINT_MAP_DISCARDED
:
1628 config
.print_map_discarded
= FALSE
;
1631 case OPTION_PRINT_MAP_DISCARDED
:
1632 config
.print_map_discarded
= TRUE
;
1637 /* Run a couple of checks on the map filename. */
1638 if (config
.map_filename
)
1640 if (config
.map_filename
[0] == 0)
1642 einfo (_("%P: no file/directory name provided for map output; ignored\n"));
1643 config
.map_filename
= NULL
;
1649 /* If the map filename is actually a directory then create
1650 a file inside it, based upon the output filename. */
1651 if (stat (config
.map_filename
, &s
) >= 0
1652 && S_ISDIR (s
.st_mode
))
1656 /* FIXME: This is a (trivial) memory leak. */
1657 if (asprintf (&new_name
, "%s/%s.map",
1658 config
.map_filename
, output_filename
) < 0)
1660 /* If this alloc fails then something is probably very
1661 wrong. Better to halt now rather than continue on
1662 into more problems. */
1663 einfo (_("%P%F: cannot create name for linker map file: %E\n"));
1667 config
.map_filename
= new_name
;
1672 if (command_line
.soname
&& command_line
.soname
[0] == '\0')
1674 einfo (_("%P: SONAME must not be empty string; ignored\n"));
1675 command_line
.soname
= NULL
;
1680 einfo (_("%P: missing --end-group; added as last command line option\n"));
1681 lang_leave_group ();
1685 if (default_dirlist
!= NULL
)
1687 set_default_dirlist (default_dirlist
);
1688 free (default_dirlist
);
1691 if (link_info
.unresolved_syms_in_objects
== RM_NOT_YET_SET
)
1692 /* FIXME: Should we allow emulations a chance to set this ? */
1693 link_info
.unresolved_syms_in_objects
= RM_DIAGNOSE
;
1695 if (link_info
.unresolved_syms_in_shared_libs
== RM_NOT_YET_SET
)
1696 /* FIXME: Should we allow emulations a chance to set this ? */
1697 link_info
.unresolved_syms_in_shared_libs
= RM_DIAGNOSE
;
1699 if (bfd_link_relocatable (&link_info
)
1700 && command_line
.check_section_addresses
< 0)
1701 command_line
.check_section_addresses
= 0;
1705 struct bfd_elf_version_expr
*head
= export_list
->head
.list
;
1706 struct bfd_elf_version_expr
*next
;
1708 /* For --export-dynamic-symbol[-list]:
1709 1. When building executable, treat like --dynamic-list.
1710 2. When building shared object:
1711 a. If -Bsymbolic or --dynamic-list are used, treat like
1713 b. Otherwise, ignored.
1715 if (!bfd_link_relocatable (&link_info
)
1716 && (bfd_link_executable (&link_info
)
1717 || opt_symbolic
!= symbolic_unset
1718 || opt_dynamic_list
!= dynamic_list_unset
))
1720 /* Append the export list to link_info.dynamic_list. */
1721 if (link_info
.dynamic_list
)
1723 for (next
= head
; next
->next
!= NULL
; next
= next
->next
)
1725 next
->next
= link_info
.dynamic_list
->head
.list
;
1726 link_info
.dynamic_list
->head
.list
= head
;
1729 link_info
.dynamic_list
= export_list
;
1731 if (opt_dynamic_list
!= dynamic_list_data
)
1732 opt_dynamic_list
= dynamic_list
;
1736 /* Free the export list. */
1737 for (; head
->next
!= NULL
; head
= next
)
1746 switch (opt_dynamic_list
)
1748 case dynamic_list_unset
:
1750 case dynamic_list_data
:
1751 link_info
.dynamic_data
= TRUE
;
1754 link_info
.dynamic
= TRUE
;
1755 opt_symbolic
= symbolic_unset
;
1759 /* -Bsymbolic and -Bsymbols-functions are for shared library output. */
1760 if (bfd_link_dll (&link_info
))
1761 switch (opt_symbolic
)
1763 case symbolic_unset
:
1766 link_info
.symbolic
= TRUE
;
1767 if (link_info
.dynamic_list
)
1769 struct bfd_elf_version_expr
*ent
, *next
;
1770 for (ent
= link_info
.dynamic_list
->head
.list
; ent
; ent
= next
)
1775 free (link_info
.dynamic_list
);
1776 link_info
.dynamic_list
= NULL
;
1779 case symbolic_functions
:
1780 link_info
.dynamic
= TRUE
;
1781 link_info
.dynamic_data
= TRUE
;
1785 if (!bfd_link_dll (&link_info
))
1787 if (command_line
.filter_shlib
)
1788 einfo (_("%F%P: -F may not be used without -shared\n"));
1789 if (command_line
.auxiliary_filters
)
1790 einfo (_("%F%P: -f may not be used without -shared\n"));
1793 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
1794 don't see how else this can be handled, since in this case we
1795 must preserve all externally visible symbols. */
1796 if (bfd_link_relocatable (&link_info
) && link_info
.strip
== strip_all
)
1798 link_info
.strip
= strip_debugger
;
1799 if (link_info
.discard
== discard_sec_merge
)
1800 link_info
.discard
= discard_all
;
1804 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1805 library search path. */
1808 set_default_dirlist (char *dirlist_ptr
)
1814 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1817 if (*dirlist_ptr
!= '\0')
1818 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1821 dirlist_ptr
= p
+ 1;
1826 set_section_start (char *sect
, char *valstr
)
1829 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1831 einfo (_("%F%P: invalid hex number `%s'\n"), valstr
);
1832 lang_section_start (sect
, exp_intop (val
), NULL
);
1836 set_segment_start (const char *section
, char *valstr
)
1842 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1844 einfo (_("%F%P: invalid hex number `%s'\n"), valstr
);
1845 /* If we already have an entry for this segment, update the existing
1848 for (seg
= segments
; seg
; seg
= seg
->next
)
1849 if (strcmp (seg
->name
, name
) == 0)
1852 lang_section_start (section
, exp_intop (val
), seg
);
1855 /* There was no existing value so we must create a new segment
1857 seg
= stat_alloc (sizeof (*seg
));
1861 /* Add it to the linked list of segments. */
1862 seg
->next
= segments
;
1864 /* Historically, -Ttext and friends set the base address of a
1865 particular section. For backwards compatibility, we still do
1866 that. If a SEGMENT_START directive is seen, the section address
1867 assignment will be disabled. */
1868 lang_section_start (section
, exp_intop (val
), seg
);
1872 elf_shlib_list_options (FILE *file
)
1875 --audit=AUDITLIB Specify a library to use for auditing\n"));
1877 -Bgroup Selects group name lookup rules for DSO\n"));
1879 --disable-new-dtags Disable new dynamic tags\n"));
1881 --enable-new-dtags Enable new dynamic tags\n"));
1883 --eh-frame-hdr Create .eh_frame_hdr section\n"));
1885 --no-eh-frame-hdr Do not create .eh_frame_hdr section\n"));
1887 --exclude-libs=LIBS Make all symbols in LIBS hidden\n"));
1889 --hash-style=STYLE Set hash style to sysv/gnu/both. Default: "));
1890 if (DEFAULT_EMIT_SYSV_HASH
)
1892 /* Note - these strings are not translated as
1893 they are keywords not descriptive text. */
1894 if (DEFAULT_EMIT_GNU_HASH
)
1895 fprintf (file
, "both\n");
1897 fprintf (file
, "sysv\n");
1901 if (DEFAULT_EMIT_GNU_HASH
)
1902 fprintf (file
, "gnu\n");
1904 /* FIXME: Can this happen ? */
1905 fprintf (file
, "none\n");
1908 -P AUDITLIB, --depaudit=AUDITLIB\n" "\
1909 Specify a library to use for auditing dependencies\n"));
1911 -z combreloc Merge dynamic relocs into one section and sort\n"));
1913 -z nocombreloc Don't merge dynamic relocs into one section\n"));
1915 -z global Make symbols in DSO available for subsequently\n\
1916 loaded objects\n"));
1918 -z initfirst Mark DSO to be initialized first at runtime\n"));
1920 -z interpose Mark object to interpose all DSOs but executable\n"));
1922 -z lazy Mark object lazy runtime binding (default)\n"));
1924 -z loadfltr Mark object requiring immediate process\n"));
1926 -z nocopyreloc Don't create copy relocs\n"));
1928 -z nodefaultlib Mark object not to use default search paths\n"));
1930 -z nodelete Mark DSO non-deletable at runtime\n"));
1932 -z nodlopen Mark DSO not available to dlopen\n"));
1934 -z nodump Mark DSO not available to dldump\n"));
1936 -z now Mark object non-lazy runtime binding\n"));
1938 -z origin Mark object requiring immediate $ORIGIN\n\
1939 processing at runtime\n"));
1940 #if DEFAULT_LD_Z_RELRO
1942 -z relro Create RELRO program header (default)\n"));
1944 -z norelro Don't create RELRO program header\n"));
1947 -z relro Create RELRO program header\n"));
1949 -z norelro Don't create RELRO program header (default)\n"));
1951 #if DEFAULT_LD_Z_SEPARATE_CODE
1953 -z separate-code Create separate code program header (default)\n"));
1955 -z noseparate-code Don't create separate code program header\n"));
1958 -z separate-code Create separate code program header\n"));
1960 -z noseparate-code Don't create separate code program header (default)\n"));
1963 -z common Generate common symbols with STT_COMMON type\n"));
1965 -z nocommon Generate common symbols with STT_OBJECT type\n"));
1967 -z stack-size=SIZE Set size of stack segment\n"));
1968 if (link_info
.textrel_check
== textrel_check_error
)
1970 -z text Treat DT_TEXTREL in output as error (default)\n"));
1973 -z text Treat DT_TEXTREL in output as error\n"));
1974 if (link_info
.textrel_check
== textrel_check_none
)
1977 -z notext Don't treat DT_TEXTREL in output as error (default)\n"));
1979 -z textoff Don't treat DT_TEXTREL in output as error (default)\n"));
1984 -z notext Don't treat DT_TEXTREL in output as error\n"));
1986 -z textoff Don't treat DT_TEXTREL in output as error\n"));
1991 elf_static_list_options (FILE *file
)
1994 --build-id[=STYLE] Generate build ID note\n"));
1996 --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]\n\
1997 Compress DWARF debug sections using zlib\n"));
1998 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
2000 Default: zlib-gabi\n"));
2006 -z common-page-size=SIZE Set common page size to SIZE\n"));
2008 -z max-page-size=SIZE Set maximum page size to SIZE\n"));
2010 -z defs Report unresolved symbols in object files\n"));
2012 -z muldefs Allow multiple definitions\n"));
2014 -z execstack Mark executable as requiring executable stack\n"));
2016 -z noexecstack Mark executable as not requiring executable stack\n"));
2018 -z globalaudit Mark executable requiring global auditing\n"));
2022 elf_plt_unwind_list_options (FILE *file
)
2025 --ld-generated-unwind-info Generate exception handling info for PLT\n"));
2027 --no-ld-generated-unwind-info\n\
2028 Don't generate exception handling info for PLT\n"));
2032 ld_list_options (FILE *file
, bfd_boolean elf
, bfd_boolean shlib
,
2033 bfd_boolean plt_unwind
)
2037 printf (_("ELF emulations:\n"));
2039 elf_plt_unwind_list_options (file
);
2040 elf_static_list_options (file
);
2042 elf_shlib_list_options (file
);
2046 /* Print help messages for the options. */
2052 const char **targets
, **pp
;
2055 printf (_("Usage: %s [options] file...\n"), program_name
);
2057 printf (_("Options:\n"));
2058 for (i
= 0; i
< OPTION_COUNT
; i
++)
2060 if (ld_options
[i
].doc
!= NULL
)
2073 if (ld_options
[j
].shortopt
!= '\0'
2074 && ld_options
[j
].control
!= NO_HELP
)
2076 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
2077 len
+= (comma
? 2 : 0) + 2;
2078 if (ld_options
[j
].arg
!= NULL
)
2080 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
2085 printf ("%s", _(ld_options
[j
].arg
));
2086 len
+= strlen (_(ld_options
[j
].arg
));
2092 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
2097 if (ld_options
[j
].opt
.name
!= NULL
2098 && ld_options
[j
].control
!= NO_HELP
)
2101 (ld_options
[j
].control
== TWO_DASHES
2102 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
2106 two_dashes
? "-" : "",
2107 ld_options
[j
].opt
.name
);
2108 len
+= ((comma
? 2 : 0)
2110 + (two_dashes
? 1 : 0)
2111 + strlen (ld_options
[j
].opt
.name
));
2112 if (ld_options
[j
].arg
!= NULL
)
2114 printf (" %s", _(ld_options
[j
].arg
));
2115 len
+= 1 + strlen (_(ld_options
[j
].arg
));
2121 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
2129 for (; len
< 30; len
++)
2132 printf ("%s\n", _(ld_options
[i
].doc
));
2135 printf (_(" @FILE"));
2136 for (len
= strlen (" @FILE"); len
< 30; len
++)
2138 printf (_("Read options from FILE\n"));
2140 /* Note: Various tools (such as libtool) depend upon the
2141 format of the listings below - do not change them. */
2142 /* xgettext:c-format */
2143 printf (_("%s: supported targets:"), program_name
);
2144 targets
= bfd_target_list ();
2145 for (pp
= targets
; *pp
!= NULL
; pp
++)
2146 printf (" %s", *pp
);
2150 /* xgettext:c-format */
2151 printf (_("%s: supported emulations: "), program_name
);
2152 ldemul_list_emulations (stdout
);
2155 /* xgettext:c-format */
2156 printf (_("%s: emulation specific options:\n"), program_name
);
2157 ld_list_options (stdout
, ELF_LIST_OPTIONS
, ELF_SHLIB_LIST_OPTIONS
,
2158 ELF_PLT_UNWIND_LIST_OPTIONS
);
2159 ldemul_list_emulation_options (stdout
);
2162 if (REPORT_BUGS_TO
[0])
2163 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);