1 /* Parse options for the GNU linker.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 Free Software Foundation, Inc.
6 This file is part of GLD, the Gnu Linker.
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include "libiberty.h"
28 #include "safe-ctype.h"
43 #ifndef PATH_SEPARATOR
44 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
45 #define PATH_SEPARATOR ';'
47 #define PATH_SEPARATOR ':'
51 /* Somewhere above, sys/stat.h got included . . . . */
52 #if !defined(S_ISDIR) && defined(S_IFDIR)
53 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
56 static int is_num
PARAMS ((const char *, int, int, int));
57 static void set_default_dirlist
PARAMS ((char *));
58 static void set_section_start
PARAMS ((char *, char *));
59 static void help
PARAMS ((void));
61 /* Non-zero if we are processing a --defsym from the command line. */
62 int parsing_defsym
= 0;
64 /* Codes used for the long options with no short synonyms. 150 isn't
65 special; it's just an arbitrary non-ASCII char value. */
67 #define OPTION_ASSERT 150
68 #define OPTION_CALL_SHARED (OPTION_ASSERT + 1)
69 #define OPTION_CREF (OPTION_CALL_SHARED + 1)
70 #define OPTION_DEFSYM (OPTION_CREF + 1)
71 #define OPTION_DEMANGLE (OPTION_DEFSYM + 1)
72 #define OPTION_DYNAMIC_LINKER (OPTION_DEMANGLE + 1)
73 #define OPTION_EB (OPTION_DYNAMIC_LINKER + 1)
74 #define OPTION_EL (OPTION_EB + 1)
75 #define OPTION_EMBEDDED_RELOCS (OPTION_EL + 1)
76 #define OPTION_EXPORT_DYNAMIC (OPTION_EMBEDDED_RELOCS + 1)
77 #define OPTION_HELP (OPTION_EXPORT_DYNAMIC + 1)
78 #define OPTION_IGNORE (OPTION_HELP + 1)
79 #define OPTION_MAP (OPTION_IGNORE + 1)
80 #define OPTION_NO_DEMANGLE (OPTION_MAP + 1)
81 #define OPTION_NO_KEEP_MEMORY (OPTION_NO_DEMANGLE + 1)
82 #define OPTION_NO_WARN_MISMATCH (OPTION_NO_KEEP_MEMORY + 1)
83 #define OPTION_NOINHIBIT_EXEC (OPTION_NO_WARN_MISMATCH + 1)
84 #define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1)
85 #define OPTION_NO_WHOLE_ARCHIVE (OPTION_NON_SHARED + 1)
86 #define OPTION_OFORMAT (OPTION_NO_WHOLE_ARCHIVE + 1)
87 #define OPTION_RELAX (OPTION_OFORMAT + 1)
88 #define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1)
89 #define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1)
90 #define OPTION_RPATH_LINK (OPTION_RPATH + 1)
91 #define OPTION_SHARED (OPTION_RPATH_LINK + 1)
92 #define OPTION_SONAME (OPTION_SHARED + 1)
93 #define OPTION_SORT_COMMON (OPTION_SONAME + 1)
94 #define OPTION_STATS (OPTION_SORT_COMMON + 1)
95 #define OPTION_SYMBOLIC (OPTION_STATS + 1)
96 #define OPTION_TASK_LINK (OPTION_SYMBOLIC + 1)
97 #define OPTION_TBSS (OPTION_TASK_LINK + 1)
98 #define OPTION_TDATA (OPTION_TBSS + 1)
99 #define OPTION_TTEXT (OPTION_TDATA + 1)
100 #define OPTION_TRADITIONAL_FORMAT (OPTION_TTEXT + 1)
101 #define OPTION_UR (OPTION_TRADITIONAL_FORMAT + 1)
102 #define OPTION_VERBOSE (OPTION_UR + 1)
103 #define OPTION_VERSION (OPTION_VERBOSE + 1)
104 #define OPTION_VERSION_SCRIPT (OPTION_VERSION + 1)
105 #define OPTION_VERSION_EXPORTS_SECTION (OPTION_VERSION_SCRIPT + 1)
106 #define OPTION_WARN_COMMON (OPTION_VERSION_EXPORTS_SECTION + 1)
107 #define OPTION_WARN_CONSTRUCTORS (OPTION_WARN_COMMON + 1)
108 #define OPTION_WARN_FATAL (OPTION_WARN_CONSTRUCTORS + 1)
109 #define OPTION_WARN_MULTIPLE_GP (OPTION_WARN_FATAL + 1)
110 #define OPTION_WARN_ONCE (OPTION_WARN_MULTIPLE_GP + 1)
111 #define OPTION_WARN_SECTION_ALIGN (OPTION_WARN_ONCE + 1)
112 #define OPTION_SPLIT_BY_RELOC (OPTION_WARN_SECTION_ALIGN + 1)
113 #define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1)
114 #define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
115 #define OPTION_WRAP (OPTION_WHOLE_ARCHIVE + 1)
116 #define OPTION_FORCE_EXE_SUFFIX (OPTION_WRAP + 1)
117 #define OPTION_GC_SECTIONS (OPTION_FORCE_EXE_SUFFIX + 1)
118 #define OPTION_NO_GC_SECTIONS (OPTION_GC_SECTIONS + 1)
119 #define OPTION_CHECK_SECTIONS (OPTION_NO_GC_SECTIONS + 1)
120 #define OPTION_NO_CHECK_SECTIONS (OPTION_CHECK_SECTIONS + 1)
121 #define OPTION_MPC860C0 (OPTION_NO_CHECK_SECTIONS + 1)
122 #define OPTION_NO_UNDEFINED (OPTION_MPC860C0 + 1)
123 #define OPTION_INIT (OPTION_NO_UNDEFINED + 1)
124 #define OPTION_FINI (OPTION_INIT + 1)
125 #define OPTION_SECTION_START (OPTION_FINI + 1)
126 #define OPTION_UNIQUE (OPTION_SECTION_START + 1)
127 #define OPTION_TARGET_HELP (OPTION_UNIQUE + 1)
128 #define OPTION_ALLOW_SHLIB_UNDEFINED (OPTION_TARGET_HELP + 1)
129 #define OPTION_NO_ALLOW_SHLIB_UNDEFINED (OPTION_ALLOW_SHLIB_UNDEFINED + 1)
130 #define OPTION_ALLOW_MULTIPLE_DEFINITION (OPTION_NO_ALLOW_SHLIB_UNDEFINED + 1)
131 #define OPTION_NO_UNDEFINED_VERSION (OPTION_ALLOW_MULTIPLE_DEFINITION + 1)
132 #define OPTION_DISCARD_NONE (OPTION_NO_UNDEFINED_VERSION + 1)
133 #define OPTION_SPARE_DYNAMIC_TAGS (OPTION_DISCARD_NONE + 1)
134 #define OPTION_NO_DEFINE_COMMON (OPTION_SPARE_DYNAMIC_TAGS + 1)
135 #define OPTION_NOSTDLIB (OPTION_NO_DEFINE_COMMON + 1)
136 #define OPTION_NO_OMAGIC (OPTION_NOSTDLIB + 1)
137 #define OPTION_STRIP_DISCARDED (OPTION_NO_OMAGIC + 1)
138 #define OPTION_NO_STRIP_DISCARDED (OPTION_STRIP_DISCARDED + 1)
139 #define OPTION_ACCEPT_UNKNOWN_INPUT_ARCH (OPTION_NO_STRIP_DISCARDED + 1)
140 #define OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH (OPTION_ACCEPT_UNKNOWN_INPUT_ARCH + 1)
141 #define OPTION_PIE (OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH + 1)
143 /* The long options. This structure is used for both the option
144 parsing and the help text. */
148 /* The long option information. */
150 /* The short option with the same meaning ('\0' if none). */
152 /* The name of the argument (NULL if none). */
154 /* The documentation string. If this is NULL, this is a synonym for
155 the previous option. */
158 /* Use one dash before long option name. */
160 /* Use two dashes before long option name. */
162 /* Only accept two dashes before the long option name.
163 This is an overloading of the use of this enum, since originally it
164 was only intended to tell the --help display function how to display
165 the long option name. This feature was added in order to resolve
166 the confusion about the -omagic command line switch. Is it setting
167 the output file name to "magic" or is it setting the NMAGIC flag on
168 the output ? It has been decided that it is setting the output file
169 name, and that if you want to set the NMAGIC flag you should use -N
172 /* Don't mention this option in --help output. */
177 static const struct ld_option ld_options
[] =
179 { {NULL
, required_argument
, NULL
, '\0'},
180 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
182 { {"architecture", required_argument
, NULL
, 'A'},
183 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES
},
184 { {"format", required_argument
, NULL
, 'b'},
185 'b', N_("TARGET"), N_("Specify target for following input files"), TWO_DASHES
},
186 { {"mri-script", required_argument
, NULL
, 'c'},
187 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES
},
188 { {"dc", no_argument
, NULL
, 'd'},
189 'd', NULL
, N_("Force common symbols to be defined"), ONE_DASH
},
190 { {"dp", no_argument
, NULL
, 'd'},
191 '\0', NULL
, NULL
, ONE_DASH
},
192 { {"entry", required_argument
, NULL
, 'e'},
193 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES
},
194 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
195 'E', NULL
, N_("Export all dynamic symbols"), TWO_DASHES
},
196 { {"EB", no_argument
, NULL
, OPTION_EB
},
197 '\0', NULL
, N_("Link big-endian objects"), ONE_DASH
},
198 { {"EL", no_argument
, NULL
, OPTION_EL
},
199 '\0', NULL
, N_("Link little-endian objects"), ONE_DASH
},
200 { {"auxiliary", required_argument
, NULL
, 'f'},
201 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
203 { {"filter", required_argument
, NULL
, 'F'},
204 'F', N_("SHLIB"), N_("Filter for shared object symbol table"), TWO_DASHES
},
205 { {NULL
, no_argument
, NULL
, '\0'},
206 'g', NULL
, N_("Ignored"), ONE_DASH
},
207 { {"gpsize", required_argument
, NULL
, 'G'},
208 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
210 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
211 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH
},
212 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
213 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"), TWO_DASHES
},
214 { {"library", required_argument
, NULL
, 'l'},
215 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES
},
216 { {"library-path", required_argument
, NULL
, 'L'},
217 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"), TWO_DASHES
},
218 { {NULL
, required_argument
, NULL
, '\0'},
219 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH
},
220 { {"print-map", no_argument
, NULL
, 'M'},
221 'M', NULL
, N_("Print map file on standard output"), TWO_DASHES
},
222 { {"nmagic", no_argument
, NULL
, 'n'},
223 'n', NULL
, N_("Do not page align data"), TWO_DASHES
},
224 { {"omagic", no_argument
, NULL
, 'N'},
225 'N', NULL
, N_("Do not page align data, do not make text readonly"),
226 EXACTLY_TWO_DASHES
},
227 { {"no-omagic", no_argument
, NULL
, OPTION_NO_OMAGIC
},
228 '\0', NULL
, N_("Page align data, make text readonly"), EXACTLY_TWO_DASHES
},
229 { {"output", required_argument
, NULL
, 'o'},
230 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES
},
231 { {NULL
, required_argument
, NULL
, '\0'},
232 'O', NULL
, N_("Optimize output file"), ONE_DASH
},
233 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
234 '\0', NULL
, N_("Ignored for SVR4 compatibility"), ONE_DASH
},
235 { {"emit-relocs", no_argument
, NULL
, 'q'},
236 'q', NULL
, "Generate relocations in final output", TWO_DASHES
},
237 { {"relocateable", no_argument
, NULL
, 'r'},
238 'r', NULL
, N_("Generate relocateable output"), TWO_DASHES
},
239 { {NULL
, no_argument
, NULL
, '\0'},
240 'i', NULL
, NULL
, ONE_DASH
},
241 { {"just-symbols", required_argument
, NULL
, 'R'},
242 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
244 { {"strip-all", no_argument
, NULL
, 's'},
245 's', NULL
, N_("Strip all symbols"), TWO_DASHES
},
246 { {"strip-debug", no_argument
, NULL
, 'S'},
247 'S', NULL
, N_("Strip debugging symbols"), TWO_DASHES
},
248 { {"strip-discarded", no_argument
, NULL
, OPTION_STRIP_DISCARDED
},
249 '\0', NULL
, N_("Strip symbols in discarded sections"), TWO_DASHES
},
250 { {"no-strip-discarded", no_argument
, NULL
, OPTION_NO_STRIP_DISCARDED
},
251 '\0', NULL
, N_("Do not strip symbols in discarded sections"), TWO_DASHES
},
252 { {"trace", no_argument
, NULL
, 't'},
253 't', NULL
, N_("Trace file opens"), TWO_DASHES
},
254 { {"script", required_argument
, NULL
, 'T'},
255 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES
},
256 { {"undefined", required_argument
, NULL
, 'u'},
257 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), TWO_DASHES
},
258 { {"unique", optional_argument
, NULL
, OPTION_UNIQUE
},
259 '\0', N_("[=SECTION]"), N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES
},
260 { {"Ur", no_argument
, NULL
, OPTION_UR
},
261 '\0', NULL
, N_("Build global constructor/destructor tables"), ONE_DASH
},
262 { {"version", no_argument
, NULL
, OPTION_VERSION
},
263 'v', NULL
, N_("Print version information"), TWO_DASHES
},
264 { {NULL
, no_argument
, NULL
, '\0'},
265 'V', NULL
, N_("Print version and emulation information"), ONE_DASH
},
266 { {"discard-all", no_argument
, NULL
, 'x'},
267 'x', NULL
, N_("Discard all local symbols"), TWO_DASHES
},
268 { {"discard-locals", no_argument
, NULL
, 'X'},
269 'X', NULL
, N_("Discard temporary local symbols (default)"), TWO_DASHES
},
270 { {"discard-none", no_argument
, NULL
, OPTION_DISCARD_NONE
},
271 '\0', NULL
, N_("Don't discard any local symbols"), TWO_DASHES
},
272 { {"trace-symbol", required_argument
, NULL
, 'y'},
273 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES
},
274 { {NULL
, required_argument
, NULL
, '\0'},
275 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), ONE_DASH
},
276 { {"start-group", no_argument
, NULL
, '('},
277 '(', NULL
, N_("Start a group"), TWO_DASHES
},
278 { {"end-group", no_argument
, NULL
, ')'},
279 ')', NULL
, N_("End a group"), TWO_DASHES
},
280 { {"accept-unknown-input-arch", no_argument
, NULL
, OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
},
281 '\0', NULL
, N_("Accept input files whose architecture cannot be determined"), TWO_DASHES
},
282 { {"no-accept-unknown-input-arch", no_argument
, NULL
, OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
},
283 '\0', NULL
, N_("Reject input files whose architecture is unknown"), TWO_DASHES
},
284 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
285 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH
},
286 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
287 '\0', NULL
, N_("Link against shared libraries"), ONE_DASH
},
288 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
289 '\0', NULL
, NULL
, ONE_DASH
},
290 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
291 '\0', NULL
, NULL
, ONE_DASH
},
292 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
293 '\0', NULL
, N_("Do not link against shared libraries"), ONE_DASH
},
294 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
295 '\0', NULL
, NULL
, ONE_DASH
},
296 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
297 '\0', NULL
, NULL
, ONE_DASH
},
298 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
299 '\0', NULL
, NULL
, ONE_DASH
},
300 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
301 '\0', NULL
, N_("Bind global references locally"), ONE_DASH
},
302 { {"check-sections", no_argument
, NULL
, OPTION_CHECK_SECTIONS
},
303 '\0', NULL
, N_("Check section addresses for overlaps (default)"), TWO_DASHES
},
304 { {"no-check-sections", no_argument
, NULL
, OPTION_NO_CHECK_SECTIONS
},
305 '\0', NULL
, N_("Do not check section addresses for overlaps"),
307 { {"cref", no_argument
, NULL
, OPTION_CREF
},
308 '\0', NULL
, N_("Output cross reference table"), TWO_DASHES
},
309 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
310 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES
},
311 { {"demangle", optional_argument
, NULL
, OPTION_DEMANGLE
},
312 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), TWO_DASHES
},
313 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
314 '\0', NULL
, N_("Generate embedded relocs"), TWO_DASHES
},
315 { {"fini", required_argument
, NULL
, OPTION_FINI
},
316 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH
},
317 { {"force-exe-suffix", no_argument
, NULL
, OPTION_FORCE_EXE_SUFFIX
},
318 '\0', NULL
, N_("Force generation of file with .exe suffix"), TWO_DASHES
},
319 { {"gc-sections", no_argument
, NULL
, OPTION_GC_SECTIONS
},
320 '\0', NULL
, N_("Remove unused sections (on some targets)"),
322 { {"no-gc-sections", no_argument
, NULL
, OPTION_NO_GC_SECTIONS
},
323 '\0', NULL
, N_("Don't remove unused sections (default)"),
325 { {"help", no_argument
, NULL
, OPTION_HELP
},
326 '\0', NULL
, N_("Print option help"), TWO_DASHES
},
327 { {"init", required_argument
, NULL
, OPTION_INIT
},
328 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH
},
329 { {"Map", required_argument
, NULL
, OPTION_MAP
},
330 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH
},
331 { {"no-define-common", no_argument
, NULL
, OPTION_NO_DEFINE_COMMON
},
332 '\0', NULL
, N_("Do not define Common storage"), TWO_DASHES
},
333 { {"no-demangle", no_argument
, NULL
, OPTION_NO_DEMANGLE
},
334 '\0', NULL
, N_("Do not demangle symbol names"), TWO_DASHES
},
335 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
336 '\0', NULL
, N_("Use less memory and more disk I/O"), TWO_DASHES
},
337 { {"no-undefined", no_argument
, NULL
, OPTION_NO_UNDEFINED
},
338 '\0', NULL
, N_("Allow no undefined symbols"), TWO_DASHES
},
339 { {"allow-shlib-undefined", no_argument
, NULL
, OPTION_ALLOW_SHLIB_UNDEFINED
},
340 '\0', NULL
, N_("Allow undefined symbols in shared objects (the default)"), TWO_DASHES
},
341 { {"no-allow-shlib-undefined", no_argument
, NULL
, OPTION_NO_ALLOW_SHLIB_UNDEFINED
},
342 '\0', NULL
, N_("Do not allow undefined symbols in shared objects"), TWO_DASHES
},
343 { {"allow-multiple-definition", no_argument
, NULL
, OPTION_ALLOW_MULTIPLE_DEFINITION
},
344 '\0', NULL
, N_("Allow multiple definitions"), TWO_DASHES
},
345 { {"no-undefined-version", no_argument
, NULL
, OPTION_NO_UNDEFINED_VERSION
},
346 '\0', NULL
, N_("Disallow undefined version"), TWO_DASHES
},
347 { {"no-warn-mismatch", no_argument
, NULL
, OPTION_NO_WARN_MISMATCH
},
348 '\0', NULL
, N_("Don't warn about mismatched input files"), TWO_DASHES
},
349 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
350 '\0', NULL
, N_("Turn off --whole-archive"), TWO_DASHES
},
351 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
352 '\0', NULL
, N_("Create an output file even if errors occur"), TWO_DASHES
},
353 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
354 '\0', NULL
, NULL
, NO_HELP
},
355 { {"nostdlib", no_argument
, NULL
, OPTION_NOSTDLIB
},
356 '\0', NULL
, N_("Only use library directories specified on\n\t\t\t\tthe command line"), ONE_DASH
},
357 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
358 '\0', N_("TARGET"), N_("Specify target of output file"), EXACTLY_TWO_DASHES
},
359 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
360 '\0', NULL
, N_("Ignored for Linux compatibility"), ONE_DASH
},
361 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
362 '\0', NULL
, N_("Relax branches on certain targets"), TWO_DASHES
},
363 { {"retain-symbols-file", required_argument
, NULL
,
364 OPTION_RETAIN_SYMBOLS_FILE
},
365 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES
},
366 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
367 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH
},
368 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
369 '\0', N_("PATH"), N_("Set link time shared library search path"), ONE_DASH
},
370 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
371 '\0', NULL
, N_("Create a shared library"), ONE_DASH
},
372 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
373 '\0', NULL
, NULL
, ONE_DASH
},
374 { {"pie", no_argument
, NULL
, OPTION_PIE
},
375 '\0', NULL
, N_("Create a position independent executable"), ONE_DASH
},
376 { {"pic-executable", no_argument
, NULL
, OPTION_PIE
},
377 '\0', NULL
, NULL
, TWO_DASHES
},
378 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
379 '\0', NULL
, N_("Sort common symbols by size"), TWO_DASHES
},
380 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
381 '\0', NULL
, NULL
, NO_HELP
},
382 { {"spare-dynamic-tags", required_argument
, NULL
, OPTION_SPARE_DYNAMIC_TAGS
},
383 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"), TWO_DASHES
},
384 { {"split-by-file", optional_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
385 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"), TWO_DASHES
},
386 { {"split-by-reloc", optional_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
387 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"), TWO_DASHES
},
388 { {"stats", no_argument
, NULL
, OPTION_STATS
},
389 '\0', NULL
, N_("Print memory usage statistics"), TWO_DASHES
},
390 { {"target-help", no_argument
, NULL
, OPTION_TARGET_HELP
},
391 '\0', NULL
, N_("Display target specific options"), TWO_DASHES
},
392 { {"task-link", required_argument
, NULL
, OPTION_TASK_LINK
},
393 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES
},
394 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
395 '\0', NULL
, N_("Use same format as native linker"), TWO_DASHES
},
396 { {"section-start", required_argument
, NULL
, OPTION_SECTION_START
},
397 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"), TWO_DASHES
},
398 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
399 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH
},
400 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
401 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH
},
402 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
403 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH
},
404 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
405 '\0', NULL
, N_("Output lots of information during link"), TWO_DASHES
},
406 { {"dll-verbose", no_argument
, NULL
, OPTION_VERBOSE
}, /* Linux. */
407 '\0', NULL
, NULL
, NO_HELP
},
408 { {"version-script", required_argument
, NULL
, OPTION_VERSION_SCRIPT
},
409 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES
},
410 { {"version-exports-section", required_argument
, NULL
,
411 OPTION_VERSION_EXPORTS_SECTION
},
412 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n\t\t\t\tSYMBOL as the version."),
414 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
415 '\0', NULL
, N_("Warn about duplicate common symbols"), TWO_DASHES
},
416 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
417 '\0', NULL
, N_("Warn if global constructors/destructors are seen"),
419 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
420 '\0', NULL
, N_("Warn if the multiple GP values are used"), TWO_DASHES
},
421 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
422 '\0', NULL
, N_("Warn only once per undefined symbol"), TWO_DASHES
},
423 { {"warn-section-align", no_argument
, NULL
, OPTION_WARN_SECTION_ALIGN
},
424 '\0', NULL
, N_("Warn if start of section changes due to alignment"),
426 { {"fatal-warnings", no_argument
, NULL
, OPTION_WARN_FATAL
},
427 '\0', NULL
, N_("Treat warnings as errors"),
429 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
430 '\0', NULL
, N_("Include all objects from following archives"), TWO_DASHES
},
431 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
432 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES
},
433 { {"mpc860c0", optional_argument
, NULL
, OPTION_MPC860C0
},
434 '\0', N_("[=WORDS]"), N_("Modify problematic branches in last WORDS (1-10,\n\t\t\t\tdefault 5) words of a page"), TWO_DASHES
}
437 #define OPTION_COUNT ARRAY_SIZE (ld_options)
439 /* Test STRING for containing a string of digits that form a number
440 between MIN and MAX. The return value is the number or ERR. */
443 is_num (string
, min
, max
, err
)
451 for (; *string
; ++string
)
453 if (! ISDIGIT (*string
))
458 result
= result
* 10 + (*string
- '0');
460 if (result
< min
|| result
> max
)
467 parse_args (argc
, argv
)
474 char *default_dirlist
= NULL
;
476 struct option
*longopts
;
477 struct option
*really_longopts
;
480 shortopts
= (char *) xmalloc (OPTION_COUNT
* 3 + 2);
481 longopts
= (struct option
*) xmalloc (sizeof (*longopts
)
482 * (OPTION_COUNT
+ 1));
483 really_longopts
= (struct option
*) xmalloc (sizeof (*really_longopts
)
484 * (OPTION_COUNT
+ 1));
486 /* Starting the short option string with '-' is for programs that
487 expect options and other ARGV-elements in any order and that care about
488 the ordering of the two. We describe each non-option ARGV-element
489 as if it were the argument of an option with character code 1. */
494 for (i
= 0; i
< OPTION_COUNT
; i
++)
496 if (ld_options
[i
].shortopt
!= '\0')
498 shortopts
[is
] = ld_options
[i
].shortopt
;
500 if (ld_options
[i
].opt
.has_arg
== required_argument
501 || ld_options
[i
].opt
.has_arg
== optional_argument
)
505 if (ld_options
[i
].opt
.has_arg
== optional_argument
)
512 if (ld_options
[i
].opt
.name
!= NULL
)
514 if (ld_options
[i
].control
== EXACTLY_TWO_DASHES
)
516 really_longopts
[irl
] = ld_options
[i
].opt
;
521 longopts
[il
] = ld_options
[i
].opt
;
526 shortopts
[is
] = '\0';
527 longopts
[il
].name
= NULL
;
528 really_longopts
[irl
].name
= NULL
;
530 ldemul_add_options (is
, &shortopts
, il
, &longopts
, irl
, &really_longopts
);
532 /* The -G option is ambiguous on different platforms. Sometimes it
533 specifies the largest data size to put into the small data
534 section. Sometimes it is equivalent to --shared. Unfortunately,
535 the first form takes an argument, while the second does not.
537 We need to permit the --shared form because on some platforms,
538 such as Solaris, gcc -shared will pass -G to the linker.
540 To permit either usage, we look through the argument list. If we
541 find -G not followed by a number, we change it into --shared.
542 This will work for most normal cases. */
543 for (i
= 1; i
< argc
; i
++)
544 if (strcmp (argv
[i
], "-G") == 0
546 || ! ISDIGIT (argv
[i
+ 1][0])))
547 argv
[i
] = (char *) "--shared";
549 /* Because we permit long options to start with a single dash, and
550 we have a --library option, and the -l option is conventionally
551 used with an immediately following argument, we can have bad
552 results if somebody tries to use -l with a library whose name
553 happens to start with "ibrary", as in -li. We avoid problems by
554 simply turning -l into --library. This means that users will
555 have to use two dashes in order to use --library, which is OK
556 since that's how it is documented.
558 FIXME: It's possible that this problem can arise for other short
559 options as well, although the user does always have the recourse
560 of adding a space between the option and the argument. */
561 for (i
= 1; i
< argc
; i
++)
563 if (argv
[i
][0] == '-'
565 && argv
[i
][2] != '\0')
569 n
= (char *) xmalloc (strlen (argv
[i
]) + 20);
570 sprintf (n
, "--library=%s", argv
[i
] + 2);
581 /* Using last_optind lets us avoid calling ldemul_parse_args
582 multiple times on a single option, which would lead to
583 confusion in the internal static variables maintained by
584 getopt. This could otherwise happen for an argument like
585 -nx, in which the -n is parsed as a single option, and we
586 loop around to pick up the -x. */
587 if (optind
!= last_optind
)
588 if (ldemul_parse_args (argc
, argv
))
591 /* getopt_long_only is like getopt_long, but '-' as well as '--'
592 can indicate a long option. */
594 last_optind
= optind
;
595 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
598 optind
= last_optind
;
599 optc
= getopt_long (argc
, argv
, "-", really_longopts
, &longind
);
602 if (ldemul_handle_option (optc
))
611 einfo (_("%P: unrecognized option '%s'\n"), argv
[last_optind
]);
613 einfo (_("%P%F: use the --help option for usage information\n"));
615 case 1: /* File name. */
616 lang_add_input_file (optarg
, lang_input_file_is_file_enum
,
623 /* For HP/UX compatibility. Actually -a shared should mean
624 ``use only shared libraries'' but, then, we don't
625 currently support shared libraries on HP/UX anyhow. */
626 if (strcmp (optarg
, "archive") == 0)
627 config
.dynamic_link
= FALSE
;
628 else if (strcmp (optarg
, "shared") == 0
629 || strcmp (optarg
, "default") == 0)
630 config
.dynamic_link
= TRUE
;
632 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg
);
635 /* FIXME: We just ignore these, but we should handle them. */
636 if (strcmp (optarg
, "definitions") == 0)
638 else if (strcmp (optarg
, "nodefinitions") == 0)
640 else if (strcmp (optarg
, "nosymbolic") == 0)
642 else if (strcmp (optarg
, "pure-text") == 0)
645 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg
);
648 ldfile_add_arch (optarg
);
651 lang_add_target (optarg
);
654 ldfile_open_command_file (optarg
);
655 parser_input
= input_mri_script
;
658 case OPTION_CALL_SHARED
:
659 config
.dynamic_link
= TRUE
;
661 case OPTION_NON_SHARED
:
662 config
.dynamic_link
= FALSE
;
665 command_line
.cref
= TRUE
;
666 link_info
.notice_all
= TRUE
;
669 command_line
.force_common_definition
= TRUE
;
673 lex_redirect (optarg
);
674 parser_input
= input_defsym
;
680 case OPTION_DEMANGLE
:
684 enum demangling_styles style
;
686 style
= cplus_demangle_name_to_style (optarg
);
687 if (style
== unknown_demangling
)
688 einfo (_("%F%P: unknown demangling style `%s'"),
691 cplus_demangle_set_style (style
);
694 case 'I': /* Used on Solaris. */
695 case OPTION_DYNAMIC_LINKER
:
696 command_line
.interpreter
= optarg
;
699 command_line
.endian
= ENDIAN_BIG
;
702 command_line
.endian
= ENDIAN_LITTLE
;
704 case OPTION_EMBEDDED_RELOCS
:
705 command_line
.embedded_relocs
= TRUE
;
707 case OPTION_EXPORT_DYNAMIC
:
708 case 'E': /* HP/UX compatibility. */
709 link_info
.export_dynamic
= TRUE
;
712 lang_add_entry (optarg
, TRUE
);
715 if (command_line
.auxiliary_filters
== NULL
)
717 command_line
.auxiliary_filters
=
718 (char **) xmalloc (2 * sizeof (char *));
719 command_line
.auxiliary_filters
[0] = optarg
;
720 command_line
.auxiliary_filters
[1] = NULL
;
728 for (p
= command_line
.auxiliary_filters
; *p
!= NULL
; p
++)
730 command_line
.auxiliary_filters
=
731 (char **) xrealloc (command_line
.auxiliary_filters
,
732 (c
+ 2) * sizeof (char *));
733 command_line
.auxiliary_filters
[c
] = optarg
;
734 command_line
.auxiliary_filters
[c
+ 1] = NULL
;
738 command_line
.filter_shlib
= optarg
;
740 case OPTION_FORCE_EXE_SUFFIX
:
741 command_line
.force_exe_suffix
= TRUE
;
746 g_switch_value
= strtoul (optarg
, &end
, 0);
748 einfo (_("%P%F: invalid number `%s'\n"), optarg
);
754 case OPTION_GC_SECTIONS
:
755 command_line
.gc_sections
= TRUE
;
762 ldfile_add_library_path (optarg
, TRUE
);
765 lang_add_input_file (optarg
, lang_input_file_is_l_enum
,
769 config
.map_filename
= "-";
772 /* Ignore. Was handled in a pre-parse. */
775 config
.map_filename
= optarg
;
778 config
.text_read_only
= FALSE
;
779 config
.magic_demand_paged
= FALSE
;
780 config
.dynamic_link
= FALSE
;
782 case OPTION_NO_OMAGIC
:
783 config
.text_read_only
= TRUE
;
784 config
.magic_demand_paged
= TRUE
;
785 /* NB/ Does not set dynamic_link to TRUE.
786 Use --call-shared or -Bdynamic for this. */
789 config
.magic_demand_paged
= FALSE
;
790 config
.dynamic_link
= FALSE
;
792 case OPTION_NO_DEFINE_COMMON
:
793 command_line
.inhibit_common_definition
= TRUE
;
795 case OPTION_NO_DEMANGLE
:
798 case OPTION_NO_GC_SECTIONS
:
799 command_line
.gc_sections
= FALSE
;
801 case OPTION_NO_KEEP_MEMORY
:
802 link_info
.keep_memory
= FALSE
;
804 case OPTION_NO_UNDEFINED
:
805 link_info
.no_undefined
= TRUE
;
807 case OPTION_ALLOW_SHLIB_UNDEFINED
:
808 link_info
.allow_shlib_undefined
= TRUE
;
810 case OPTION_NO_ALLOW_SHLIB_UNDEFINED
:
811 link_info
.allow_shlib_undefined
= FALSE
;
813 case OPTION_ALLOW_MULTIPLE_DEFINITION
:
814 link_info
.allow_multiple_definition
= TRUE
;
816 case OPTION_NO_UNDEFINED_VERSION
:
817 link_info
.allow_undefined_version
= FALSE
;
819 case OPTION_NO_WARN_MISMATCH
:
820 command_line
.warn_mismatch
= FALSE
;
822 case OPTION_NOINHIBIT_EXEC
:
823 force_make_executable
= TRUE
;
825 case OPTION_NOSTDLIB
:
826 config
.only_cmd_line_lib_dirs
= TRUE
;
828 case OPTION_NO_WHOLE_ARCHIVE
:
829 whole_archive
= FALSE
;
832 /* FIXME "-O<non-digits> <value>" used to set the address of
833 section <non-digits>. Was this for compatibility with
834 something, or can we create a new option to do that
835 (with a syntax similar to -defsym)?
836 getopt can't handle two args to an option without kludges. */
838 /* Enable optimizations of output files. */
839 link_info
.optimize
= strtoul (optarg
, NULL
, 0) ? TRUE
: FALSE
;
842 lang_add_output (optarg
, 0);
845 lang_add_output_format (optarg
, (char *) NULL
, (char *) NULL
, 0);
848 link_info
.emitrelocations
= TRUE
;
852 if (optind
== last_optind
)
853 /* This can happen if the user put "-rpath,a" on the command
854 line. (Or something similar. The comma is important).
855 Getopt becomes confused and thinks that this is a -r option
856 but it cannot parse the text after the -r so it refuses to
857 increment the optind counter. Detect this case and issue
858 an error message here. We cannot just make this a warning,
859 increment optind, and continue because getopt is too confused
860 and will seg-fault the next time around. */
861 einfo(_("%P%F: bad -rpath option\n"));
863 link_info
.relocateable
= TRUE
;
864 config
.build_constructors
= FALSE
;
865 config
.magic_demand_paged
= FALSE
;
866 config
.text_read_only
= FALSE
;
867 config
.dynamic_link
= FALSE
;
870 /* The GNU linker traditionally uses -R to mean to include
871 only the symbols from a file. The Solaris linker uses -R
872 to set the path used by the runtime linker to find
873 libraries. This is the GNU linker -rpath argument. We
874 try to support both simultaneously by checking the file
875 named. If it is a directory, rather than a regular file,
876 we assume -rpath was meant. */
880 if (stat (optarg
, &s
) >= 0
881 && ! S_ISDIR (s
.st_mode
))
883 lang_add_input_file (optarg
,
884 lang_input_file_is_symbols_only_enum
,
891 if (command_line
.rpath
== NULL
)
892 command_line
.rpath
= xstrdup (optarg
);
895 size_t rpath_len
= strlen (command_line
.rpath
);
896 size_t optarg_len
= strlen (optarg
);
898 char *cp
= command_line
.rpath
;
900 /* First see whether OPTARG is already in the path. */
905 while (optarg
[idx
] != '\0' && optarg
[idx
] == cp
[idx
])
907 if (optarg
[idx
] == '\0'
908 && (cp
[idx
] == '\0' || cp
[idx
] == ':'))
913 cp
= strchr (cp
, ':');
921 buf
= xmalloc (rpath_len
+ optarg_len
+ 2);
922 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
923 free (command_line
.rpath
);
924 command_line
.rpath
= buf
;
928 case OPTION_RPATH_LINK
:
929 if (command_line
.rpath_link
== NULL
)
930 command_line
.rpath_link
= xstrdup (optarg
);
935 buf
= xmalloc (strlen (command_line
.rpath_link
)
938 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
939 free (command_line
.rpath_link
);
940 command_line
.rpath_link
= buf
;
944 command_line
.relax
= TRUE
;
946 case OPTION_RETAIN_SYMBOLS_FILE
:
947 add_keepsyms_file (optarg
);
950 link_info
.strip
= strip_debugger
;
953 link_info
.strip
= strip_all
;
955 case OPTION_STRIP_DISCARDED
:
956 link_info
.strip_discarded
= TRUE
;
958 case OPTION_NO_STRIP_DISCARDED
:
959 link_info
.strip_discarded
= FALSE
;
962 if (config
.has_shared
)
963 link_info
.shared
= TRUE
;
965 einfo (_("%P%F: -shared not supported\n"));
968 if (config
.has_shared
)
970 link_info
.shared
= TRUE
;
971 link_info
.pie
= TRUE
;
974 einfo (_("%P%F: -pie not supported\n"));
976 case 'h': /* Used on Solaris. */
978 command_line
.soname
= optarg
;
980 case OPTION_SORT_COMMON
:
981 config
.sort_common
= TRUE
;
986 case OPTION_SYMBOLIC
:
987 link_info
.symbolic
= TRUE
;
993 ldfile_open_command_file (optarg
);
994 parser_input
= input_script
;
997 case OPTION_SECTION_START
:
1003 /* Check for <something>=<somthing>... */
1004 optarg2
= strchr (optarg
, '=');
1005 if (optarg2
== NULL
)
1006 einfo (_("%P%F: invalid argument to option \"--section-start\"\n"));
1010 /* So far so good. Are all the args present? */
1011 if ((*optarg
== '\0') || (*optarg2
== '\0'))
1012 einfo (_("%P%F: missing argument(s) to option \"--section-start\"\n"));
1014 /* We must copy the section name as set_section_start
1015 doesn't do it for us. */
1016 len
= optarg2
- optarg
;
1017 sec_name
= xmalloc (len
);
1018 memcpy (sec_name
, optarg
, len
- 1);
1019 sec_name
[len
- 1] = 0;
1021 /* Then set it... */
1022 set_section_start (sec_name
, optarg2
);
1025 case OPTION_TARGET_HELP
:
1026 /* Mention any target specific options. */
1027 ldemul_list_emulation_options (stdout
);
1030 set_section_start (".bss", optarg
);
1033 set_section_start (".data", optarg
);
1036 set_section_start (".text", optarg
);
1038 case OPTION_TRADITIONAL_FORMAT
:
1039 link_info
.traditional_format
= TRUE
;
1041 case OPTION_TASK_LINK
:
1042 link_info
.task_link
= TRUE
;
1043 /* Fall through - do an implied -r option. */
1045 link_info
.relocateable
= TRUE
;
1046 config
.build_constructors
= TRUE
;
1047 config
.magic_demand_paged
= FALSE
;
1048 config
.text_read_only
= FALSE
;
1049 config
.dynamic_link
= FALSE
;
1052 ldlang_add_undef (optarg
);
1056 lang_add_unique (optarg
);
1058 config
.unique_orphan_sections
= TRUE
;
1060 case OPTION_VERBOSE
:
1062 version_printed
= TRUE
;
1063 trace_file_tries
= TRUE
;
1064 overflow_cutoff_limit
= -2;
1068 version_printed
= TRUE
;
1072 version_printed
= TRUE
;
1074 case OPTION_VERSION
:
1078 case OPTION_VERSION_SCRIPT
:
1079 /* This option indicates a small script that only specifies
1080 version information. Read it, but don't assume that
1081 we've seen a linker script. */
1083 FILE *hold_script_handle
;
1085 hold_script_handle
= saved_script_handle
;
1086 ldfile_open_command_file (optarg
);
1087 saved_script_handle
= hold_script_handle
;
1088 parser_input
= input_version_script
;
1092 case OPTION_VERSION_EXPORTS_SECTION
:
1093 /* This option records a version symbol to be applied to the
1094 symbols listed for export to be found in the object files
1095 .exports sections. */
1096 command_line
.version_exports_section
= optarg
;
1098 case OPTION_WARN_COMMON
:
1099 config
.warn_common
= TRUE
;
1101 case OPTION_WARN_CONSTRUCTORS
:
1102 config
.warn_constructors
= TRUE
;
1104 case OPTION_WARN_FATAL
:
1105 config
.fatal_warnings
= TRUE
;
1107 case OPTION_WARN_MULTIPLE_GP
:
1108 config
.warn_multiple_gp
= TRUE
;
1110 case OPTION_WARN_ONCE
:
1111 config
.warn_once
= TRUE
;
1113 case OPTION_WARN_SECTION_ALIGN
:
1114 config
.warn_section_align
= TRUE
;
1116 case OPTION_WHOLE_ARCHIVE
:
1117 whole_archive
= TRUE
;
1122 case OPTION_DISCARD_NONE
:
1123 link_info
.discard
= discard_none
;
1126 link_info
.discard
= discard_l
;
1129 link_info
.discard
= discard_all
;
1132 if (strncmp (optarg
, "P,", 2) == 0)
1134 if (default_dirlist
!= NULL
)
1135 free (default_dirlist
);
1136 default_dirlist
= xstrdup (optarg
);
1141 case OPTION_SPARE_DYNAMIC_TAGS
:
1142 link_info
.spare_dynamic_tags
= strtoul (optarg
, NULL
, 0);
1144 case OPTION_SPLIT_BY_RELOC
:
1146 config
.split_by_reloc
= strtoul (optarg
, NULL
, 0);
1148 config
.split_by_reloc
= 32768;
1150 case OPTION_SPLIT_BY_FILE
:
1152 config
.split_by_file
= bfd_scan_vma (optarg
, NULL
, 0);
1154 config
.split_by_file
= 1;
1156 case OPTION_CHECK_SECTIONS
:
1157 command_line
.check_section_addresses
= TRUE
;
1159 case OPTION_NO_CHECK_SECTIONS
:
1160 command_line
.check_section_addresses
= FALSE
;
1162 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH
:
1163 command_line
.accept_unknown_input_arch
= TRUE
;
1165 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH
:
1166 command_line
.accept_unknown_input_arch
= FALSE
;
1170 einfo (_("%P%F: may not nest groups (--help for usage)\n"));
1172 lang_enter_group ();
1177 einfo (_("%P%F: group ended before it began (--help for usage)\n"));
1179 lang_leave_group ();
1182 case OPTION_MPC860C0
:
1183 /* Default value (in bytes). */
1184 link_info
.mpc860c0
= 20;
1189 words
= is_num (optarg
, 1, 10, 0);
1191 einfo (_("%P%F: invalid argument to option \"mpc860c0\"\n"));
1193 /* Convert words to bytes. */
1194 link_info
.mpc860c0
= words
* 4;
1196 command_line
.relax
= TRUE
;
1200 link_info
.init_function
= optarg
;
1204 link_info
.fini_function
= optarg
;
1210 lang_leave_group ();
1212 if (default_dirlist
!= NULL
)
1214 set_default_dirlist (default_dirlist
);
1215 free (default_dirlist
);
1219 /* Add the (colon-separated) elements of DIRLIST_PTR to the
1220 library search path. */
1223 set_default_dirlist (dirlist_ptr
)
1230 p
= strchr (dirlist_ptr
, PATH_SEPARATOR
);
1233 if (*dirlist_ptr
!= '\0')
1234 ldfile_add_library_path (dirlist_ptr
, TRUE
);
1237 dirlist_ptr
= p
+ 1;
1242 set_section_start (sect
, valstr
)
1243 char *sect
, *valstr
;
1246 bfd_vma val
= bfd_scan_vma (valstr
, &end
, 16);
1248 einfo (_("%P%F: invalid hex number `%s'\n"), valstr
);
1249 lang_section_start (sect
, exp_intop (val
));
1252 /* Print help messages for the options. */
1258 const char **targets
, **pp
;
1260 printf (_("Usage: %s [options] file...\n"), program_name
);
1262 printf (_("Options:\n"));
1263 for (i
= 0; i
< OPTION_COUNT
; i
++)
1265 if (ld_options
[i
].doc
!= NULL
)
1279 if (ld_options
[j
].shortopt
!= '\0'
1280 && ld_options
[j
].control
!= NO_HELP
)
1282 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
1283 len
+= (comma
? 2 : 0) + 2;
1284 if (ld_options
[j
].arg
!= NULL
)
1286 if (ld_options
[j
].opt
.has_arg
!= optional_argument
)
1291 printf ("%s", _(ld_options
[j
].arg
));
1292 len
+= strlen (_(ld_options
[j
].arg
));
1298 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1303 if (ld_options
[j
].opt
.name
!= NULL
1304 && ld_options
[j
].control
!= NO_HELP
)
1307 (ld_options
[j
].control
== TWO_DASHES
1308 || ld_options
[j
].control
== EXACTLY_TWO_DASHES
);
1312 two_dashes
? "-" : "",
1313 ld_options
[j
].opt
.name
);
1314 len
+= ((comma
? 2 : 0)
1316 + (two_dashes
? 1 : 0)
1317 + strlen (ld_options
[j
].opt
.name
));
1318 if (ld_options
[j
].arg
!= NULL
)
1320 printf (" %s", _(ld_options
[j
].arg
));
1321 len
+= 1 + strlen (_(ld_options
[j
].arg
));
1327 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
1335 for (; len
< 30; len
++)
1338 printf ("%s\n", _(ld_options
[i
].doc
));
1342 /* Note: Various tools (such as libtool) depend upon the
1343 format of the listings below - do not change them. */
1344 /* xgettext:c-format */
1345 printf (_("%s: supported targets:"), program_name
);
1346 targets
= bfd_target_list ();
1347 for (pp
= targets
; *pp
!= NULL
; pp
++)
1348 printf (" %s", *pp
);
1352 /* xgettext:c-format */
1353 printf (_("%s: supported emulations: "), program_name
);
1354 ldemul_list_emulations (stdout
);
1357 /* xgettext:c-format */
1358 printf (_("%s: emulation specific options:\n"), program_name
);
1359 ldemul_list_emulation_options (stdout
);
1362 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO
);