Implement -Bstatic/-Bdynamic.
[deliverable/binutils-gdb.git] / gold / options.cc
1 // options.c -- handle command line options for gold
2
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
5
6 // This file is part of gold.
7
8 // This program 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 3 of the License, or
11 // (at your option) any later version.
12
13 // This program 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.
17
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
22
23 #include "gold.h"
24
25 #include <iostream>
26 #include <sys/stat.h>
27 #include "filenames.h"
28 #include "libiberty.h"
29
30 #include "options.h"
31
32 namespace gold
33 {
34
35 // The information we keep for a single command line option.
36
37 struct options::One_option
38 {
39 // The single character option name, or '\0' if this is only a long
40 // option.
41 char short_option;
42
43 // The long option name, or NULL if this is only a short option.
44 const char* long_option;
45
46 // Description of the option for --help output, or NULL if there is none.
47 const char* doc;
48
49 // How to print the option name in --help output, or NULL to use the
50 // default.
51 const char* help_output;
52
53 // Long option dash control. This is ignored if long_option is
54 // NULL.
55 enum
56 {
57 // Long option normally takes one dash; two dashes are also
58 // accepted.
59 ONE_DASH,
60 // Long option normally takes two dashes; one dash is also
61 // accepted.
62 TWO_DASHES,
63 // Long option always takes two dashes.
64 EXACTLY_TWO_DASHES
65 } dash;
66
67 // Function for special handling, or NULL. Returns the number of
68 // arguments to skip. This will normally be at least 1, but it may
69 // be 0 if this function changes *argv. ARG points to the location
70 // in *ARGV where the option starts, which may be helpful for a
71 // short option.
72 int (*special)(int argc, char** argv, char *arg, Command_line*);
73
74 // If this is a position independent option which does not take an
75 // argument, this is the member function to call to record it.
76 void (General_options::*general_noarg)();
77
78 // If this is a position independent function which takes an
79 // argument, this is the member function to call to record it.
80 void (General_options::*general_arg)(const char*);
81
82 // If this is a position dependent option which does not take an
83 // argument, this is the member function to call to record it.
84 void (Position_dependent_options::*dependent_noarg)();
85
86 // If this is a position dependent option which takes an argument,
87 // this is the member function to record it.
88 void (Position_dependent_options::*dependent_arg)(const char*);
89
90 // Return whether this option takes an argument.
91 bool
92 takes_argument() const
93 { return this->general_arg != NULL || this->dependent_arg != NULL; }
94 };
95
96 class options::Command_line_options
97 {
98 public:
99 static const One_option options[];
100 static const int options_size;
101 };
102
103 } // End namespace gold.
104
105 namespace
106 {
107
108 // Handle the special -l option, which adds an input file.
109
110 int
111 library(int argc, char** argv, char* arg, gold::Command_line* cmdline)
112 {
113 return cmdline->process_l_option(argc, argv, arg);
114 }
115
116 // Handle the special --start-group option.
117
118 int
119 start_group(int, char**, char* arg, gold::Command_line* cmdline)
120 {
121 cmdline->start_group(arg);
122 return 1;
123 }
124
125 // Handle the special --end-group option.
126
127 int
128 end_group(int, char**, char* arg, gold::Command_line* cmdline)
129 {
130 cmdline->end_group(arg);
131 return 1;
132 }
133
134 // Report usage information for ld --help, and exit.
135
136 int
137 help(int, char**, char*, gold::Command_line*)
138 {
139 printf(_("Usage: %s [options] file...\nOptions:\n"), gold::program_name);
140
141 const int options_size = gold::options::Command_line_options::options_size;
142 const gold::options::One_option* options =
143 gold::options::Command_line_options::options;
144 for (int i = 0; i < options_size; ++i)
145 {
146 if (options[i].doc == NULL)
147 continue;
148
149 printf(" ");
150 int len = 2;
151 bool comma = false;
152
153 int j = i;
154 do
155 {
156 if (options[j].help_output != NULL)
157 {
158 if (comma)
159 {
160 printf(", ");
161 len += 2;
162 }
163 printf(options[j].help_output);
164 len += std::strlen(options[i].help_output);
165 comma = true;
166 }
167 else
168 {
169 if (options[j].short_option != '\0')
170 {
171 if (comma)
172 {
173 printf(", ");
174 len += 2;
175 }
176 printf("-%c", options[j].short_option);
177 len += 2;
178 comma = true;
179 }
180
181 if (options[j].long_option != NULL)
182 {
183 if (comma)
184 {
185 printf(", ");
186 len += 2;
187 }
188 if (options[j].dash == gold::options::One_option::ONE_DASH)
189 {
190 printf("-");
191 ++len;
192 }
193 else
194 {
195 printf("--");
196 len += 2;
197 }
198 printf("%s", options[j].long_option);
199 len += std::strlen(options[j].long_option);
200 comma = true;
201 }
202 }
203 ++j;
204 }
205 while (j < options_size && options[j].doc == NULL);
206
207 if (len >= 30)
208 {
209 printf("\n");
210 len = 0;
211 }
212 for (; len < 30; ++len)
213 std::putchar(' ');
214
215 std::puts(options[i].doc);
216 }
217
218 ::exit(0);
219
220 return 0;
221 }
222
223 // Report version information.
224
225 int
226 version(int, char**, char* opt, gold::Command_line*)
227 {
228 gold::print_version(opt[0] == 'v' && opt[1] == '\0');
229 ::exit(0);
230 return 0;
231 }
232
233 // If the default sysroot is relocatable, try relocating it based on
234 // the prefix FROM.
235
236 char*
237 get_relative_sysroot(const char* from)
238 {
239 char* path = make_relative_prefix(gold::program_name, from,
240 TARGET_SYSTEM_ROOT);
241 if (path != NULL)
242 {
243 struct stat s;
244 if (::stat(path, &s) == 0 && S_ISDIR(s.st_mode))
245 return path;
246 free(path);
247 }
248
249 return NULL;
250 }
251
252 // Return the default sysroot. This is set by the --with-sysroot
253 // option to configure.
254
255 std::string
256 get_default_sysroot()
257 {
258 const char* sysroot = TARGET_SYSTEM_ROOT;
259 if (*sysroot == '\0')
260 return "";
261
262 if (TARGET_SYSTEM_ROOT_RELOCATABLE)
263 {
264 char* path = get_relative_sysroot (BINDIR);
265 if (path == NULL)
266 path = get_relative_sysroot (TOOLBINDIR);
267 if (path != NULL)
268 {
269 std::string ret = path;
270 free(path);
271 return ret;
272 }
273 }
274
275 return sysroot;
276 }
277
278 } // End anonymous namespace.
279
280 namespace gold
281 {
282
283 // Helper macros used to specify the options. We could also do this
284 // using constructors, but then g++ would generate code to initialize
285 // the array. We want the array to be initialized statically so that
286 // we get better startup time.
287
288 #define GENERAL_NOARG(short_option, long_option, doc, help, dash, func) \
289 { short_option, long_option, doc, help, options::One_option::dash, \
290 NULL, func, NULL, NULL, NULL }
291 #define GENERAL_ARG(short_option, long_option, doc, help, dash, func) \
292 { short_option, long_option, doc, help, options::One_option::dash, \
293 NULL, NULL, func, NULL, NULL }
294 #define POSDEP_NOARG(short_option, long_option, doc, help, dash, func) \
295 { short_option, long_option, doc, help, options::One_option::dash, \
296 NULL, NULL, NULL, func, NULL }
297 #define POSDEP_ARG(short_option, long_option, doc, help, dash, func) \
298 { short_option, long_option, doc, help, options::One_option::dash, \
299 NULL, NULL, NULL, NULL, func }
300 #define SPECIAL(short_option, long_option, doc, help, dash, func) \
301 { short_option, long_option, doc, help, options::One_option::dash, \
302 func, NULL, NULL, NULL, NULL }
303
304 // Here is the actual list of options which we accept.
305
306 const options::One_option
307 options::Command_line_options::options[] =
308 {
309 POSDEP_NOARG('\0', "as-needed",
310 N_("Only set DT_NEEDED for dynamic libs if used"),
311 NULL, TWO_DASHES, &Position_dependent_options::set_as_needed),
312 POSDEP_NOARG('\0', "no-as-needed",
313 N_("Always DT_NEEDED for dynamic libs (default)"),
314 NULL, TWO_DASHES, &Position_dependent_options::clear_as_needed),
315 POSDEP_NOARG('\0', "Bdynamic",
316 N_("-l searches for shared libraries"),
317 NULL, ONE_DASH,
318 &Position_dependent_options::set_dynamic_search),
319 POSDEP_NOARG('\0', "Bstatic",
320 N_("-l does not search for shared libraries"),
321 NULL, ONE_DASH,
322 &Position_dependent_options::set_static_search),
323 GENERAL_NOARG('\0', "Bsymbolic", N_("Bind defined symbols locally"),
324 NULL, ONE_DASH, &General_options::set_symbolic),
325 GENERAL_NOARG('E', "export-dynamic", N_("Export all dynamic symbols"),
326 NULL, TWO_DASHES, &General_options::set_export_dynamic),
327 GENERAL_NOARG('\0', "eh-frame-hdr", N_("Create exception frame header"),
328 NULL, TWO_DASHES, &General_options::set_create_eh_frame_hdr),
329 GENERAL_ARG('I', "dynamic-linker", N_("Set dynamic linker path"),
330 N_("-I PROGRAM, --dynamic-linker PROGRAM"), TWO_DASHES,
331 &General_options::set_dynamic_linker),
332 SPECIAL('l', "library", N_("Search for library LIBNAME"),
333 N_("-lLIBNAME, --library LIBNAME"), TWO_DASHES,
334 &library),
335 GENERAL_ARG('L', "library-path", N_("Add directory to search path"),
336 N_("-L DIR, --library-path DIR"), TWO_DASHES,
337 &General_options::add_to_search_path),
338 GENERAL_ARG('m', NULL, N_("Ignored for compatibility"), NULL, ONE_DASH,
339 &General_options::ignore),
340 GENERAL_ARG('o', "output", N_("Set output file name"),
341 N_("-o FILE, --output FILE"), TWO_DASHES,
342 &General_options::set_output_file_name),
343 GENERAL_ARG('O', NULL, N_("Optimize output file size"),
344 N_("-O level"), ONE_DASH,
345 &General_options::set_optimization_level),
346 GENERAL_NOARG('r', NULL, N_("Generate relocatable output"), NULL,
347 ONE_DASH, &General_options::set_relocatable),
348 GENERAL_ARG('R', "rpath", N_("Add DIR to runtime search path"),
349 N_("-R DIR, -rpath DIR"), ONE_DASH,
350 &General_options::add_to_rpath),
351 GENERAL_ARG('\0', "rpath-link",
352 N_("Add DIR to link time shared library search path"),
353 N_("--rpath-link DIR"), TWO_DASHES,
354 &General_options::add_to_rpath_link),
355 GENERAL_NOARG('s', "strip-all", N_("Strip all symbols"), NULL,
356 TWO_DASHES, &General_options::set_strip_all),
357 GENERAL_NOARG('S', "strip-debug", N_("Strip debugging information"), NULL,
358 TWO_DASHES, &General_options::set_strip_debug),
359 GENERAL_NOARG('\0', "shared", N_("Generate shared library"),
360 NULL, ONE_DASH, &General_options::set_shared),
361 GENERAL_NOARG('\0', "static", N_("Do not link against shared libraries"),
362 NULL, ONE_DASH, &General_options::set_static),
363 GENERAL_NOARG('\0', "stats", N_("Print resource usage statistics"),
364 NULL, TWO_DASHES, &General_options::set_stats),
365 GENERAL_ARG('\0', "sysroot", N_("Set target system root directory"),
366 N_("--sysroot DIR"), TWO_DASHES, &General_options::set_sysroot),
367 GENERAL_ARG('\0', "Ttext", N_("Set the address of the .text section"),
368 N_("-Ttext ADDRESS"), ONE_DASH,
369 &General_options::set_text_segment_address),
370 GENERAL_NOARG('\0', "threads", N_("Run the linker multi-threaded"),
371 NULL, TWO_DASHES, &General_options::set_threads),
372 GENERAL_NOARG('\0', "no-threads", N_("Do not run the linker multi-threaded"),
373 NULL, TWO_DASHES, &General_options::clear_threads),
374 GENERAL_ARG('\0', "thread-count", N_("Number of threads to use"),
375 N_("--thread-count COUNT"), TWO_DASHES,
376 &General_options::set_thread_count),
377 GENERAL_ARG('\0', "thread-count-initial",
378 N_("Number of threads to use in initial pass"),
379 N_("--thread-count-initial COUNT"), TWO_DASHES,
380 &General_options::set_thread_count_initial),
381 GENERAL_ARG('\0', "thread-count-middle",
382 N_("Number of threads to use in middle pass"),
383 N_("--thread-count-middle COUNT"), TWO_DASHES,
384 &General_options::set_thread_count_middle),
385 GENERAL_ARG('\0', "thread-count-final",
386 N_("Number of threads to use in final pass"),
387 N_("--thread-count-final COUNT"), TWO_DASHES,
388 &General_options::set_thread_count_final),
389 POSDEP_NOARG('\0', "whole-archive",
390 N_("Include all archive contents"),
391 NULL, TWO_DASHES,
392 &Position_dependent_options::set_whole_archive),
393 POSDEP_NOARG('\0', "no-whole-archive",
394 N_("Include only needed archive contents"),
395 NULL, TWO_DASHES,
396 &Position_dependent_options::clear_whole_archive),
397 SPECIAL('(', "start-group", N_("Start a library search group"), NULL,
398 TWO_DASHES, &start_group),
399 SPECIAL(')', "end-group", N_("End a library search group"), NULL,
400 TWO_DASHES, &end_group),
401 SPECIAL('\0', "help", N_("Report usage information"), NULL,
402 TWO_DASHES, &help),
403 SPECIAL('v', "version", N_("Report version information"), NULL,
404 TWO_DASHES, &version)
405 };
406
407 const int options::Command_line_options::options_size =
408 sizeof (options) / sizeof (options[0]);
409
410 // The default values for the general options.
411
412 General_options::General_options()
413 : export_dynamic_(false),
414 dynamic_linker_(NULL),
415 search_path_(),
416 optimization_level_(0),
417 output_file_name_("a.out"),
418 is_relocatable_(false),
419 strip_(STRIP_NONE),
420 symbolic_(false),
421 create_eh_frame_hdr_(false),
422 rpath_(),
423 rpath_link_(),
424 is_shared_(false),
425 is_static_(false),
426 print_stats_(false),
427 sysroot_(),
428 text_segment_address_(-1U), // -1 indicates value not set by user
429 threads_(false),
430 thread_count_initial_(0),
431 thread_count_middle_(0),
432 thread_count_final_(0)
433 {
434 }
435
436 // The default values for the position dependent options.
437
438 Position_dependent_options::Position_dependent_options()
439 : do_static_search_(false),
440 as_needed_(false),
441 include_whole_archive_(false)
442 {
443 }
444
445 // Add the sysroot, if any, to the search paths.
446
447 void
448 General_options::add_sysroot()
449 {
450 if (this->sysroot_.empty())
451 {
452 this->sysroot_ = get_default_sysroot();
453 if (this->sysroot_.empty())
454 return;
455 }
456
457 const char* sysroot = this->sysroot_.c_str();
458 char* canonical_sysroot = lrealpath(sysroot);
459
460 for (Dir_list::iterator p = this->search_path_.begin();
461 p != this->search_path_.end();
462 ++p)
463 p->add_sysroot(sysroot, canonical_sysroot);
464
465 free(canonical_sysroot);
466 }
467
468 // Search_directory methods.
469
470 // This is called if we have a sysroot. Apply the sysroot if
471 // appropriate. Record whether the directory is in the sysroot.
472
473 void
474 Search_directory::add_sysroot(const char* sysroot,
475 const char* canonical_sysroot)
476 {
477 gold_assert(*sysroot != '\0');
478 if (this->put_in_sysroot_)
479 {
480 if (!IS_DIR_SEPARATOR(this->name_[0])
481 && !IS_DIR_SEPARATOR(sysroot[strlen(sysroot) - 1]))
482 this->name_ = '/' + this->name_;
483 this->name_ = sysroot + this->name_;
484 this->is_in_sysroot_ = true;
485 }
486 else
487 {
488 // Check whether this entry is in the sysroot. To do this
489 // correctly, we need to use canonical names. Otherwise we will
490 // get confused by the ../../.. paths that gcc tends to use.
491 char* canonical_name = lrealpath(this->name_.c_str());
492 int canonical_name_len = strlen(canonical_name);
493 int canonical_sysroot_len = strlen(canonical_sysroot);
494 if (canonical_name_len > canonical_sysroot_len
495 && IS_DIR_SEPARATOR(canonical_name[canonical_sysroot_len]))
496 {
497 canonical_name[canonical_sysroot_len] = '\0';
498 if (FILENAME_CMP(canonical_name, canonical_sysroot) == 0)
499 this->is_in_sysroot_ = true;
500 }
501 free(canonical_name);
502 }
503 }
504
505 // Input_arguments methods.
506
507 // Add a file to the list.
508
509 void
510 Input_arguments::add_file(const Input_file_argument& file)
511 {
512 if (!this->in_group_)
513 this->input_argument_list_.push_back(Input_argument(file));
514 else
515 {
516 gold_assert(!this->input_argument_list_.empty());
517 gold_assert(this->input_argument_list_.back().is_group());
518 this->input_argument_list_.back().group()->add_file(file);
519 }
520 }
521
522 // Start a group.
523
524 void
525 Input_arguments::start_group()
526 {
527 gold_assert(!this->in_group_);
528 Input_file_group* group = new Input_file_group();
529 this->input_argument_list_.push_back(Input_argument(group));
530 this->in_group_ = true;
531 }
532
533 // End a group.
534
535 void
536 Input_arguments::end_group()
537 {
538 gold_assert(this->in_group_);
539 this->in_group_ = false;
540 }
541
542 // Command_line options.
543
544 Command_line::Command_line()
545 : options_(), position_options_(), inputs_()
546 {
547 }
548
549 // Process the command line options.
550
551 void
552 Command_line::process(int argc, char** argv)
553 {
554 const int options_size = options::Command_line_options::options_size;
555 const options::One_option* options =
556 options::Command_line_options::options;
557 bool no_more_options = false;
558 int i = 0;
559 while (i < argc)
560 {
561 if (argv[i][0] != '-' || no_more_options)
562 {
563 this->add_file(argv[i], false);
564 ++i;
565 continue;
566 }
567
568 // Option starting with '-'.
569 int dashes = 1;
570 if (argv[i][1] == '-')
571 {
572 dashes = 2;
573 if (argv[i][2] == '\0')
574 {
575 no_more_options = true;
576 continue;
577 }
578 }
579
580 // Look for a long option match.
581 char* opt = argv[i] + dashes;
582 char first = opt[0];
583 int skiparg = 0;
584 char* arg = strchr(opt, '=');
585 bool argument_with_equals = arg != NULL;
586 if (arg != NULL)
587 {
588 *arg = '\0';
589 ++arg;
590 }
591 else if (i + 1 < argc)
592 {
593 arg = argv[i + 1];
594 skiparg = 1;
595 }
596
597 int j;
598 for (j = 0; j < options_size; ++j)
599 {
600 if (options[j].long_option != NULL
601 && (dashes == 2
602 || (options[j].dash
603 != options::One_option::EXACTLY_TWO_DASHES))
604 && first == options[j].long_option[0]
605 && strcmp(opt, options[j].long_option) == 0)
606 {
607 if (options[j].special)
608 i += options[j].special(argc - 1, argv + i, opt, this);
609 else
610 {
611 if (!options[j].takes_argument())
612 {
613 if (argument_with_equals)
614 this->usage(_("unexpected argument"), argv[i]);
615 arg = NULL;
616 skiparg = 0;
617 }
618 else
619 {
620 if (arg == NULL)
621 this->usage(_("missing argument"), argv[i]);
622 }
623 this->apply_option(options[j], arg);
624 i += skiparg + 1;
625 }
626 break;
627 }
628 }
629 if (j < options_size)
630 continue;
631
632 // If we saw two dashes, we need to see a long option.
633 if (dashes == 2)
634 this->usage(_("unknown option"), argv[i]);
635
636 // Look for a short option match. There may be more than one
637 // short option in a given argument.
638 bool done = false;
639 char* s = argv[i] + 1;
640 ++i;
641 while (*s != '\0' && !done)
642 {
643 char opt = *s;
644 int j;
645 for (j = 0; j < options_size; ++j)
646 {
647 if (options[j].short_option == opt)
648 {
649 if (options[j].special)
650 {
651 // Undo the argument skip done above.
652 --i;
653 i += options[j].special(argc - i, argv + i, s, this);
654 done = true;
655 }
656 else
657 {
658 arg = NULL;
659 if (options[j].takes_argument())
660 {
661 if (s[1] != '\0')
662 {
663 arg = s + 1;
664 done = true;
665 }
666 else if (i < argc)
667 {
668 arg = argv[i];
669 ++i;
670 }
671 else
672 this->usage(_("missing argument"), opt);
673 }
674 this->apply_option(options[j], arg);
675 }
676 break;
677 }
678 }
679
680 if (j >= options_size)
681 this->usage(_("unknown option"), *s);
682
683 ++s;
684 }
685 }
686
687 if (this->inputs_.in_group())
688 {
689 fprintf(stderr, _("%s: missing group end"), program_name);
690 this->usage();
691 }
692
693 // FIXME: We should only do this when configured in native mode.
694 this->options_.add_to_search_path_with_sysroot("/lib");
695 this->options_.add_to_search_path_with_sysroot("/usr/lib");
696
697 this->options_.add_sysroot();
698
699 // Ensure options don't contradict each other and are otherwise kosher.
700 this->normalize_options();
701 }
702
703 // Ensure options don't contradict each other and are otherwise kosher.
704
705 void
706 Command_line::normalize_options()
707 {
708 // If the user specifies both -s and -r, convert the -s as -S.
709 // -r requires us to keep externally visible symbols!
710 if (this->options_.strip_all() && this->options_.is_relocatable())
711 {
712 // Clears the strip_all() status, replacing it with strip_debug().
713 this->options_.set_strip_debug();
714 }
715
716 // FIXME: we can/should be doing a lot more sanity checking here.
717 }
718
719
720 // Apply a command line option.
721
722 void
723 Command_line::apply_option(const options::One_option& opt,
724 const char* arg)
725 {
726 if (arg == NULL)
727 {
728 if (opt.general_noarg)
729 (this->options_.*(opt.general_noarg))();
730 else if (opt.dependent_noarg)
731 (this->position_options_.*(opt.dependent_noarg))();
732 else
733 gold_unreachable();
734 }
735 else
736 {
737 if (opt.general_arg)
738 (this->options_.*(opt.general_arg))(arg);
739 else if (opt.dependent_arg)
740 (this->position_options_.*(opt.dependent_arg))(arg);
741 else
742 gold_unreachable();
743 }
744 }
745
746 // Add an input file or library.
747
748 void
749 Command_line::add_file(const char* name, bool is_lib)
750 {
751 Input_file_argument file(name, is_lib, "", this->position_options_);
752 this->inputs_.add_file(file);
753 }
754
755 // Handle the -l option, which requires special treatment.
756
757 int
758 Command_line::process_l_option(int argc, char** argv, char* arg)
759 {
760 int ret;
761 const char* libname;
762 if (arg[1] != '\0')
763 {
764 ret = 1;
765 libname = arg + 1;
766 }
767 else if (argc > 1)
768 {
769 ret = 2;
770 libname = argv[argc + 1];
771 }
772 else
773 this->usage(_("missing argument"), arg);
774
775 this->add_file(libname, true);
776
777 return ret;
778 }
779
780 // Handle the --start-group option.
781
782 void
783 Command_line::start_group(const char* arg)
784 {
785 if (this->inputs_.in_group())
786 this->usage(_("may not nest groups"), arg);
787 this->inputs_.start_group();
788 }
789
790 // Handle the --end-group option.
791
792 void
793 Command_line::end_group(const char* arg)
794 {
795 if (!this->inputs_.in_group())
796 this->usage(_("group end without group start"), arg);
797 this->inputs_.end_group();
798 }
799
800 // Report a usage error. */
801
802 void
803 Command_line::usage()
804 {
805 fprintf(stderr,
806 _("%s: use the --help option for usage information\n"),
807 program_name);
808 ::exit(1);
809 }
810
811 void
812 Command_line::usage(const char* msg, const char *opt)
813 {
814 fprintf(stderr,
815 _("%s: %s: %s\n"),
816 program_name, opt, msg);
817 this->usage();
818 }
819
820 void
821 Command_line::usage(const char* msg, char opt)
822 {
823 fprintf(stderr,
824 _("%s: -%c: %s\n"),
825 program_name, opt, msg);
826 this->usage();
827 }
828
829 } // End namespace gold.
This page took 0.052495 seconds and 5 git commands to generate.