#include "ldfile.h"
#include "ldver.h"
#include "ldemul.h"
+#include "demangle.h"
#ifndef PATH_SEPARATOR
#if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
#endif
#endif
-/* Somewhere above, sys/stat.h got included . . . . */
+/* Somewhere above, sys/stat.h got included . . . . */
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#define OPTION_INIT (OPTION_NO_UNDEFINED + 1)
#define OPTION_FINI (OPTION_INIT + 1)
#define OPTION_SECTION_START (OPTION_FINI + 1)
+#define OPTION_UNIQUE (OPTION_SECTION_START + 1)
+#define OPTION_TARGET_HELP (OPTION_UNIQUE + 1)
/* The long options. This structure is used for both the option
parsing and the help text. */
-struct ld_option
-{
+struct ld_option {
/* The long option information. */
struct option opt;
/* The short option with the same meaning ('\0' if none). */
/* The documentation string. If this is NULL, this is a synonym for
the previous option. */
const char *doc;
- enum
- {
- /* Use one dash before long option name. */
- ONE_DASH,
- /* Use two dashes before long option name. */
- TWO_DASHES,
- /* Don't mention this option in --help output. */
- NO_HELP
- } control;
+ enum {
+ /* Use one dash before long option name. */
+ ONE_DASH,
+ /* Use two dashes before long option name. */
+ TWO_DASHES,
+ /* Don't mention this option in --help output. */
+ NO_HELP
+ } control;
};
-static const struct ld_option ld_options[] =
-{
+static const struct ld_option ld_options[] = {
{ {NULL, required_argument, NULL, '\0'},
'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
ONE_DASH },
'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
{ {"undefined", required_argument, NULL, 'u'},
'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), TWO_DASHES },
+ { {"unique", no_argument, NULL, OPTION_UNIQUE},
+ '\0', NULL, N_("Don't merge orphan sections with the same name"), TWO_DASHES },
{ {"Ur", no_argument, NULL, OPTION_UR},
'\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
{ {"version", no_argument, NULL, OPTION_VERSION},
'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
{ {NULL, required_argument, NULL, '\0'},
'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), ONE_DASH },
-#if 0
- { {NULL, required_argument, NULL, '\0'},
- 'z', N_("KEYWORD"), N_("Ignored for Solaris compatibility"), ONE_DASH },
-#endif
{ {"start-group", no_argument, NULL, '('},
'(', NULL, N_("Start a group"), TWO_DASHES },
{ {"end-group", no_argument, NULL, ')'},
'\0', NULL, N_("Output cross reference table"), TWO_DASHES },
{ {"defsym", required_argument, NULL, OPTION_DEFSYM},
'\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
- { {"demangle", no_argument, NULL, OPTION_DEMANGLE},
- '\0', NULL, N_("Demangle symbol names"), TWO_DASHES },
+ { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
+ '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), TWO_DASHES },
{ {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
'\0', N_("PROGRAM"), N_("Set the dynamic linker to use"), TWO_DASHES },
{ {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
'\0', NULL, N_("Sort common symbols by size"), TWO_DASHES },
{ {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
'\0', NULL, NULL, NO_HELP },
- { {"split-by-file", no_argument, NULL, OPTION_SPLIT_BY_FILE},
- '\0', NULL, N_("Split output sections for each file"), TWO_DASHES },
- { {"split-by-reloc", required_argument, NULL, OPTION_SPLIT_BY_RELOC},
- '\0', N_("COUNT"), N_("Split output sections every COUNT relocs"), TWO_DASHES },
+ { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE},
+ '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"), TWO_DASHES },
+ { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC},
+ '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"), TWO_DASHES },
{ {"stats", no_argument, NULL, OPTION_STATS},
'\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
+ { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
+ '\0', NULL, N_("Display target specific options"), TWO_DASHES },
{ {"task-link", required_argument, NULL, OPTION_TASK_LINK},
'\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
{ {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
break;
case OPTION_DEMANGLE:
demangling = true;
+ if (optarg != NULL)
+ {
+ enum demangling_styles style;
+
+ style = cplus_demangle_name_to_style (optarg);
+ if (style == unknown_demangling)
+ einfo (_("%F%P: unknown demangling style `%s'"),
+ optarg);
+
+ cplus_demangle_set_style (style);
+ }
break;
case OPTION_DYNAMIC_LINKER:
command_line.interpreter = optarg;
link_info.optimize = strtoul (optarg, NULL, 0) ? true : false;
break;
case 'o':
- lang_add_output (optarg, 0);
+ lang_add_output (optarg, 0);
break;
case OPTION_OFORMAT:
lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
xexit (1);
}
- optarg2 ++;
-
+ optarg2++;
+
/* So far so good. Are all the args present? */
if ((*optarg == '\0') || (*optarg2 == '\0'))
{
set_section_start (sec_name, optarg2);
}
break;
+ case OPTION_TARGET_HELP:
+ /* Mention any target specific options. */
+ ldemul_list_emulation_options (stdout);
+ exit (0);
case OPTION_TBSS:
set_section_start (".bss", optarg);
break;
case 'u':
ldlang_add_undef (optarg);
break;
+ case OPTION_UNIQUE:
+ config.unique_orphan_sections = true;
+ break;
case OPTION_VERBOSE:
ldversion (1);
version_printed = true;
the GNU General Public License. This program has absolutely no warranty.\n"));
{
ld_emulation_xfer_type **ptr = ld_emulations;
-
+
printf (_(" Supported emulations:\n"));
- while (*ptr)
+ while (*ptr)
{
printf (" %s\n", (*ptr)->emulation_name);
ptr++;
case 'y':
add_ysym (optarg);
break;
-#if 0
- case 'z':
- /* We accept and ignore this option for Solaris
- compatibility. Actually, on Solaris, optarg is not
- ignored. Someday we should handle it correctly. FIXME. */
- break;
-#endif
case OPTION_SPLIT_BY_RELOC:
- config.split_by_reloc = strtoul (optarg, NULL, 0);
- break;
+ if (optarg != NULL)
+ config.split_by_reloc = strtoul (optarg, NULL, 0);
+ else
+ config.split_by_reloc = 32768;
+ break;
case OPTION_SPLIT_BY_FILE:
- config.split_by_file = true;
- break;
+ if (optarg != NULL)
+ config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
+ else
+ config.split_by_file = 1;
+ break;
case OPTION_CHECK_SECTIONS:
command_line.check_section_addresses = true;
break;
lang_leave_group ();
ingroup = 0;
break;
- case OPTION_MPC860C0:
- link_info.mpc860c0 = 20; /* default value (in bytes) */
- if (optarg)
- {
- unsigned words;
+ case OPTION_MPC860C0:
+ link_info.mpc860c0 = 20; /* default value (in bytes) */
+ if (optarg)
+ {
+ unsigned words;
- words = is_num (optarg, 1, 10, 0);
- if (words == 0)
- {
- fprintf (stderr,
+ words = is_num (optarg, 1, 10, 0);
+ if (words == 0)
+ {
+ fprintf (stderr,
_("%s: Invalid argument to option \"mpc860c0\"\n"),
program_name);
- xexit (1);
- }
- link_info.mpc860c0 = words * 4; /* convert words to bytes */
- }
- command_line.relax = true;
- break;
+ xexit (1);
+ }
+ link_info.mpc860c0 = words * 4; /* convert words to bytes */
+ }
+ command_line.relax = true;
+ break;
case OPTION_INIT:
link_info.init_function = optarg;
break;
-
+
case OPTION_FINI:
link_info.fini_function = optarg;
break;