1 /* Parse options for the GNU linker.
2 Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
4 This file is part of GLD, the Gnu Linker.
6 GLD 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 2, or (at your option)
11 GLD 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 GLD; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 #include "libiberty.h"
39 /* Somewhere above, sys/stat.h got included . . . . */
40 #if !defined(S_ISDIR) && defined(S_IFDIR)
41 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
44 /* Omit args to avoid the possibility of clashing with a system header
45 that might disagree about consts. */
46 unsigned long strtoul ();
48 static void set_default_dirlist PARAMS ((char *dirlist_ptr));
49 static void set_section_start PARAMS ((char *sect, char *valstr));
50 static void help PARAMS ((void));
52 /* Non-zero if we are processing a --defsym from the command line. */
53 int parsing_defsym = 0;
55 /* Codes used for the long options with no short synonyms. 150 isn't
56 special; it's just an arbitrary non-ASCII char value. */
58 #define OPTION_ASSERT 150
59 #define OPTION_CALL_SHARED (OPTION_ASSERT + 1)
60 #define OPTION_CREF (OPTION_CALL_SHARED + 1)
61 #define OPTION_DEFSYM (OPTION_CREF + 1)
62 #define OPTION_DYNAMIC_LINKER (OPTION_DEFSYM + 1)
63 #define OPTION_EB (OPTION_DYNAMIC_LINKER + 1)
64 #define OPTION_EL (OPTION_EB + 1)
65 #define OPTION_EMBEDDED_RELOCS (OPTION_EL + 1)
66 #define OPTION_EXPORT_DYNAMIC (OPTION_EMBEDDED_RELOCS + 1)
67 #define OPTION_HELP (OPTION_EXPORT_DYNAMIC + 1)
68 #define OPTION_IGNORE (OPTION_HELP + 1)
69 #define OPTION_MAP (OPTION_IGNORE + 1)
70 #define OPTION_NO_KEEP_MEMORY (OPTION_MAP + 1)
71 #define OPTION_NOINHIBIT_EXEC (OPTION_NO_KEEP_MEMORY + 1)
72 #define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1)
73 #define OPTION_NO_WHOLE_ARCHIVE (OPTION_NON_SHARED + 1)
74 #define OPTION_OFORMAT (OPTION_NO_WHOLE_ARCHIVE + 1)
75 #define OPTION_RELAX (OPTION_OFORMAT + 1)
76 #define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1)
77 #define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1)
78 #define OPTION_RPATH_LINK (OPTION_RPATH + 1)
79 #define OPTION_SHARED (OPTION_RPATH_LINK + 1)
80 #define OPTION_SONAME (OPTION_SHARED + 1)
81 #define OPTION_SORT_COMMON (OPTION_SONAME + 1)
82 #define OPTION_STATS (OPTION_SORT_COMMON + 1)
83 #define OPTION_SYMBOLIC (OPTION_STATS + 1)
84 #define OPTION_TBSS (OPTION_SYMBOLIC + 1)
85 #define OPTION_TDATA (OPTION_TBSS + 1)
86 #define OPTION_TTEXT (OPTION_TDATA + 1)
87 #define OPTION_TRADITIONAL_FORMAT (OPTION_TTEXT + 1)
88 #define OPTION_UR (OPTION_TRADITIONAL_FORMAT + 1)
89 #define OPTION_VERBOSE (OPTION_UR + 1)
90 #define OPTION_VERSION (OPTION_VERBOSE + 1)
91 #define OPTION_WARN_COMMON (OPTION_VERSION + 1)
92 #define OPTION_WARN_CONSTRUCTORS (OPTION_WARN_COMMON + 1)
93 #define OPTION_WARN_MULTIPLE_GP (OPTION_WARN_CONSTRUCTORS + 1)
94 #define OPTION_WARN_ONCE (OPTION_WARN_MULTIPLE_GP + 1)
95 #define OPTION_SPLIT_BY_RELOC (OPTION_WARN_ONCE + 1)
96 #define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1)
97 #define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
98 #define OPTION_WRAP (OPTION_WHOLE_ARCHIVE + 1)
99 #define OPTION_FORCE_EXE_SUFFIX (OPTION_WRAP + 1)
101 /* The long options. This structure is used for both the option
102 parsing and the help text. */
106 /* The long option information. */
108 /* The short option with the same meaning ('\0' if none). */
110 /* The name of the argument (NULL if none). */
112 /* The documentation string. If this is NULL, this is a synonym for
113 the previous option. */
117 /* Use one dash before long option name. */
119 /* Use two dashes before long option name. */
121 /* Don't mention this option in --help output. */
126 static const struct ld_option ld_options[] =
128 { {NULL, required_argument, NULL, '\0'},
129 'a', "KEYWORD", "Shared library control for HP/UX compatibility",
131 { {"architecture", required_argument, NULL, 'A'},
132 'A', "ARCH", "Set architecture" , TWO_DASHES },
133 { {"format", required_argument, NULL, 'b'},
134 'b', "TARGET", "Specify target for following input files", TWO_DASHES },
135 { {"mri-script", required_argument, NULL, 'c'},
136 'c', "FILE", "Read MRI format linker script", TWO_DASHES },
137 { {"dc", no_argument, NULL, 'd'},
138 'd', NULL, "Force common symbols to be defined", ONE_DASH },
139 { {"dp", no_argument, NULL, 'd'},
140 '\0', NULL, NULL, ONE_DASH },
141 { {"entry", required_argument, NULL, 'e'},
142 'e', "ADDRESS", "Set start address", TWO_DASHES },
143 { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
144 'E', NULL, "Export all dynamic symbols", TWO_DASHES },
145 { {NULL, optional_argument, NULL, '\0'},
146 'F', "[FORMAT]", "Ignored", ONE_DASH },
147 { {NULL, no_argument, NULL, '\0'},
148 'g', NULL, "Ignored", ONE_DASH },
149 { {"gpsize", required_argument, NULL, 'G'},
150 'G', "SIZE", "Small data size (if no size, same as --shared)",
152 { {"soname", required_argument, NULL, OPTION_SONAME},
153 'h', "FILENAME", "Set internal name of shared library", ONE_DASH },
154 { {"library", required_argument, NULL, 'l'},
155 'l', "LIBNAME", "Search for library LIBNAME", TWO_DASHES },
156 { {"library-path", required_argument, NULL, 'L'},
157 'L', "DIRECTORY", "Add DIRECTORY to library search path", TWO_DASHES },
158 { {NULL, required_argument, NULL, '\0'},
159 'm', "EMULATION", "Set emulation", ONE_DASH },
160 { {"print-map", no_argument, NULL, 'M'},
161 'M', NULL, "Print map file on standard output", TWO_DASHES },
162 { {"nmagic", no_argument, NULL, 'n'},
163 'n', NULL, "Do not page align data", TWO_DASHES },
164 { {"omagic", no_argument, NULL, 'N'},
165 'N', NULL, "Do not page align data, do not make text readonly",
167 { {"output", required_argument, NULL, 'o'},
168 'o', "FILE", "Set output file name", TWO_DASHES },
169 { {NULL, required_argument, NULL, '\0'},
170 'O', NULL, "Ignored", ONE_DASH },
171 { {"relocateable", no_argument, NULL, 'r'},
172 'r', NULL, "Generate relocateable output", TWO_DASHES },
173 { {NULL, no_argument, NULL, '\0'},
174 'i', NULL, NULL, ONE_DASH },
175 { {"just-symbols", required_argument, NULL, 'R'},
176 'R', "FILE", "Just link symbols (if directory, same as --rpath)",
178 { {"strip-all", no_argument, NULL, 's'},
179 's', NULL, "Strip all symbols", TWO_DASHES },
180 { {"strip-debug", no_argument, NULL, 'S'},
181 'S', NULL, "Strip debugging symbols", TWO_DASHES },
182 { {"trace", no_argument, NULL, 't'},
183 't', NULL, "Trace file opens", TWO_DASHES },
184 { {"script", required_argument, NULL, 'T'},
185 'T', "FILE", "Read linker script", TWO_DASHES },
186 { {"undefined", required_argument, NULL, 'u'},
187 'u', "SYMBOL", "Start with undefined reference to SYMBOL", TWO_DASHES },
188 { {"version", no_argument, NULL, OPTION_VERSION},
189 'v', NULL, "Print version information", TWO_DASHES },
190 { {NULL, no_argument, NULL, '\0'},
191 'V', NULL, "Print version and emulation information", ONE_DASH },
192 { {"discard-all", no_argument, NULL, 'x'},
193 'x', NULL, "Discard all local symbols", TWO_DASHES },
194 { {"discard-locals", no_argument, NULL, 'X'},
195 'X', NULL, "Discard temporary local symbols", TWO_DASHES },
196 { {"trace-symbol", required_argument, NULL, 'y'},
197 'y', "SYMBOL", "Trace mentions of SYMBOL", TWO_DASHES },
198 { {NULL, required_argument, NULL, '\0'},
199 'Y', "PATH", "Default search path for Solaris compatibility", ONE_DASH },
200 { {NULL, required_argument, NULL, '\0'},
201 'z', "KEYWORD", "Ignored for Solaris compatibility", ONE_DASH },
202 { {"start-group", no_argument, NULL, '('},
203 '(', NULL, "Start a group", TWO_DASHES },
204 { {"end-group", no_argument, NULL, ')'},
205 ')', NULL, "End a group", TWO_DASHES },
206 { {"assert", required_argument, NULL, OPTION_ASSERT},
207 '\0', "KEYWORD", "Ignored for SunOS compatibility", ONE_DASH },
208 { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
209 '\0', NULL, "Link against shared libraries", ONE_DASH },
210 { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
211 '\0', NULL, NULL, ONE_DASH },
212 { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
213 '\0', NULL, NULL, ONE_DASH },
214 { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
215 '\0', NULL, "Do not link against shared libraries", ONE_DASH },
216 { {"dn", no_argument, NULL, OPTION_NON_SHARED},
217 '\0', NULL, NULL, ONE_DASH },
218 { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
219 '\0', NULL, NULL, ONE_DASH },
220 { {"static", no_argument, NULL, OPTION_NON_SHARED},
221 '\0', NULL, NULL, ONE_DASH },
222 { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
223 '\0', NULL, "Bind global references locally", ONE_DASH },
224 { {"cref", no_argument, NULL, OPTION_CREF},
225 '\0', NULL, "Output cross reference table", TWO_DASHES },
226 { {"defsym", required_argument, NULL, OPTION_DEFSYM},
227 '\0', "SYMBOL=EXPRESSION", "Define a symbol", TWO_DASHES },
228 { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
229 '\0', "PROGRAM", "Set the dynamic linker to use", TWO_DASHES },
230 { {"EB", no_argument, NULL, OPTION_EB},
231 '\0', NULL, "Link big-endian objects", ONE_DASH },
232 { {"EL", no_argument, NULL, OPTION_EL},
233 '\0', NULL, "Link little-endian objects", ONE_DASH },
234 { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
235 '\0', NULL, "Generate embedded relocs", TWO_DASHES},
236 { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
237 '\0', NULL, "Force generation of file with .exe suffix", TWO_DASHES},
238 { {"help", no_argument, NULL, OPTION_HELP},
239 '\0', NULL, "Print option help", TWO_DASHES },
240 { {"Map", required_argument, NULL, OPTION_MAP},
241 '\0', "FILE", "Write a map file", ONE_DASH },
242 { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
243 '\0', NULL, "Use less memory and more disk I/O", TWO_DASHES },
244 { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
245 '\0', NULL, "Turn off --whole-archive", TWO_DASHES },
246 { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
247 '\0', NULL, "Create an output file even if errors occur", TWO_DASHES },
248 { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
249 '\0', NULL, NULL, NO_HELP },
250 { {"oformat", required_argument, NULL, OPTION_OFORMAT},
251 '\0', "TARGET", "Specify target of output file", TWO_DASHES },
252 { {"qmagic", no_argument, NULL, OPTION_IGNORE},
253 '\0', NULL, "Ignored for Linux compatibility", ONE_DASH },
254 { {"Qy", no_argument, NULL, OPTION_IGNORE},
255 '\0', NULL, "Ignored for SVR4 compatibility", ONE_DASH },
256 { {"relax", no_argument, NULL, OPTION_RELAX},
257 '\0', NULL, "Relax branches on certain targets", TWO_DASHES },
258 { {"retain-symbols-file", required_argument, NULL,
259 OPTION_RETAIN_SYMBOLS_FILE},
260 '\0', "FILE", "Keep only symbols listed in FILE", TWO_DASHES },
261 { {"rpath", required_argument, NULL, OPTION_RPATH},
262 '\0', "PATH", "Set runtime shared library search path", ONE_DASH },
263 { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
264 '\0', "PATH", "Set link time shared library search path", ONE_DASH },
265 { {"shared", no_argument, NULL, OPTION_SHARED},
266 '\0', NULL, "Create a shared library", ONE_DASH },
267 { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */
268 '\0', NULL, NULL, ONE_DASH },
269 { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
270 '\0', NULL, "Sort common symbols by size", TWO_DASHES },
271 { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
272 '\0', NULL, NULL, NO_HELP },
273 { {"split-by-file", no_argument, NULL, OPTION_SPLIT_BY_FILE},
274 '\0', NULL, "Split output sections for each file", TWO_DASHES },
275 { {"split-by-reloc", required_argument, NULL, OPTION_SPLIT_BY_RELOC},
276 '\0', "COUNT", "Split output sections every COUNT relocs", TWO_DASHES },
277 { {"stats", no_argument, NULL, OPTION_STATS},
278 '\0', NULL, "Print memory usage statistics", TWO_DASHES },
279 { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
280 '\0', NULL, "Use same format as native linker", TWO_DASHES },
281 { {"Tbss", required_argument, NULL, OPTION_TBSS},
282 '\0', "ADDRESS", "Set address of .bss section", ONE_DASH },
283 { {"Tdata", required_argument, NULL, OPTION_TDATA},
284 '\0', "ADDRESS", "Set address of .data section", ONE_DASH },
285 { {"Ttext", required_argument, NULL, OPTION_TTEXT},
286 '\0', "ADDRESS", "Set address of .text section", ONE_DASH },
287 { {"Ur", no_argument, NULL, OPTION_UR},
288 '\0', NULL, "Build global constructor/destructor tables", ONE_DASH },
289 { {"verbose", no_argument, NULL, OPTION_VERBOSE},
290 '\0', NULL, "Output lots of information during link", TWO_DASHES },
291 { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */
292 '\0', NULL, NULL, NO_HELP },
293 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
294 '\0', NULL, "Warn about duplicate common symbols", TWO_DASHES },
295 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
296 '\0', NULL, "Warn if global constructors/destructors are seen",
298 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
299 '\0', NULL, "Warn if the multiple GP values are used", TWO_DASHES },
300 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
301 '\0', NULL, "Warn only once per undefined symbol", TWO_DASHES },
302 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
303 '\0', NULL, "Include all objects from following archives", TWO_DASHES },
304 { {"wrap", required_argument, NULL, OPTION_WRAP},
305 '\0', "SYMBOL", "Use wrapper functions for SYMBOL", TWO_DASHES }
308 #define OPTION_COUNT (sizeof ld_options / sizeof ld_options[0])
311 parse_args (argc, argv)
317 char *default_dirlist = NULL;
318 char shortopts[OPTION_COUNT * 3 + 2];
319 struct option longopts[OPTION_COUNT + 1];
321 /* Starting the short option string with '-' is for programs that
322 expect options and other ARGV-elements in any order and that care about
323 the ordering of the two. We describe each non-option ARGV-element
324 as if it were the argument of an option with character code 1. */
328 for (i = 0; i < OPTION_COUNT; i++)
330 if (ld_options[i].shortopt != '\0')
332 shortopts[is] = ld_options[i].shortopt;
334 if (ld_options[i].opt.has_arg == required_argument
335 || ld_options[i].opt.has_arg == optional_argument)
339 if (ld_options[i].opt.has_arg == optional_argument)
346 if (ld_options[i].opt.name != NULL)
348 longopts[il] = ld_options[i].opt;
352 shortopts[is] = '\0';
353 longopts[il].name = NULL;
355 /* The -G option is ambiguous on different platforms. Sometimes it
356 specifies the largest data size to put into the small data
357 section. Sometimes it is equivalent to --shared. Unfortunately,
358 the first form takes an argument, while the second does not.
360 We need to permit the --shared form because on some platforms,
361 such as Solaris, gcc -shared will pass -G to the linker.
363 To permit either usage, we look through the argument list. If we
364 find -G not followed by a number, we change it into --shared.
365 This will work for most normal cases. */
366 for (i = 1; i < argc; i++)
367 if (strcmp (argv[i], "-G") == 0
369 || ! isdigit (argv[i + 1][0])))
370 argv[i] = (char *) "--shared";
374 /* getopt_long_only is like getopt_long, but '-' as well as '--' can
375 indicate a long option. */
379 if (ldemul_parse_args (argc, argv))
382 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
390 case 1: /* File name. */
391 lang_add_input_file (optarg, lang_input_file_is_file_enum,
398 /* For HP/UX compatibility. Actually -a shared should mean
399 ``use only shared libraries'' but, then, we don't
400 currently support shared libraries on HP/UX anyhow. */
401 if (strcmp (optarg, "archive") == 0)
402 config.dynamic_link = false;
403 else if (strcmp (optarg, "shared") == 0
404 || strcmp (optarg, "default") == 0)
405 config.dynamic_link = true;
407 einfo ("%P%F: unrecognized -a option `%s'\n", optarg);
410 /* FIXME: We just ignore these, but we should handle them. */
411 if (strcmp (optarg, "definitions") == 0)
413 else if (strcmp (optarg, "nodefinitions") == 0)
415 else if (strcmp (optarg, "nosymbolic") == 0)
417 else if (strcmp (optarg, "pure-text") == 0)
420 einfo ("%P%F: unrecognized -assert option `%s'\n", optarg);
423 ldfile_add_arch (optarg);
426 lang_add_target (optarg);
429 ldfile_open_command_file (optarg);
430 parser_input = input_mri_script;
433 case OPTION_CALL_SHARED:
434 config.dynamic_link = true;
436 case OPTION_NON_SHARED:
437 config.dynamic_link = false;
440 command_line.cref = true;
441 link_info.notice_all = true;
444 command_line.force_common_definition = true;
448 lex_redirect (optarg);
449 parser_input = input_defsym;
455 case OPTION_DYNAMIC_LINKER:
456 command_line.interpreter = optarg;
459 command_line.endian = ENDIAN_BIG;
462 command_line.endian = ENDIAN_LITTLE;
464 case OPTION_EMBEDDED_RELOCS:
465 command_line.embedded_relocs = true;
467 case OPTION_EXPORT_DYNAMIC:
468 case 'E': /* HP/UX compatibility. */
469 command_line.export_dynamic = true;
472 lang_add_entry (optarg, true);
477 case OPTION_FORCE_EXE_SUFFIX:
478 command_line.force_exe_suffix = true;
483 g_switch_value = strtoul (optarg, &end, 0);
485 einfo ("%P%F: invalid number `%s'\n", optarg);
496 ldfile_add_library_path (optarg, true);
499 lang_add_input_file (optarg, lang_input_file_is_l_enum,
503 config.map_filename = "-";
506 /* Ignore. Was handled in a pre-parse. */
509 config.map_filename = optarg;
512 config.text_read_only = false;
513 config.magic_demand_paged = false;
514 config.dynamic_link = false;
517 config.magic_demand_paged = false;
518 config.dynamic_link = false;
520 case OPTION_NO_KEEP_MEMORY:
521 link_info.keep_memory = false;
523 case OPTION_NOINHIBIT_EXEC:
524 force_make_executable = true;
526 case OPTION_NO_WHOLE_ARCHIVE:
527 whole_archive = false;
530 /* FIXME "-O<non-digits> <value>" used to set the address of
531 section <non-digits>. Was this for compatibility with
532 something, or can we create a new option to do that
533 (with a syntax similar to -defsym)?
534 getopt can't handle two args to an option without kludges. */
537 lang_add_output (optarg, 0);
540 lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
544 link_info.relocateable = true;
545 config.build_constructors = false;
546 config.magic_demand_paged = false;
547 config.text_read_only = false;
548 config.dynamic_link = false;
551 /* The GNU linker traditionally uses -R to mean to include
552 only the symbols from a file. The Solaris linker uses -R
553 to set the path used by the runtime linker to find
554 libraries. This is the GNU linker -rpath argument. We
555 try to support both simultaneously by checking the file
556 named. If it is a directory, rather than a regular file,
557 we assume -rpath was meant. */
561 if (stat (optarg, &s) >= 0
562 && ! S_ISDIR (s.st_mode))
564 lang_add_input_file (optarg,
565 lang_input_file_is_symbols_only_enum,
572 if (command_line.rpath == NULL)
573 command_line.rpath = buystring (optarg);
578 buf = xmalloc (strlen (command_line.rpath)
581 sprintf (buf, "%s:%s", command_line.rpath, optarg);
582 free (command_line.rpath);
583 command_line.rpath = buf;
586 case OPTION_RPATH_LINK:
587 if (command_line.rpath_link == NULL)
588 command_line.rpath_link = buystring (optarg);
593 buf = xmalloc (strlen (command_line.rpath_link)
596 sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
597 free (command_line.rpath_link);
598 command_line.rpath_link = buf;
602 command_line.relax = true;
604 case OPTION_RETAIN_SYMBOLS_FILE:
605 add_keepsyms_file (optarg);
608 link_info.strip = strip_debugger;
611 link_info.strip = strip_all;
614 link_info.shared = true;
616 case 'h': /* Used on Solaris. */
618 command_line.soname = optarg;
620 case OPTION_SORT_COMMON:
621 config.sort_common = true;
626 case OPTION_SYMBOLIC:
627 link_info.symbolic = true;
633 ldfile_open_command_file (optarg);
634 parser_input = input_script;
638 set_section_start (".bss", optarg);
641 set_section_start (".data", optarg);
644 set_section_start (".text", optarg);
646 case OPTION_TRADITIONAL_FORMAT:
647 link_info.traditional_format = true;
650 link_info.relocateable = true;
651 config.build_constructors = true;
652 config.magic_demand_paged = false;
653 config.text_read_only = false;
654 config.dynamic_link = false;
657 ldlang_add_undef (optarg);
661 version_printed = true;
662 trace_file_tries = true;
666 version_printed = true;
670 version_printed = true;
673 /* This output is intended to follow the GNU standards document. */
674 printf ("GNU ld %s\n", ld_program_version);
675 printf ("Copyright 1996 Free Software Foundation, Inc.\n");
677 This program is free software; you may redistribute it under the terms of\n\
678 the GNU General Public License. This program has absolutely no warranty.\n");
680 ld_emulation_xfer_type **ptr = ld_emulations;
682 printf (" Supported emulations:\n");
685 printf (" %s\n", (*ptr)->emulation_name);
691 case OPTION_WARN_COMMON:
692 config.warn_common = true;
694 case OPTION_WARN_CONSTRUCTORS:
695 config.warn_constructors = true;
697 case OPTION_WARN_MULTIPLE_GP:
698 config.warn_multiple_gp = true;
700 case OPTION_WARN_ONCE:
701 config.warn_once = true;
703 case OPTION_WHOLE_ARCHIVE:
704 whole_archive = true;
710 link_info.discard = discard_l;
713 link_info.discard = discard_all;
716 if (strncmp (optarg, "P,", 2) == 0)
718 default_dirlist = xstrdup (optarg);
724 /* We accept and ignore this option for Solaris
725 compatibility. Actually, on Solaris, optarg is not
726 ignored. Someday we should handle it correctly. FIXME. */
728 case OPTION_SPLIT_BY_RELOC:
729 config.split_by_reloc = atoi (optarg);
731 case OPTION_SPLIT_BY_FILE:
732 config.split_by_file = true;
738 "%s: may not nest groups (--help for usage)\n",
749 "%s: group ended before it began (--help for usage)\n",
763 if (default_dirlist != NULL)
764 set_default_dirlist (default_dirlist);
768 /* Add the (colon-separated) elements of DIRLIST_PTR to the
769 library search path. */
772 set_default_dirlist (dirlist_ptr)
779 p = strchr (dirlist_ptr, ':');
782 if (*dirlist_ptr != '\0')
783 ldfile_add_library_path (dirlist_ptr, true);
791 set_section_start (sect, valstr)
795 unsigned long val = strtoul (valstr, &end, 16);
797 einfo ("%P%F: invalid hex number `%s'\n", valstr);
798 lang_section_start (sect, exp_intop (val));
801 /* Print help messages for the options. */
807 const char **targets, **pp;
809 printf ("Usage: %s [options] file...\n", program_name);
811 printf ("Options:\n");
812 for (i = 0; i < OPTION_COUNT; i++)
814 if (ld_options[i].doc != NULL)
828 if (ld_options[j].shortopt != '\0'
829 && ld_options[j].control != NO_HELP)
831 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
832 len += (comma ? 2 : 0) + 2;
833 if (ld_options[j].arg != NULL)
835 if (ld_options[j].opt.has_arg != optional_argument)
840 printf ("%s", ld_options[j].arg);
841 len += strlen (ld_options[j].arg);
847 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
852 if (ld_options[j].opt.name != NULL
853 && ld_options[j].control != NO_HELP)
857 ld_options[j].control == TWO_DASHES ? "-" : "",
858 ld_options[j].opt.name);
859 len += ((comma ? 2 : 0)
861 + (ld_options[j].control == TWO_DASHES ? 1 : 0)
862 + strlen (ld_options[j].opt.name));
863 if (ld_options[j].arg != NULL)
865 printf (" %s", ld_options[j].arg);
866 len += 1 + strlen (ld_options[j].arg);
872 while (j < OPTION_COUNT && ld_options[j].doc == NULL);
880 for (; len < 30; len++)
883 printf ("%s\n", ld_options[i].doc);
887 printf ("%s: supported targets:", program_name);
888 targets = bfd_target_list ();
889 for (pp = targets; *pp != NULL; pp++)
894 printf ("%s: supported emulations: ", program_name);
895 ldemul_list_emulations (stdout);
897 printf ("\nReport bugs to bug-gnu-utils@prep.ai.mit.edu\n");