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. */
38 /* Somewhere above, sys/stat.h got included . . . . */
39 #if !defined(S_ISDIR) && defined(S_IFDIR)
40 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
43 /* Omit args to avoid the possibility of clashing with a system header
44 that might disagree about consts. */
45 unsigned long strtoul ();
47 static void set_default_dirlist
PARAMS ((char *dirlist_ptr
));
48 static void set_section_start
PARAMS ((char *sect
, char *valstr
));
49 static void help
PARAMS ((void));
51 /* Non-zero if we are processing a --defsym from the command line. */
52 int parsing_defsym
= 0;
54 /* Codes used for the long options with no short synonyms. 150 isn't
55 special; it's just an arbitrary non-ASCII char value. */
57 #define OPTION_ASSERT 150
58 #define OPTION_CALL_SHARED (OPTION_ASSERT + 1)
59 #define OPTION_DEFSYM (OPTION_CALL_SHARED + 1)
60 #define OPTION_DYNAMIC_LINKER (OPTION_DEFSYM + 1)
61 #define OPTION_EB (OPTION_DYNAMIC_LINKER + 1)
62 #define OPTION_EL (OPTION_EB + 1)
63 #define OPTION_EMBEDDED_RELOCS (OPTION_EL + 1)
64 #define OPTION_EXPORT_DYNAMIC (OPTION_EMBEDDED_RELOCS + 1)
65 #define OPTION_HELP (OPTION_EXPORT_DYNAMIC + 1)
66 #define OPTION_IGNORE (OPTION_HELP + 1)
67 #define OPTION_MAP (OPTION_IGNORE + 1)
68 #define OPTION_NO_KEEP_MEMORY (OPTION_MAP + 1)
69 #define OPTION_NOINHIBIT_EXEC (OPTION_NO_KEEP_MEMORY + 1)
70 #define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1)
71 #define OPTION_NO_WHOLE_ARCHIVE (OPTION_NON_SHARED + 1)
72 #define OPTION_OFORMAT (OPTION_NO_WHOLE_ARCHIVE + 1)
73 #define OPTION_RELAX (OPTION_OFORMAT + 1)
74 #define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1)
75 #define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1)
76 #define OPTION_RPATH_LINK (OPTION_RPATH + 1)
77 #define OPTION_SHARED (OPTION_RPATH_LINK + 1)
78 #define OPTION_SONAME (OPTION_SHARED + 1)
79 #define OPTION_SORT_COMMON (OPTION_SONAME + 1)
80 #define OPTION_STATS (OPTION_SORT_COMMON + 1)
81 #define OPTION_SYMBOLIC (OPTION_STATS + 1)
82 #define OPTION_TBSS (OPTION_SYMBOLIC + 1)
83 #define OPTION_TDATA (OPTION_TBSS + 1)
84 #define OPTION_TTEXT (OPTION_TDATA + 1)
85 #define OPTION_TRADITIONAL_FORMAT (OPTION_TTEXT + 1)
86 #define OPTION_UR (OPTION_TRADITIONAL_FORMAT + 1)
87 #define OPTION_VERBOSE (OPTION_UR + 1)
88 #define OPTION_VERSION (OPTION_VERBOSE + 1)
89 #define OPTION_WARN_COMMON (OPTION_VERSION + 1)
90 #define OPTION_WARN_CONSTRUCTORS (OPTION_WARN_COMMON + 1)
91 #define OPTION_WARN_MULTIPLE_GP (OPTION_WARN_CONSTRUCTORS + 1)
92 #define OPTION_WARN_ONCE (OPTION_WARN_MULTIPLE_GP + 1)
93 #define OPTION_SPLIT_BY_RELOC (OPTION_WARN_ONCE + 1)
94 #define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1)
95 #define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
96 #define OPTION_WRAP (OPTION_WHOLE_ARCHIVE + 1)
98 /* The long options. This structure is used for both the option
99 parsing and the help text. */
103 /* The long option information. */
105 /* The short option with the same meaning ('\0' if none). */
107 /* The name of the argument (NULL if none). */
109 /* The documentation string. If this is NULL, this is a synonym for
110 the previous option. */
114 /* Use one dash before long option name. */
116 /* Use two dashes before long option name. */
118 /* Don't mention this option in --help output. */
123 static const struct ld_option ld_options
[] =
125 { {NULL
, required_argument
, NULL
, '\0'},
126 'a', "KEYWORD", "Shared library control for HP/UX compatibility",
128 { {"architecture", required_argument
, NULL
, 'A'},
129 'A', "ARCH", "Set architecture" , TWO_DASHES
},
130 { {"format", required_argument
, NULL
, 'b'},
131 'b', "TARGET", "Specify target for following input files", TWO_DASHES
},
132 { {"mri-script", required_argument
, NULL
, 'c'},
133 'c', "FILE", "Read MRI format linker script", TWO_DASHES
},
134 { {"dc", no_argument
, NULL
, 'd'},
135 'd', NULL
, "Force common symbols to be defined", ONE_DASH
},
136 { {"dp", no_argument
, NULL
, 'd'},
137 '\0', NULL
, NULL
, ONE_DASH
},
138 { {"entry", required_argument
, NULL
, 'e'},
139 'e', "ADDRESS", "Set start address", TWO_DASHES
},
140 { {"export-dynamic", no_argument
, NULL
, OPTION_EXPORT_DYNAMIC
},
141 'E', NULL
, "Export all dynamic symbols", TWO_DASHES
},
142 { {NULL
, no_argument
, NULL
, '\0'},
143 'F', NULL
, "Ignored", ONE_DASH
},
144 { {"gpsize", required_argument
, NULL
, 'G'},
145 'G', "SIZE", "Small data size (if no size, same as --shared)",
147 { {NULL
, no_argument
, NULL
, '\0'},
148 'g', NULL
, "Ignored", ONE_DASH
},
149 { {"soname", required_argument
, NULL
, OPTION_SONAME
},
150 'h', "FILENAME", "Set internal name of shared library", ONE_DASH
},
151 { {"library", required_argument
, NULL
, 'l'},
152 'l', "LIBNAME", "Search for library LIBNAME", TWO_DASHES
},
153 { {"library-path", required_argument
, NULL
, 'L'},
154 'L', "DIRECTORY", "Add DIRECTORY to library search path", TWO_DASHES
},
155 { {NULL
, required_argument
, NULL
, '\0'},
156 'm', "EMULATION", "Set emulation", ONE_DASH
},
157 { {"print-map", no_argument
, NULL
, 'M'},
158 'M', NULL
, "Print map file on standard output", TWO_DASHES
},
159 { {"nmagic", no_argument
, NULL
, 'n'},
160 'n', NULL
, "Do not page align data", TWO_DASHES
},
161 { {"omagic", no_argument
, NULL
, 'N'},
162 'N', NULL
, "Do not page align data, do not make text readonly",
164 { {"output", required_argument
, NULL
, 'o'},
165 'o', "FILE", "Set output file name", TWO_DASHES
},
166 { {NULL
, required_argument
, NULL
, '\0'},
167 'O', NULL
, "Ignored", ONE_DASH
},
168 { {"relocateable", no_argument
, NULL
, 'r'},
169 'r', NULL
, "Generate relocateable output", TWO_DASHES
},
170 { {NULL
, no_argument
, NULL
, '\0'},
171 'i', NULL
, NULL
, ONE_DASH
},
172 { {"just-symbols", required_argument
, NULL
, 'R'},
173 'R', "FILE", "Just link symbols (if directory, same as --rpath)",
175 { {"strip-all", no_argument
, NULL
, 's'},
176 's', NULL
, "Strip all symbols", TWO_DASHES
},
177 { {"strip-debug", no_argument
, NULL
, 'S'},
178 'S', NULL
, "Strip debugging symbols", TWO_DASHES
},
179 { {"trace", no_argument
, NULL
, 't'},
180 't', NULL
, "Trace file opens", TWO_DASHES
},
181 { {"script", required_argument
, NULL
, 'T'},
182 'T', "FILE", "Read linker script", TWO_DASHES
},
183 { {"undefined", required_argument
, NULL
, 'u'},
184 'u', "SYMBOL", "Start with undefined reference to SYMBOL", TWO_DASHES
},
185 { {"version", no_argument
, NULL
, OPTION_VERSION
},
186 'v', NULL
, "Print version information", TWO_DASHES
},
187 { {NULL
, no_argument
, NULL
, '\0'},
188 'V', NULL
, "Print version and emulation information", ONE_DASH
},
189 { {"discard-all", no_argument
, NULL
, 'x'},
190 'x', NULL
, "Discard all local symbols", TWO_DASHES
},
191 { {"discard-locals", no_argument
, NULL
, 'X'},
192 'X', NULL
, "Discard temporary local symbols", TWO_DASHES
},
193 { {"trace-symbol", required_argument
, NULL
, 'y'},
194 'y', "SYMBOL", "Trace mentions of SYMBOL", TWO_DASHES
},
195 { {NULL
, required_argument
, NULL
, '\0'},
196 'Y', "PATH", "Default search path for Solaris compatibility", ONE_DASH
},
197 { {NULL
, required_argument
, NULL
, '\0'},
198 'z', "KEYWORD", "Ignored for Solaris compatibility", ONE_DASH
},
199 { {"start-group", no_argument
, NULL
, '('},
200 '(', NULL
, "Start a group", TWO_DASHES
},
201 { {"end-group", no_argument
, NULL
, ')'},
202 ')', NULL
, "End a group", TWO_DASHES
},
203 { {"assert", required_argument
, NULL
, OPTION_ASSERT
},
204 '\0', "KEYWORD", "Ignored for SunOS compatibility", ONE_DASH
},
205 { {"Bdynamic", no_argument
, NULL
, OPTION_CALL_SHARED
},
206 '\0', NULL
, "Link against shared libraries", ONE_DASH
},
207 { {"call_shared", no_argument
, NULL
, OPTION_CALL_SHARED
},
208 '\0', NULL
, NULL
, ONE_DASH
},
209 { {"dy", no_argument
, NULL
, OPTION_CALL_SHARED
},
210 '\0', NULL
, NULL
, ONE_DASH
},
211 { {"Bstatic", no_argument
, NULL
, OPTION_NON_SHARED
},
212 '\0', NULL
, "Do not link against shared libraries", ONE_DASH
},
213 { {"dn", no_argument
, NULL
, OPTION_NON_SHARED
},
214 '\0', NULL
, NULL
, ONE_DASH
},
215 { {"non_shared", no_argument
, NULL
, OPTION_NON_SHARED
},
216 '\0', NULL
, NULL
, ONE_DASH
},
217 { {"static", no_argument
, NULL
, OPTION_NON_SHARED
},
218 '\0', NULL
, NULL
, ONE_DASH
},
219 { {"Bsymbolic", no_argument
, NULL
, OPTION_SYMBOLIC
},
220 '\0', NULL
, "Bind global references locally", ONE_DASH
},
221 { {"defsym", required_argument
, NULL
, OPTION_DEFSYM
},
222 '\0', "SYMBOL=EXPRESSION", "Define a symbol", TWO_DASHES
},
223 { {"dynamic-linker", required_argument
, NULL
, OPTION_DYNAMIC_LINKER
},
224 '\0', "PROGRAM", "Set the dynamic linker to use", TWO_DASHES
},
225 { {"EB", no_argument
, NULL
, OPTION_EB
},
226 '\0', NULL
, "Link big-endian objects", ONE_DASH
},
227 { {"EL", no_argument
, NULL
, OPTION_EL
},
228 '\0', NULL
, "Link little-endian objects", ONE_DASH
},
229 { {"embedded-relocs", no_argument
, NULL
, OPTION_EMBEDDED_RELOCS
},
230 '\0', NULL
, "Generate embedded relocs", TWO_DASHES
},
231 { {"help", no_argument
, NULL
, OPTION_HELP
},
232 '\0', NULL
, "Print option help", TWO_DASHES
},
233 { {"Map", required_argument
, NULL
, OPTION_MAP
},
234 '\0', "FILE", "Write a map file", ONE_DASH
},
235 { {"no-keep-memory", no_argument
, NULL
, OPTION_NO_KEEP_MEMORY
},
236 '\0', NULL
, "Use less memory and more disk I/O", TWO_DASHES
},
237 { {"no-whole-archive", no_argument
, NULL
, OPTION_NO_WHOLE_ARCHIVE
},
238 '\0', NULL
, "Turn off --whole-archive", TWO_DASHES
},
239 { {"noinhibit-exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
240 '\0', NULL
, "Create an output file even if errors occur", TWO_DASHES
},
241 { {"noinhibit_exec", no_argument
, NULL
, OPTION_NOINHIBIT_EXEC
},
242 '\0', NULL
, NULL
, NO_HELP
},
243 { {"oformat", required_argument
, NULL
, OPTION_OFORMAT
},
244 '\0', "TARGET", "Specify target of output file", TWO_DASHES
},
245 { {"qmagic", no_argument
, NULL
, OPTION_IGNORE
},
246 '\0', NULL
, "Ignored for Linux compatibility", ONE_DASH
},
247 { {"Qy", no_argument
, NULL
, OPTION_IGNORE
},
248 '\0', NULL
, "Ignored for SVR4 compatibility", ONE_DASH
},
249 { {"relax", no_argument
, NULL
, OPTION_RELAX
},
250 '\0', NULL
, "Relax branches on certain targets", TWO_DASHES
},
251 { {"retain-symbols-file", required_argument
, NULL
,
252 OPTION_RETAIN_SYMBOLS_FILE
},
253 '\0', "FILE", "Keep only symbols listed in FILE", TWO_DASHES
},
254 { {"rpath", required_argument
, NULL
, OPTION_RPATH
},
255 '\0', "PATH", "Set runtime shared library search path", ONE_DASH
},
256 { {"rpath-link", required_argument
, NULL
, OPTION_RPATH_LINK
},
257 '\0', "PATH", "Set line time shared library search path", ONE_DASH
},
258 { {"shared", no_argument
, NULL
, OPTION_SHARED
},
259 '\0', NULL
, "Create a shared library", ONE_DASH
},
260 { {"Bshareable", no_argument
, NULL
, OPTION_SHARED
}, /* FreeBSD. */
261 '\0', NULL
, NULL
, ONE_DASH
},
262 { {"sort-common", no_argument
, NULL
, OPTION_SORT_COMMON
},
263 '\0', NULL
, "Sort common symbols by size", TWO_DASHES
},
264 { {"sort_common", no_argument
, NULL
, OPTION_SORT_COMMON
},
265 '\0', NULL
, NULL
, NO_HELP
},
266 { {"split-by-file", no_argument
, NULL
, OPTION_SPLIT_BY_FILE
},
267 '\0', NULL
, "Split output sections for each file", TWO_DASHES
},
268 { {"split-by-reloc", required_argument
, NULL
, OPTION_SPLIT_BY_RELOC
},
269 '\0', "COUNT", "Split output sections every COUNT relocs", TWO_DASHES
},
270 { {"stats", no_argument
, NULL
, OPTION_STATS
},
271 '\0', NULL
, "Print memory usage statistics", TWO_DASHES
},
272 { {"traditional-format", no_argument
, NULL
, OPTION_TRADITIONAL_FORMAT
},
273 '\0', NULL
, "Use same format as native linker", TWO_DASHES
},
274 { {"Tbss", required_argument
, NULL
, OPTION_TBSS
},
275 '\0', "ADDRESS", "Set address of .bss section", ONE_DASH
},
276 { {"Tdata", required_argument
, NULL
, OPTION_TDATA
},
277 '\0', "ADDRESS", "Set address of .data section", ONE_DASH
},
278 { {"Ttext", required_argument
, NULL
, OPTION_TTEXT
},
279 '\0', "ADDRESS", "Set address of .text section", ONE_DASH
},
280 { {"Ur", no_argument
, NULL
, OPTION_UR
},
281 '\0', NULL
, "Build global constructor/destructor tables", ONE_DASH
},
282 { {"verbose", no_argument
, NULL
, OPTION_VERBOSE
},
283 '\0', NULL
, "Output lots of information during link", TWO_DASHES
},
284 { {"dll-verbose", no_argument
, NULL
, OPTION_VERSION
}, /* Linux. */
285 '\0', NULL
, NULL
, NO_HELP
},
286 { {"warn-common", no_argument
, NULL
, OPTION_WARN_COMMON
},
287 '\0', NULL
, "Warn about duplicate common symbols", TWO_DASHES
},
288 { {"warn-constructors", no_argument
, NULL
, OPTION_WARN_CONSTRUCTORS
},
289 '\0', NULL
, "Warn if global constructors/destructors are seen",
291 { {"warn-multiple-gp", no_argument
, NULL
, OPTION_WARN_MULTIPLE_GP
},
292 '\0', NULL
, "Warn if the multiple GP values are used", TWO_DASHES
},
293 { {"warn-once", no_argument
, NULL
, OPTION_WARN_ONCE
},
294 '\0', NULL
, "Warn only once per undefined symbol", TWO_DASHES
},
295 { {"whole-archive", no_argument
, NULL
, OPTION_WHOLE_ARCHIVE
},
296 '\0', NULL
, "Include all objects from following archives", TWO_DASHES
},
297 { {"wrap", required_argument
, NULL
, OPTION_WRAP
},
298 '\0', "SYMBOL", "Use wrapper functions for SYMBOL", TWO_DASHES
}
301 #define OPTION_COUNT (sizeof ld_options / sizeof ld_options[0])
304 parse_args (argc
, argv
)
310 char *default_dirlist
= NULL
;
311 char shortopts
[OPTION_COUNT
* 2 + 2];
312 struct option longopts
[OPTION_COUNT
+ 1];
314 /* Starting the short option string with '-' is for programs that
315 expect options and other ARGV-elements in any order and that care about
316 the ordering of the two. We describe each non-option ARGV-element
317 as if it were the argument of an option with character code 1. */
321 for (i
= 0; i
< OPTION_COUNT
; i
++)
323 if (ld_options
[i
].shortopt
!= '\0')
325 shortopts
[is
] = ld_options
[i
].shortopt
;
327 if (ld_options
[i
].opt
.has_arg
== required_argument
)
333 if (ld_options
[i
].opt
.name
!= NULL
)
335 longopts
[il
] = ld_options
[i
].opt
;
339 shortopts
[is
] = '\0';
340 longopts
[il
].name
= NULL
;
342 /* The -G option is ambiguous on different platforms. Sometimes it
343 specifies the largest data size to put into the small data
344 section. Sometimes it is equivalent to --shared. Unfortunately,
345 the first form takes an argument, while the second does not.
347 We need to permit the --shared form because on some platforms,
348 such as Solaris, gcc -shared will pass -G to the linker.
350 To permit either usage, we look through the argument list. If we
351 find -G not followed by a number, we change it into --shared.
352 This will work for most normal cases. */
353 for (i
= 1; i
< argc
; i
++)
354 if (strcmp (argv
[i
], "-G") == 0
356 || ! isdigit (argv
[i
+ 1][0])))
357 argv
[i
] = (char *) "--shared";
361 /* getopt_long_only is like getopt_long, but '-' as well as '--' can
362 indicate a long option. */
366 if (ldemul_parse_args (argc
, argv
))
369 optc
= getopt_long_only (argc
, argv
, shortopts
, longopts
, &longind
);
377 case 1: /* File name. */
378 lang_add_input_file (optarg
, lang_input_file_is_file_enum
,
385 /* For HP/UX compatibility. Actually -a shared should mean
386 ``use only shared libraries'' but, then, we don't
387 currently support shared libraries on HP/UX anyhow. */
388 if (strcmp (optarg
, "archive") == 0)
389 config
.dynamic_link
= false;
390 else if (strcmp (optarg
, "shared") == 0
391 || strcmp (optarg
, "default") == 0)
392 config
.dynamic_link
= true;
394 einfo ("%P%F: unrecognized -a option `%s'\n", optarg
);
397 /* FIXME: We just ignore these, but we should handle them. */
398 if (strcmp (optarg
, "definitions") == 0)
400 else if (strcmp (optarg
, "nodefinitions") == 0)
402 else if (strcmp (optarg
, "nosymbolic") == 0)
404 else if (strcmp (optarg
, "pure-text") == 0)
407 einfo ("%P%F: unrecognized -assert option `%s'\n", optarg
);
410 ldfile_add_arch (optarg
);
413 lang_add_target (optarg
);
416 ldfile_open_command_file (optarg
);
417 parser_input
= input_mri_script
;
420 case OPTION_CALL_SHARED
:
421 config
.dynamic_link
= true;
423 case OPTION_NON_SHARED
:
424 config
.dynamic_link
= false;
427 command_line
.force_common_definition
= true;
431 lex_redirect (optarg
);
432 parser_input
= input_defsym
;
438 case OPTION_DYNAMIC_LINKER
:
439 command_line
.interpreter
= optarg
;
442 command_line
.endian
= ENDIAN_BIG
;
445 command_line
.endian
= ENDIAN_LITTLE
;
447 case OPTION_EMBEDDED_RELOCS
:
448 command_line
.embedded_relocs
= true;
450 case OPTION_EXPORT_DYNAMIC
:
451 case 'E': /* HP/UX compatibility. */
452 command_line
.export_dynamic
= true;
455 lang_add_entry (optarg
, true);
463 g_switch_value
= strtoul (optarg
, &end
, 0);
465 einfo ("%P%F: invalid number `%s'\n", optarg
);
476 ldfile_add_library_path (optarg
, true);
479 lang_add_input_file (optarg
, lang_input_file_is_l_enum
,
483 config
.map_filename
= "-";
486 /* Ignore. Was handled in a pre-parse. */
489 config
.map_filename
= optarg
;
492 config
.text_read_only
= false;
493 config
.magic_demand_paged
= false;
494 config
.dynamic_link
= false;
497 config
.magic_demand_paged
= false;
498 config
.dynamic_link
= false;
500 case OPTION_NO_KEEP_MEMORY
:
501 link_info
.keep_memory
= false;
503 case OPTION_NOINHIBIT_EXEC
:
504 force_make_executable
= true;
506 case OPTION_NO_WHOLE_ARCHIVE
:
507 whole_archive
= false;
510 /* FIXME "-O<non-digits> <value>" used to set the address of
511 section <non-digits>. Was this for compatibility with
512 something, or can we create a new option to do that
513 (with a syntax similar to -defsym)?
514 getopt can't handle two args to an option without kludges. */
517 lang_add_output (optarg
, 0);
520 lang_add_output_format (optarg
, (char *) NULL
, (char *) NULL
, 0);
524 link_info
.relocateable
= true;
525 config
.build_constructors
= false;
526 config
.magic_demand_paged
= false;
527 config
.text_read_only
= false;
528 config
.dynamic_link
= false;
531 /* The GNU linker traditionally uses -R to mean to include
532 only the symbols from a file. The Solaris linker uses -R
533 to set the path used by the runtime linker to find
534 libraries. This is the GNU linker -rpath argument. We
535 try to support both simultaneously by checking the file
536 named. If it is a directory, rather than a regular file,
537 we assume -rpath was meant. */
541 if (stat (optarg
, &s
) >= 0
542 && ! S_ISDIR (s
.st_mode
))
544 lang_add_input_file (optarg
,
545 lang_input_file_is_symbols_only_enum
,
552 if (command_line
.rpath
== NULL
)
553 command_line
.rpath
= buystring (optarg
);
558 buf
= xmalloc (strlen (command_line
.rpath
)
561 sprintf (buf
, "%s:%s", command_line
.rpath
, optarg
);
562 free (command_line
.rpath
);
563 command_line
.rpath
= buf
;
566 case OPTION_RPATH_LINK
:
567 if (command_line
.rpath_link
== NULL
)
568 command_line
.rpath_link
= buystring (optarg
);
573 buf
= xmalloc (strlen (command_line
.rpath_link
)
576 sprintf (buf
, "%s:%s", command_line
.rpath_link
, optarg
);
577 free (command_line
.rpath_link
);
578 command_line
.rpath_link
= buf
;
582 command_line
.relax
= true;
584 case OPTION_RETAIN_SYMBOLS_FILE
:
585 add_keepsyms_file (optarg
);
588 link_info
.strip
= strip_debugger
;
591 link_info
.strip
= strip_all
;
594 link_info
.shared
= true;
596 case 'h': /* Used on Solaris. */
598 command_line
.soname
= optarg
;
600 case OPTION_SORT_COMMON
:
601 config
.sort_common
= true;
606 case OPTION_SYMBOLIC
:
607 link_info
.symbolic
= true;
613 ldfile_open_command_file (optarg
);
614 parser_input
= input_script
;
618 set_section_start (".bss", optarg
);
621 set_section_start (".data", optarg
);
624 set_section_start (".text", optarg
);
626 case OPTION_TRADITIONAL_FORMAT
:
627 config
.traditional_format
= true;
630 link_info
.relocateable
= true;
631 config
.build_constructors
= true;
632 config
.magic_demand_paged
= false;
633 config
.text_read_only
= false;
634 config
.dynamic_link
= false;
637 ldlang_add_undef (optarg
);
641 version_printed
= true;
642 trace_file_tries
= true;
646 version_printed
= true;
650 version_printed
= true;
654 version_printed
= true;
656 case OPTION_WARN_COMMON
:
657 config
.warn_common
= true;
659 case OPTION_WARN_CONSTRUCTORS
:
660 config
.warn_constructors
= true;
662 case OPTION_WARN_MULTIPLE_GP
:
663 config
.warn_multiple_gp
= true;
665 case OPTION_WARN_ONCE
:
666 config
.warn_once
= true;
668 case OPTION_WHOLE_ARCHIVE
:
669 whole_archive
= true;
675 link_info
.discard
= discard_l
;
678 link_info
.discard
= discard_all
;
681 if (strncmp (optarg
, "P,", 2) == 0)
683 default_dirlist
= optarg
;
689 /* We accept and ignore this option for Solaris
690 compatibility. Actually, on Solaris, optarg is not
691 ignored. Someday we should handle it correctly. FIXME. */
693 case OPTION_SPLIT_BY_RELOC
:
694 config
.split_by_reloc
= atoi (optarg
);
696 case OPTION_SPLIT_BY_FILE
:
697 config
.split_by_file
= true;
703 "%s: may not nest groups (--help for usage)\n",
714 "%s: group ended before it began (--help for usage)\n",
728 if (default_dirlist
!= NULL
)
729 set_default_dirlist (default_dirlist
);
733 /* Add the (colon-separated) elements of DIRLIST_PTR to the
734 library search path. */
737 set_default_dirlist (dirlist_ptr
)
744 p
= strchr (dirlist_ptr
, ':');
748 ldfile_add_library_path (dirlist_ptr
, true);
757 set_section_start (sect
, valstr
)
761 unsigned long val
= strtoul (valstr
, &end
, 16);
763 einfo ("%P%F: invalid hex number `%s'\n", valstr
);
764 lang_section_start (sect
, exp_intop (val
));
767 /* Print help messages for the options. */
773 const char **targets
, **pp
;
775 printf ("Usage: %s [options] file...\n", program_name
);
777 printf ("Options:\n");
778 for (i
= 0; i
< OPTION_COUNT
; i
++)
780 if (ld_options
[i
].doc
!= NULL
)
794 if (ld_options
[j
].shortopt
!= '\0'
795 && ld_options
[j
].control
!= NO_HELP
)
797 printf ("%s-%c", comma
? ", " : "", ld_options
[j
].shortopt
);
798 len
+= (comma
? 2 : 0) + 2;
799 if (ld_options
[j
].arg
!= NULL
)
801 printf (" %s", ld_options
[j
].arg
);
802 len
+= 1 + strlen (ld_options
[j
].arg
);
808 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
813 if (ld_options
[j
].opt
.name
!= NULL
814 && ld_options
[j
].control
!= NO_HELP
)
818 ld_options
[j
].control
== TWO_DASHES
? "-" : "",
819 ld_options
[j
].opt
.name
);
820 len
+= ((comma
? 2 : 0)
822 + (ld_options
[j
].control
== TWO_DASHES
? 1 : 0)
823 + strlen (ld_options
[j
].opt
.name
));
824 if (ld_options
[j
].arg
!= NULL
)
826 printf (" %s", ld_options
[j
].arg
);
827 len
+= 1 + strlen (ld_options
[j
].arg
);
833 while (j
< OPTION_COUNT
&& ld_options
[j
].doc
== NULL
);
841 for (; len
< 30; len
++)
844 printf ("%s\n", ld_options
[i
].doc
);
848 printf ("%s: supported targets:", program_name
);
849 targets
= bfd_target_list ();
850 for (pp
= targets
; *pp
!= NULL
; pp
++)
855 printf ("%s: supported emulations: ", program_name
);
856 ldemul_list_emulations (stdout
);