13d8817e4Smiod /* Parse options for the GNU linker.
23d8817e4Smiod Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
33d8817e4Smiod 2001, 2002, 2003, 2004, 2005
43d8817e4Smiod Free Software Foundation, Inc.
53d8817e4Smiod
63d8817e4Smiod This file is part of GLD, the Gnu Linker.
73d8817e4Smiod
83d8817e4Smiod GLD is free software; you can redistribute it and/or modify
93d8817e4Smiod it under the terms of the GNU General Public License as published by
103d8817e4Smiod the Free Software Foundation; either version 2, or (at your option)
113d8817e4Smiod any later version.
123d8817e4Smiod
133d8817e4Smiod GLD is distributed in the hope that it will be useful,
143d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
153d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
163d8817e4Smiod GNU General Public License for more details.
173d8817e4Smiod
183d8817e4Smiod You should have received a copy of the GNU General Public License
193d8817e4Smiod along with GLD; see the file COPYING. If not, write to the Free
203d8817e4Smiod Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
213d8817e4Smiod 02110-1301, USA. */
223d8817e4Smiod
233d8817e4Smiod #include "config.h"
243d8817e4Smiod #include "bfd.h"
253d8817e4Smiod #include "sysdep.h"
263d8817e4Smiod #include "libiberty.h"
273d8817e4Smiod #include <stdio.h>
283d8817e4Smiod #include <string.h>
293d8817e4Smiod #include "safe-ctype.h"
303d8817e4Smiod #include "getopt.h"
313d8817e4Smiod #include "bfdlink.h"
323d8817e4Smiod #include "ld.h"
333d8817e4Smiod #include "ldmain.h"
343d8817e4Smiod #include "ldmisc.h"
353d8817e4Smiod #include "ldexp.h"
363d8817e4Smiod #include "ldlang.h"
373d8817e4Smiod #include <ldgram.h>
383d8817e4Smiod #include "ldlex.h"
393d8817e4Smiod #include "ldfile.h"
403d8817e4Smiod #include "ldver.h"
413d8817e4Smiod #include "ldemul.h"
423d8817e4Smiod #include "demangle.h"
433d8817e4Smiod
443d8817e4Smiod #ifndef PATH_SEPARATOR
453d8817e4Smiod #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
463d8817e4Smiod #define PATH_SEPARATOR ';'
473d8817e4Smiod #else
483d8817e4Smiod #define PATH_SEPARATOR ':'
493d8817e4Smiod #endif
503d8817e4Smiod #endif
513d8817e4Smiod
523d8817e4Smiod /* Somewhere above, sys/stat.h got included . . . . */
533d8817e4Smiod #if !defined(S_ISDIR) && defined(S_IFDIR)
543d8817e4Smiod #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
553d8817e4Smiod #endif
563d8817e4Smiod
573d8817e4Smiod static void set_default_dirlist (char *);
583d8817e4Smiod static void set_section_start (char *, char *);
593d8817e4Smiod static void set_segment_start (const char *, char *);
603d8817e4Smiod static void help (void);
613d8817e4Smiod
623d8817e4Smiod /* Non-zero if we are processing a --defsym from the command line. */
633d8817e4Smiod int parsing_defsym = 0;
643d8817e4Smiod
653d8817e4Smiod /* Codes used for the long options with no short synonyms. 150 isn't
663d8817e4Smiod special; it's just an arbitrary non-ASCII char value. */
673d8817e4Smiod enum option_values
683d8817e4Smiod {
693d8817e4Smiod OPTION_ASSERT = 150,
703d8817e4Smiod OPTION_CALL_SHARED,
713d8817e4Smiod OPTION_CREF,
723d8817e4Smiod OPTION_DEFSYM,
733d8817e4Smiod OPTION_DEMANGLE,
743d8817e4Smiod OPTION_DYNAMIC_LINKER,
753d8817e4Smiod OPTION_SYSROOT,
763d8817e4Smiod OPTION_EB,
773d8817e4Smiod OPTION_EL,
783d8817e4Smiod OPTION_EMBEDDED_RELOCS,
793d8817e4Smiod OPTION_EXPORT_DYNAMIC,
80*754e8b3dSkettenis OPTION_EXECUTE_ONLY,
81*754e8b3dSkettenis OPTION_NO_EXECUTE_ONLY,
823d8817e4Smiod OPTION_HELP,
833d8817e4Smiod OPTION_IGNORE,
843d8817e4Smiod OPTION_MAP,
853d8817e4Smiod OPTION_NO_DEMANGLE,
863d8817e4Smiod OPTION_NO_KEEP_MEMORY,
873d8817e4Smiod OPTION_NO_WARN_MISMATCH,
883d8817e4Smiod OPTION_NOINHIBIT_EXEC,
893d8817e4Smiod OPTION_NON_SHARED,
903d8817e4Smiod OPTION_NO_WHOLE_ARCHIVE,
913d8817e4Smiod OPTION_OFORMAT,
923d8817e4Smiod OPTION_RELAX,
933d8817e4Smiod OPTION_RETAIN_SYMBOLS_FILE,
943d8817e4Smiod OPTION_RPATH,
953d8817e4Smiod OPTION_RPATH_LINK,
963d8817e4Smiod OPTION_SHARED,
973d8817e4Smiod OPTION_SONAME,
983d8817e4Smiod OPTION_SORT_COMMON,
993d8817e4Smiod OPTION_SORT_SECTION,
1003d8817e4Smiod OPTION_STATS,
1013d8817e4Smiod OPTION_SYMBOLIC,
1023d8817e4Smiod OPTION_TASK_LINK,
1033d8817e4Smiod OPTION_TBSS,
1043d8817e4Smiod OPTION_TDATA,
1053d8817e4Smiod OPTION_TTEXT,
1063d8817e4Smiod OPTION_TRADITIONAL_FORMAT,
1073d8817e4Smiod OPTION_UR,
1083d8817e4Smiod OPTION_VERBOSE,
1093d8817e4Smiod OPTION_VERSION,
1103d8817e4Smiod OPTION_VERSION_SCRIPT,
1113d8817e4Smiod OPTION_VERSION_EXPORTS_SECTION,
1123d8817e4Smiod OPTION_WARN_COMMON,
1133d8817e4Smiod OPTION_WARN_CONSTRUCTORS,
1143d8817e4Smiod OPTION_WARN_FATAL,
1153d8817e4Smiod OPTION_WARN_MULTIPLE_GP,
1163d8817e4Smiod OPTION_WARN_ONCE,
1173d8817e4Smiod OPTION_WARN_SECTION_ALIGN,
1183d8817e4Smiod OPTION_SPLIT_BY_RELOC,
1193d8817e4Smiod OPTION_SPLIT_BY_FILE ,
1203d8817e4Smiod OPTION_WHOLE_ARCHIVE,
1213d8817e4Smiod OPTION_ADD_NEEDED,
1223d8817e4Smiod OPTION_NO_ADD_NEEDED,
1233d8817e4Smiod OPTION_AS_NEEDED,
1243d8817e4Smiod OPTION_NO_AS_NEEDED,
1253d8817e4Smiod OPTION_WRAP,
1263d8817e4Smiod OPTION_FORCE_EXE_SUFFIX,
1273d8817e4Smiod OPTION_GC_SECTIONS,
1283d8817e4Smiod OPTION_NO_GC_SECTIONS,
1293d8817e4Smiod OPTION_HASH_SIZE,
1303d8817e4Smiod OPTION_CHECK_SECTIONS,
1313d8817e4Smiod OPTION_NO_CHECK_SECTIONS,
1323d8817e4Smiod OPTION_NO_UNDEFINED,
1333d8817e4Smiod OPTION_INIT,
1343d8817e4Smiod OPTION_FINI,
1353d8817e4Smiod OPTION_SECTION_START,
1363d8817e4Smiod OPTION_UNIQUE,
1373d8817e4Smiod OPTION_TARGET_HELP,
1383d8817e4Smiod OPTION_ALLOW_SHLIB_UNDEFINED,
1393d8817e4Smiod OPTION_NO_ALLOW_SHLIB_UNDEFINED,
1403d8817e4Smiod OPTION_ALLOW_MULTIPLE_DEFINITION,
1413d8817e4Smiod OPTION_NO_UNDEFINED_VERSION,
1423d8817e4Smiod OPTION_DEFAULT_SYMVER,
1433d8817e4Smiod OPTION_DEFAULT_IMPORTED_SYMVER,
1443d8817e4Smiod OPTION_DISCARD_NONE,
1453d8817e4Smiod OPTION_SPARE_DYNAMIC_TAGS,
1463d8817e4Smiod OPTION_NO_DEFINE_COMMON,
1473d8817e4Smiod OPTION_NOSTDLIB,
1483d8817e4Smiod OPTION_NO_OMAGIC,
1493d8817e4Smiod OPTION_STRIP_DISCARDED,
1503d8817e4Smiod OPTION_NO_STRIP_DISCARDED,
1513d8817e4Smiod OPTION_ACCEPT_UNKNOWN_INPUT_ARCH,
1523d8817e4Smiod OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH,
1533d8817e4Smiod OPTION_PIE,
1549622a78fSpascal OPTION_NOPIE,
1553d8817e4Smiod OPTION_UNRESOLVED_SYMBOLS,
1563d8817e4Smiod OPTION_WARN_UNRESOLVED_SYMBOLS,
1573d8817e4Smiod OPTION_ERROR_UNRESOLVED_SYMBOLS,
1583d8817e4Smiod OPTION_WARN_SHARED_TEXTREL,
1593d8817e4Smiod OPTION_REDUCE_MEMORY_OVERHEADS
1603d8817e4Smiod };
1613d8817e4Smiod
1623d8817e4Smiod /* The long options. This structure is used for both the option
1633d8817e4Smiod parsing and the help text. */
1643d8817e4Smiod
1653d8817e4Smiod struct ld_option
1663d8817e4Smiod {
1673d8817e4Smiod /* The long option information. */
1683d8817e4Smiod struct option opt;
1693d8817e4Smiod /* The short option with the same meaning ('\0' if none). */
1703d8817e4Smiod char shortopt;
1713d8817e4Smiod /* The name of the argument (NULL if none). */
1723d8817e4Smiod const char *arg;
1733d8817e4Smiod /* The documentation string. If this is NULL, this is a synonym for
1743d8817e4Smiod the previous option. */
1753d8817e4Smiod const char *doc;
1763d8817e4Smiod enum {
1773d8817e4Smiod /* Use one dash before long option name. */
1783d8817e4Smiod ONE_DASH,
1793d8817e4Smiod /* Use two dashes before long option name. */
1803d8817e4Smiod TWO_DASHES,
1813d8817e4Smiod /* Only accept two dashes before the long option name.
1823d8817e4Smiod This is an overloading of the use of this enum, since originally it
1833d8817e4Smiod was only intended to tell the --help display function how to display
1843d8817e4Smiod the long option name. This feature was added in order to resolve
1853d8817e4Smiod the confusion about the -omagic command line switch. Is it setting
1863d8817e4Smiod the output file name to "magic" or is it setting the NMAGIC flag on
1873d8817e4Smiod the output ? It has been decided that it is setting the output file
1883d8817e4Smiod name, and that if you want to set the NMAGIC flag you should use -N
1893d8817e4Smiod or --omagic. */
1903d8817e4Smiod EXACTLY_TWO_DASHES,
1913d8817e4Smiod /* Don't mention this option in --help output. */
1923d8817e4Smiod NO_HELP
1933d8817e4Smiod } control;
1943d8817e4Smiod };
1953d8817e4Smiod
1963d8817e4Smiod static const struct ld_option ld_options[] =
1973d8817e4Smiod {
1983d8817e4Smiod { {NULL, required_argument, NULL, '\0'},
1993d8817e4Smiod 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
2003d8817e4Smiod ONE_DASH },
2013d8817e4Smiod { {"architecture", required_argument, NULL, 'A'},
2023d8817e4Smiod 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES },
2033d8817e4Smiod { {"format", required_argument, NULL, 'b'},
2043d8817e4Smiod 'b', N_("TARGET"), N_("Specify target for following input files"),
2053d8817e4Smiod TWO_DASHES },
2063d8817e4Smiod { {"mri-script", required_argument, NULL, 'c'},
2073d8817e4Smiod 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES },
2083d8817e4Smiod { {"dc", no_argument, NULL, 'd'},
2093d8817e4Smiod 'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
2103d8817e4Smiod { {"dp", no_argument, NULL, 'd'},
2113d8817e4Smiod '\0', NULL, NULL, ONE_DASH },
2123d8817e4Smiod { {"entry", required_argument, NULL, 'e'},
2133d8817e4Smiod 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
2143d8817e4Smiod { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
2153d8817e4Smiod 'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
2163d8817e4Smiod { {"EB", no_argument, NULL, OPTION_EB},
2173d8817e4Smiod '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
2183d8817e4Smiod { {"EL", no_argument, NULL, OPTION_EL},
2193d8817e4Smiod '\0', NULL, N_("Link little-endian objects"), ONE_DASH },
2203d8817e4Smiod { {"auxiliary", required_argument, NULL, 'f'},
2213d8817e4Smiod 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
2223d8817e4Smiod TWO_DASHES },
2233d8817e4Smiod { {"filter", required_argument, NULL, 'F'},
2243d8817e4Smiod 'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
2253d8817e4Smiod TWO_DASHES },
2263d8817e4Smiod { {NULL, no_argument, NULL, '\0'},
2273d8817e4Smiod 'g', NULL, N_("Ignored"), ONE_DASH },
2283d8817e4Smiod { {"gpsize", required_argument, NULL, 'G'},
2293d8817e4Smiod 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
2303d8817e4Smiod TWO_DASHES },
2313d8817e4Smiod { {"soname", required_argument, NULL, OPTION_SONAME},
2323d8817e4Smiod 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
2333d8817e4Smiod { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
2343d8817e4Smiod 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
2353d8817e4Smiod TWO_DASHES },
2363d8817e4Smiod { {"library", required_argument, NULL, 'l'},
2373d8817e4Smiod 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
2383d8817e4Smiod { {"library-path", required_argument, NULL, 'L'},
2393d8817e4Smiod 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
2403d8817e4Smiod TWO_DASHES },
2413d8817e4Smiod { {"sysroot=<DIRECTORY>", required_argument, NULL, OPTION_SYSROOT},
2423d8817e4Smiod '\0', NULL, N_("Override the default sysroot location"), TWO_DASHES },
2433d8817e4Smiod { {NULL, required_argument, NULL, '\0'},
2443d8817e4Smiod 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH },
2453d8817e4Smiod { {"print-map", no_argument, NULL, 'M'},
2463d8817e4Smiod 'M', NULL, N_("Print map file on standard output"), TWO_DASHES },
2473d8817e4Smiod { {"nmagic", no_argument, NULL, 'n'},
2483d8817e4Smiod 'n', NULL, N_("Do not page align data"), TWO_DASHES },
2493d8817e4Smiod { {"omagic", no_argument, NULL, 'N'},
2503d8817e4Smiod 'N', NULL, N_("Do not page align data, do not make text readonly"),
2513d8817e4Smiod EXACTLY_TWO_DASHES },
2523d8817e4Smiod { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC},
2533d8817e4Smiod '\0', NULL, N_("Page align data, make text readonly"),
2543d8817e4Smiod EXACTLY_TWO_DASHES },
2553d8817e4Smiod { {"output", required_argument, NULL, 'o'},
2563d8817e4Smiod 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES },
2573d8817e4Smiod { {NULL, required_argument, NULL, '\0'},
2583d8817e4Smiod 'O', NULL, N_("Optimize output file"), ONE_DASH },
2593d8817e4Smiod { {"Qy", no_argument, NULL, OPTION_IGNORE},
2603d8817e4Smiod '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
2613d8817e4Smiod { {"emit-relocs", no_argument, NULL, 'q'},
2623d8817e4Smiod 'q', NULL, "Generate relocations in final output", TWO_DASHES },
2633d8817e4Smiod { {"relocatable", no_argument, NULL, 'r'},
2643d8817e4Smiod 'r', NULL, N_("Generate relocatable output"), TWO_DASHES },
2653d8817e4Smiod { {NULL, no_argument, NULL, '\0'},
2663d8817e4Smiod 'i', NULL, NULL, ONE_DASH },
2673d8817e4Smiod { {"just-symbols", required_argument, NULL, 'R'},
2683d8817e4Smiod 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
2693d8817e4Smiod TWO_DASHES },
2703d8817e4Smiod { {"strip-all", no_argument, NULL, 's'},
2713d8817e4Smiod 's', NULL, N_("Strip all symbols"), TWO_DASHES },
2723d8817e4Smiod { {"strip-debug", no_argument, NULL, 'S'},
2733d8817e4Smiod 'S', NULL, N_("Strip debugging symbols"), TWO_DASHES },
2743d8817e4Smiod { {"strip-discarded", no_argument, NULL, OPTION_STRIP_DISCARDED},
2753d8817e4Smiod '\0', NULL, N_("Strip symbols in discarded sections"), TWO_DASHES },
2763d8817e4Smiod { {"no-strip-discarded", no_argument, NULL, OPTION_NO_STRIP_DISCARDED},
2773d8817e4Smiod '\0', NULL, N_("Do not strip symbols in discarded sections"), TWO_DASHES },
2783d8817e4Smiod { {"trace", no_argument, NULL, 't'},
2793d8817e4Smiod 't', NULL, N_("Trace file opens"), TWO_DASHES },
2803d8817e4Smiod { {"script", required_argument, NULL, 'T'},
2813d8817e4Smiod 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
2823d8817e4Smiod { {"undefined", required_argument, NULL, 'u'},
2833d8817e4Smiod 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
2843d8817e4Smiod TWO_DASHES },
2853d8817e4Smiod { {"unique", optional_argument, NULL, OPTION_UNIQUE},
2863d8817e4Smiod '\0', N_("[=SECTION]"),
2873d8817e4Smiod N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
2883d8817e4Smiod { {"Ur", no_argument, NULL, OPTION_UR},
2893d8817e4Smiod '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
2903d8817e4Smiod { {"version", no_argument, NULL, OPTION_VERSION},
2913d8817e4Smiod 'v', NULL, N_("Print version information"), TWO_DASHES },
2923d8817e4Smiod { {NULL, no_argument, NULL, '\0'},
2933d8817e4Smiod 'V', NULL, N_("Print version and emulation information"), ONE_DASH },
2943d8817e4Smiod { {"discard-all", no_argument, NULL, 'x'},
2953d8817e4Smiod 'x', NULL, N_("Discard all local symbols"), TWO_DASHES },
2963d8817e4Smiod { {"discard-locals", no_argument, NULL, 'X'},
2973d8817e4Smiod 'X', NULL, N_("Discard temporary local symbols (default)"), TWO_DASHES },
2983d8817e4Smiod { {"discard-none", no_argument, NULL, OPTION_DISCARD_NONE},
2993d8817e4Smiod '\0', NULL, N_("Don't discard any local symbols"), TWO_DASHES },
3003d8817e4Smiod { {"trace-symbol", required_argument, NULL, 'y'},
3013d8817e4Smiod 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
3023d8817e4Smiod { {NULL, required_argument, NULL, '\0'},
3033d8817e4Smiod 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
3043d8817e4Smiod ONE_DASH },
305d2386abeSmiod { {"Zmagic", no_argument, NULL, 'Z'},
306d2386abeSmiod 'Z', NULL, N_("Do not page align got/plt, old style executable"),
307d2386abeSmiod EXACTLY_TWO_DASHES },
3083d8817e4Smiod { {"start-group", no_argument, NULL, '('},
3093d8817e4Smiod '(', NULL, N_("Start a group"), TWO_DASHES },
3103d8817e4Smiod { {"end-group", no_argument, NULL, ')'},
3113d8817e4Smiod ')', NULL, N_("End a group"), TWO_DASHES },
3123d8817e4Smiod { {"accept-unknown-input-arch", no_argument, NULL,
3133d8817e4Smiod OPTION_ACCEPT_UNKNOWN_INPUT_ARCH},
3143d8817e4Smiod '\0', NULL,
3153d8817e4Smiod N_("Accept input files whose architecture cannot be determined"),
3163d8817e4Smiod TWO_DASHES },
3173d8817e4Smiod { {"no-accept-unknown-input-arch", no_argument, NULL,
3183d8817e4Smiod OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
3193d8817e4Smiod '\0', NULL, N_("Reject input files whose architecture is unknown"),
3203d8817e4Smiod TWO_DASHES },
3213d8817e4Smiod { {"add-needed", no_argument, NULL, OPTION_ADD_NEEDED},
3223d8817e4Smiod '\0', NULL, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
3233d8817e4Smiod "\t\t\t\tfollowing dynamic libs"), TWO_DASHES },
3243d8817e4Smiod { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_NEEDED},
3253d8817e4Smiod '\0', NULL, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
3263d8817e4Smiod "\t\t\t\tin following dynamic libs"), TWO_DASHES },
3273d8817e4Smiod { {"as-needed", no_argument, NULL, OPTION_AS_NEEDED},
3283d8817e4Smiod '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
3293d8817e4Smiod TWO_DASHES },
3303d8817e4Smiod { {"no-as-needed", no_argument, NULL, OPTION_NO_AS_NEEDED},
3313d8817e4Smiod '\0', NULL, N_("Always set DT_NEEDED for following dynamic libs"),
3323d8817e4Smiod TWO_DASHES },
3333d8817e4Smiod { {"assert", required_argument, NULL, OPTION_ASSERT},
3343d8817e4Smiod '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
3353d8817e4Smiod { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
3363d8817e4Smiod '\0', NULL, N_("Link against shared libraries"), ONE_DASH },
3373d8817e4Smiod { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
3383d8817e4Smiod '\0', NULL, NULL, ONE_DASH },
3393d8817e4Smiod { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
3403d8817e4Smiod '\0', NULL, NULL, ONE_DASH },
3413d8817e4Smiod { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
3423d8817e4Smiod '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
3433d8817e4Smiod { {"dn", no_argument, NULL, OPTION_NON_SHARED},
3443d8817e4Smiod '\0', NULL, NULL, ONE_DASH },
3453d8817e4Smiod { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
3463d8817e4Smiod '\0', NULL, NULL, ONE_DASH },
3473d8817e4Smiod { {"static", no_argument, NULL, OPTION_NON_SHARED},
3483d8817e4Smiod '\0', NULL, NULL, ONE_DASH },
3493d8817e4Smiod { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
3503d8817e4Smiod '\0', NULL, N_("Bind global references locally"), ONE_DASH },
3513d8817e4Smiod { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
3523d8817e4Smiod '\0', NULL, N_("Check section addresses for overlaps (default)"),
3533d8817e4Smiod TWO_DASHES },
3543d8817e4Smiod { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
3553d8817e4Smiod '\0', NULL, N_("Do not check section addresses for overlaps"),
3563d8817e4Smiod TWO_DASHES },
3573d8817e4Smiod { {"cref", no_argument, NULL, OPTION_CREF},
3583d8817e4Smiod '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
3593d8817e4Smiod { {"defsym", required_argument, NULL, OPTION_DEFSYM},
3603d8817e4Smiod '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
3613d8817e4Smiod { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
3623d8817e4Smiod '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
3633d8817e4Smiod TWO_DASHES },
3643d8817e4Smiod { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
3653d8817e4Smiod '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
366*754e8b3dSkettenis { {"execute-only", no_argument, NULL, OPTION_EXECUTE_ONLY},
367*754e8b3dSkettenis '\0', NULL, N_("Mark executable sections unreadable"), TWO_DASHES},
368*754e8b3dSkettenis { {"no-execute-only", no_argument, NULL, OPTION_NO_EXECUTE_ONLY},
369*754e8b3dSkettenis '\0', NULL, N_("Do not mark executable sections unreadable"), TWO_DASHES},
3703d8817e4Smiod { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
3713d8817e4Smiod '\0', NULL, N_("Treat warnings as errors"),
3723d8817e4Smiod TWO_DASHES },
3733d8817e4Smiod { {"fini", required_argument, NULL, OPTION_FINI},
3743d8817e4Smiod '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
3753d8817e4Smiod { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
3763d8817e4Smiod '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
3773d8817e4Smiod { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
3783d8817e4Smiod '\0', NULL, N_("Remove unused sections (on some targets)"),
3793d8817e4Smiod TWO_DASHES },
3803d8817e4Smiod { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
3813d8817e4Smiod '\0', NULL, N_("Don't remove unused sections (default)"),
3823d8817e4Smiod TWO_DASHES },
3833d8817e4Smiod { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
3843d8817e4Smiod '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
3853d8817e4Smiod TWO_DASHES },
3863d8817e4Smiod { {"help", no_argument, NULL, OPTION_HELP},
3873d8817e4Smiod '\0', NULL, N_("Print option help"), TWO_DASHES },
3883d8817e4Smiod { {"init", required_argument, NULL, OPTION_INIT},
3893d8817e4Smiod '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
3903d8817e4Smiod { {"Map", required_argument, NULL, OPTION_MAP},
3913d8817e4Smiod '\0', N_("FILE"), N_("Write a map file"), ONE_DASH },
3923d8817e4Smiod { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
3933d8817e4Smiod '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
3943d8817e4Smiod { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
3953d8817e4Smiod '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
3963d8817e4Smiod { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
3973d8817e4Smiod '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES },
3983d8817e4Smiod { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
3993d8817e4Smiod '\0', NULL, N_("Do not allow unresolved references in object files"),
4003d8817e4Smiod TWO_DASHES },
4013d8817e4Smiod { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED},
4023d8817e4Smiod '\0', NULL, N_("Allow unresolved references in shared libaries"),
4033d8817e4Smiod TWO_DASHES },
4043d8817e4Smiod { {"no-allow-shlib-undefined", no_argument, NULL,
4053d8817e4Smiod OPTION_NO_ALLOW_SHLIB_UNDEFINED},
4063d8817e4Smiod '\0', NULL, N_("Do not allow unresolved references in shared libs"),
4073d8817e4Smiod TWO_DASHES },
4083d8817e4Smiod { {"allow-multiple-definition", no_argument, NULL,
4093d8817e4Smiod OPTION_ALLOW_MULTIPLE_DEFINITION},
4103d8817e4Smiod '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES },
4113d8817e4Smiod { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
4123d8817e4Smiod '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
4133d8817e4Smiod { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER},
4143d8817e4Smiod '\0', NULL, N_("Create default symbol version"), TWO_DASHES },
4153d8817e4Smiod { {"default-imported-symver", no_argument, NULL,
4163d8817e4Smiod OPTION_DEFAULT_IMPORTED_SYMVER},
4173d8817e4Smiod '\0', NULL, N_("Create default symbol version for imported symbols"),
4183d8817e4Smiod TWO_DASHES },
4193d8817e4Smiod { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
4203d8817e4Smiod '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
4213d8817e4Smiod { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
4223d8817e4Smiod '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
4233d8817e4Smiod { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
4243d8817e4Smiod '\0', NULL, N_("Create an output file even if errors occur"),
4253d8817e4Smiod TWO_DASHES },
4263d8817e4Smiod { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
4273d8817e4Smiod '\0', NULL, NULL, NO_HELP },
4283d8817e4Smiod { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB},
4293d8817e4Smiod '\0', NULL, N_("Only use library directories specified on\n"
4303d8817e4Smiod "\t\t\t\tthe command line"), ONE_DASH },
4313d8817e4Smiod { {"oformat", required_argument, NULL, OPTION_OFORMAT},
4323d8817e4Smiod '\0', N_("TARGET"), N_("Specify target of output file"),
4333d8817e4Smiod EXACTLY_TWO_DASHES },
4343d8817e4Smiod { {"qmagic", no_argument, NULL, OPTION_IGNORE},
4353d8817e4Smiod '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
4363d8817e4Smiod { {"reduce-memory-overheads", no_argument, NULL,
4373d8817e4Smiod OPTION_REDUCE_MEMORY_OVERHEADS},
4383d8817e4Smiod '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
4393d8817e4Smiod TWO_DASHES },
4403d8817e4Smiod { {"relax", no_argument, NULL, OPTION_RELAX},
4413d8817e4Smiod '\0', NULL, N_("Relax branches on certain targets"), TWO_DASHES },
4423d8817e4Smiod { {"retain-symbols-file", required_argument, NULL,
4433d8817e4Smiod OPTION_RETAIN_SYMBOLS_FILE},
4443d8817e4Smiod '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
4453d8817e4Smiod { {"rpath", required_argument, NULL, OPTION_RPATH},
4463d8817e4Smiod '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH },
4473d8817e4Smiod { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
4483d8817e4Smiod '\0', N_("PATH"), N_("Set link time shared library search path"),
4493d8817e4Smiod ONE_DASH },
4503d8817e4Smiod { {"shared", no_argument, NULL, OPTION_SHARED},
4513d8817e4Smiod '\0', NULL, N_("Create a shared library"), ONE_DASH },
4523d8817e4Smiod { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */
4533d8817e4Smiod '\0', NULL, NULL, ONE_DASH },
4543d8817e4Smiod { {"pie", no_argument, NULL, OPTION_PIE},
4553d8817e4Smiod '\0', NULL, N_("Create a position independent executable"), ONE_DASH },
4563d8817e4Smiod { {"pic-executable", no_argument, NULL, OPTION_PIE},
4573d8817e4Smiod '\0', NULL, NULL, TWO_DASHES },
4589622a78fSpascal { {"nopie", no_argument, NULL, OPTION_NOPIE},
4599622a78fSpascal '\0', NULL, N_("Do not create a position independent executable"), ONE_DASH },
4603d8817e4Smiod { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
4613d8817e4Smiod '\0', NULL, N_("Sort common symbols by size"), TWO_DASHES },
4623d8817e4Smiod { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
4633d8817e4Smiod '\0', NULL, NULL, NO_HELP },
4643d8817e4Smiod { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
4653d8817e4Smiod '\0', N_("name|alignment"),
4663d8817e4Smiod N_("Sort sections by name or maximum alignment"), TWO_DASHES },
4673d8817e4Smiod { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
4683d8817e4Smiod '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
4693d8817e4Smiod TWO_DASHES },
4703d8817e4Smiod { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE},
4713d8817e4Smiod '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
4723d8817e4Smiod TWO_DASHES },
4733d8817e4Smiod { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC},
4743d8817e4Smiod '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
4753d8817e4Smiod TWO_DASHES },
4763d8817e4Smiod { {"stats", no_argument, NULL, OPTION_STATS},
4773d8817e4Smiod '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
4783d8817e4Smiod { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
4793d8817e4Smiod '\0', NULL, N_("Display target specific options"), TWO_DASHES },
4803d8817e4Smiod { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
4813d8817e4Smiod '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
4823d8817e4Smiod { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
4833d8817e4Smiod '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
4843d8817e4Smiod { {"section-start", required_argument, NULL, OPTION_SECTION_START},
4853d8817e4Smiod '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
4863d8817e4Smiod TWO_DASHES },
4873d8817e4Smiod { {"Tbss", required_argument, NULL, OPTION_TBSS},
4883d8817e4Smiod '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
4893d8817e4Smiod { {"Tdata", required_argument, NULL, OPTION_TDATA},
4903d8817e4Smiod '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
4913d8817e4Smiod { {"Ttext", required_argument, NULL, OPTION_TTEXT},
4923d8817e4Smiod '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
4933d8817e4Smiod { {"unresolved-symbols=<method>", required_argument, NULL,
4943d8817e4Smiod OPTION_UNRESOLVED_SYMBOLS},
4953d8817e4Smiod '\0', NULL, N_("How to handle unresolved symbols. <method> is:\n"
4963d8817e4Smiod "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
4973d8817e4Smiod "\t\t\t\tignore-in-shared-libs"), TWO_DASHES },
4983d8817e4Smiod { {"verbose", no_argument, NULL, OPTION_VERBOSE},
4993d8817e4Smiod '\0', NULL, N_("Output lots of information during link"), TWO_DASHES },
5003d8817e4Smiod { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */
5013d8817e4Smiod '\0', NULL, NULL, NO_HELP },
5023d8817e4Smiod { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
5033d8817e4Smiod '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
5043d8817e4Smiod { {"version-exports-section", required_argument, NULL,
5053d8817e4Smiod OPTION_VERSION_EXPORTS_SECTION },
5063d8817e4Smiod '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
5073d8817e4Smiod "\t\t\t\tSYMBOL as the version."), TWO_DASHES },
5083d8817e4Smiod { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
5093d8817e4Smiod '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
5103d8817e4Smiod { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
5113d8817e4Smiod '\0', NULL, N_("Warn if global constructors/destructors are seen"),
5123d8817e4Smiod TWO_DASHES },
5133d8817e4Smiod { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
5143d8817e4Smiod '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
5153d8817e4Smiod { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
5163d8817e4Smiod '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
5173d8817e4Smiod { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
5183d8817e4Smiod '\0', NULL, N_("Warn if start of section changes due to alignment"),
5193d8817e4Smiod TWO_DASHES },
5203d8817e4Smiod { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_SHARED_TEXTREL},
5213d8817e4Smiod '\0', NULL, N_("Warn if shared object has DT_TEXTREL"),
5223d8817e4Smiod TWO_DASHES },
5233d8817e4Smiod { {"warn-unresolved-symbols", no_argument, NULL,
5243d8817e4Smiod OPTION_WARN_UNRESOLVED_SYMBOLS},
5253d8817e4Smiod '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
5263d8817e4Smiod { {"error-unresolved-symbols", no_argument, NULL,
5273d8817e4Smiod OPTION_ERROR_UNRESOLVED_SYMBOLS},
5283d8817e4Smiod '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES },
5293d8817e4Smiod { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
5303d8817e4Smiod '\0', NULL, N_("Include all objects from following archives"),
5313d8817e4Smiod TWO_DASHES },
5323d8817e4Smiod { {"wrap", required_argument, NULL, OPTION_WRAP},
5333d8817e4Smiod '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
5343d8817e4Smiod };
5353d8817e4Smiod
5363d8817e4Smiod #define OPTION_COUNT ARRAY_SIZE (ld_options)
5373d8817e4Smiod
5383d8817e4Smiod void
parse_args(unsigned argc,char ** argv)5393d8817e4Smiod parse_args (unsigned argc, char **argv)
5403d8817e4Smiod {
5413d8817e4Smiod unsigned i;
5423d8817e4Smiod int is, il, irl;
5433d8817e4Smiod int ingroup = 0;
5443d8817e4Smiod char *default_dirlist = NULL;
5453d8817e4Smiod char *shortopts;
5463d8817e4Smiod struct option *longopts;
5473d8817e4Smiod struct option *really_longopts;
5483d8817e4Smiod int last_optind;
5493d8817e4Smiod enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
5503d8817e4Smiod
5513d8817e4Smiod shortopts = xmalloc (OPTION_COUNT * 3 + 2);
5523d8817e4Smiod longopts = xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
5533d8817e4Smiod really_longopts = xmalloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
5543d8817e4Smiod
5553d8817e4Smiod /* Starting the short option string with '-' is for programs that
5563d8817e4Smiod expect options and other ARGV-elements in any order and that care about
5573d8817e4Smiod the ordering of the two. We describe each non-option ARGV-element
5583d8817e4Smiod as if it were the argument of an option with character code 1. */
5593d8817e4Smiod shortopts[0] = '-';
5603d8817e4Smiod is = 1;
5613d8817e4Smiod il = 0;
5623d8817e4Smiod irl = 0;
5633d8817e4Smiod for (i = 0; i < OPTION_COUNT; i++)
5643d8817e4Smiod {
5653d8817e4Smiod if (ld_options[i].shortopt != '\0')
5663d8817e4Smiod {
5673d8817e4Smiod shortopts[is] = ld_options[i].shortopt;
5683d8817e4Smiod ++is;
5693d8817e4Smiod if (ld_options[i].opt.has_arg == required_argument
5703d8817e4Smiod || ld_options[i].opt.has_arg == optional_argument)
5713d8817e4Smiod {
5723d8817e4Smiod shortopts[is] = ':';
5733d8817e4Smiod ++is;
5743d8817e4Smiod if (ld_options[i].opt.has_arg == optional_argument)
5753d8817e4Smiod {
5763d8817e4Smiod shortopts[is] = ':';
5773d8817e4Smiod ++is;
5783d8817e4Smiod }
5793d8817e4Smiod }
5803d8817e4Smiod }
5813d8817e4Smiod if (ld_options[i].opt.name != NULL)
5823d8817e4Smiod {
5833d8817e4Smiod if (ld_options[i].control == EXACTLY_TWO_DASHES)
5843d8817e4Smiod {
5853d8817e4Smiod really_longopts[irl] = ld_options[i].opt;
5863d8817e4Smiod ++irl;
5873d8817e4Smiod }
5883d8817e4Smiod else
5893d8817e4Smiod {
5903d8817e4Smiod longopts[il] = ld_options[i].opt;
5913d8817e4Smiod ++il;
5923d8817e4Smiod }
5933d8817e4Smiod }
5943d8817e4Smiod }
5953d8817e4Smiod shortopts[is] = '\0';
5963d8817e4Smiod longopts[il].name = NULL;
5973d8817e4Smiod really_longopts[irl].name = NULL;
5983d8817e4Smiod
5993d8817e4Smiod ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
6003d8817e4Smiod
6013d8817e4Smiod /* The -G option is ambiguous on different platforms. Sometimes it
6023d8817e4Smiod specifies the largest data size to put into the small data
6033d8817e4Smiod section. Sometimes it is equivalent to --shared. Unfortunately,
6043d8817e4Smiod the first form takes an argument, while the second does not.
6053d8817e4Smiod
6063d8817e4Smiod We need to permit the --shared form because on some platforms,
6073d8817e4Smiod such as Solaris, gcc -shared will pass -G to the linker.
6083d8817e4Smiod
6093d8817e4Smiod To permit either usage, we look through the argument list. If we
6103d8817e4Smiod find -G not followed by a number, we change it into --shared.
6113d8817e4Smiod This will work for most normal cases. */
6123d8817e4Smiod for (i = 1; i < argc; i++)
6133d8817e4Smiod if (strcmp (argv[i], "-G") == 0
6143d8817e4Smiod && (i + 1 >= argc
6153d8817e4Smiod || ! ISDIGIT (argv[i + 1][0])))
6163d8817e4Smiod argv[i] = (char *) "--shared";
6173d8817e4Smiod
6183d8817e4Smiod /* Because we permit long options to start with a single dash, and
6193d8817e4Smiod we have a --library option, and the -l option is conventionally
6203d8817e4Smiod used with an immediately following argument, we can have bad
6213d8817e4Smiod results if somebody tries to use -l with a library whose name
6223d8817e4Smiod happens to start with "ibrary", as in -li. We avoid problems by
6233d8817e4Smiod simply turning -l into --library. This means that users will
6243d8817e4Smiod have to use two dashes in order to use --library, which is OK
6253d8817e4Smiod since that's how it is documented.
6263d8817e4Smiod
6273d8817e4Smiod FIXME: It's possible that this problem can arise for other short
6283d8817e4Smiod options as well, although the user does always have the recourse
6293d8817e4Smiod of adding a space between the option and the argument. */
6303d8817e4Smiod for (i = 1; i < argc; i++)
6313d8817e4Smiod {
6323d8817e4Smiod if (argv[i][0] == '-'
6333d8817e4Smiod && argv[i][1] == 'l'
6343d8817e4Smiod && argv[i][2] != '\0')
6353d8817e4Smiod {
6363d8817e4Smiod char *n;
6373d8817e4Smiod
6383d8817e4Smiod n = xmalloc (strlen (argv[i]) + 20);
6393d8817e4Smiod sprintf (n, "--library=%s", argv[i] + 2);
6403d8817e4Smiod argv[i] = n;
6413d8817e4Smiod }
6423d8817e4Smiod }
6433d8817e4Smiod
6443d8817e4Smiod last_optind = -1;
6453d8817e4Smiod while (1)
6463d8817e4Smiod {
6473d8817e4Smiod int longind;
6483d8817e4Smiod int optc;
6493d8817e4Smiod
6503d8817e4Smiod /* Using last_optind lets us avoid calling ldemul_parse_args
6513d8817e4Smiod multiple times on a single option, which would lead to
6523d8817e4Smiod confusion in the internal static variables maintained by
6533d8817e4Smiod getopt. This could otherwise happen for an argument like
6543d8817e4Smiod -nx, in which the -n is parsed as a single option, and we
6553d8817e4Smiod loop around to pick up the -x. */
6563d8817e4Smiod if (optind != last_optind)
6573d8817e4Smiod if (ldemul_parse_args (argc, argv))
6583d8817e4Smiod continue;
6593d8817e4Smiod
6603d8817e4Smiod /* getopt_long_only is like getopt_long, but '-' as well as '--'
6613d8817e4Smiod can indicate a long option. */
6623d8817e4Smiod opterr = 0;
6633d8817e4Smiod last_optind = optind;
6643d8817e4Smiod optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
6653d8817e4Smiod if (optc == '?')
6663d8817e4Smiod {
6673d8817e4Smiod optind = last_optind;
6683d8817e4Smiod optc = getopt_long (argc, argv, "-", really_longopts, &longind);
6693d8817e4Smiod }
6703d8817e4Smiod
6713d8817e4Smiod if (ldemul_handle_option (optc))
6723d8817e4Smiod continue;
6733d8817e4Smiod
6743d8817e4Smiod if (optc == -1)
6753d8817e4Smiod break;
6763d8817e4Smiod
6773d8817e4Smiod switch (optc)
6783d8817e4Smiod {
6793d8817e4Smiod case '?':
6803d8817e4Smiod einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
6813d8817e4Smiod default:
6823d8817e4Smiod einfo (_("%P%F: use the --help option for usage information\n"));
6833d8817e4Smiod
6843d8817e4Smiod case 1: /* File name. */
6853d8817e4Smiod lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL);
6863d8817e4Smiod break;
6873d8817e4Smiod
6883d8817e4Smiod case OPTION_IGNORE:
6893d8817e4Smiod break;
6903d8817e4Smiod case 'a':
6913d8817e4Smiod /* For HP/UX compatibility. Actually -a shared should mean
6923d8817e4Smiod ``use only shared libraries'' but, then, we don't
6933d8817e4Smiod currently support shared libraries on HP/UX anyhow. */
6943d8817e4Smiod if (strcmp (optarg, "archive") == 0)
6953d8817e4Smiod config.dynamic_link = FALSE;
6963d8817e4Smiod else if (strcmp (optarg, "shared") == 0
6973d8817e4Smiod || strcmp (optarg, "default") == 0)
6983d8817e4Smiod config.dynamic_link = TRUE;
6993d8817e4Smiod else
7003d8817e4Smiod einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg);
7013d8817e4Smiod break;
7023d8817e4Smiod case OPTION_ASSERT:
7033d8817e4Smiod /* FIXME: We just ignore these, but we should handle them. */
7043d8817e4Smiod if (strcmp (optarg, "definitions") == 0)
7053d8817e4Smiod ;
7063d8817e4Smiod else if (strcmp (optarg, "nodefinitions") == 0)
7073d8817e4Smiod ;
7083d8817e4Smiod else if (strcmp (optarg, "nosymbolic") == 0)
7093d8817e4Smiod ;
7103d8817e4Smiod else if (strcmp (optarg, "pure-text") == 0)
7113d8817e4Smiod ;
7123d8817e4Smiod else
7133d8817e4Smiod einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg);
7143d8817e4Smiod break;
7153d8817e4Smiod case 'A':
7163d8817e4Smiod ldfile_add_arch (optarg);
7173d8817e4Smiod break;
7183d8817e4Smiod case 'b':
7193d8817e4Smiod lang_add_target (optarg);
7203d8817e4Smiod break;
7213d8817e4Smiod case 'c':
7223d8817e4Smiod ldfile_open_command_file (optarg);
7233d8817e4Smiod parser_input = input_mri_script;
7243d8817e4Smiod yyparse ();
7253d8817e4Smiod break;
7263d8817e4Smiod case OPTION_CALL_SHARED:
7273d8817e4Smiod config.dynamic_link = TRUE;
7283d8817e4Smiod break;
7293d8817e4Smiod case OPTION_NON_SHARED:
7303d8817e4Smiod config.dynamic_link = FALSE;
7313d8817e4Smiod break;
7323d8817e4Smiod case OPTION_CREF:
7333d8817e4Smiod command_line.cref = TRUE;
7343d8817e4Smiod link_info.notice_all = TRUE;
7353d8817e4Smiod break;
7363d8817e4Smiod case 'd':
7373d8817e4Smiod command_line.force_common_definition = TRUE;
7383d8817e4Smiod break;
7393d8817e4Smiod case OPTION_DEFSYM:
7403d8817e4Smiod lex_string = optarg;
7413d8817e4Smiod lex_redirect (optarg);
7423d8817e4Smiod parser_input = input_defsym;
7433d8817e4Smiod parsing_defsym = 1;
7443d8817e4Smiod yyparse ();
7453d8817e4Smiod parsing_defsym = 0;
7463d8817e4Smiod lex_string = NULL;
7473d8817e4Smiod break;
7483d8817e4Smiod case OPTION_DEMANGLE:
7493d8817e4Smiod demangling = TRUE;
7503d8817e4Smiod if (optarg != NULL)
7513d8817e4Smiod {
7523d8817e4Smiod enum demangling_styles style;
7533d8817e4Smiod
7543d8817e4Smiod style = cplus_demangle_name_to_style (optarg);
7553d8817e4Smiod if (style == unknown_demangling)
7563d8817e4Smiod einfo (_("%F%P: unknown demangling style `%s'"),
7573d8817e4Smiod optarg);
7583d8817e4Smiod
7593d8817e4Smiod cplus_demangle_set_style (style);
7603d8817e4Smiod }
7613d8817e4Smiod break;
7623d8817e4Smiod case 'I': /* Used on Solaris. */
7633d8817e4Smiod case OPTION_DYNAMIC_LINKER:
7643d8817e4Smiod command_line.interpreter = optarg;
7653d8817e4Smiod break;
7663d8817e4Smiod case OPTION_SYSROOT:
7673d8817e4Smiod /* Already handled in ldmain.c. */
7683d8817e4Smiod break;
7693d8817e4Smiod case OPTION_EB:
7703d8817e4Smiod command_line.endian = ENDIAN_BIG;
7713d8817e4Smiod break;
7723d8817e4Smiod case OPTION_EL:
7733d8817e4Smiod command_line.endian = ENDIAN_LITTLE;
7743d8817e4Smiod break;
7753d8817e4Smiod case OPTION_EMBEDDED_RELOCS:
7763d8817e4Smiod command_line.embedded_relocs = TRUE;
7773d8817e4Smiod break;
778*754e8b3dSkettenis case OPTION_EXECUTE_ONLY:
779*754e8b3dSkettenis link_info.execute_only = TRUE;
780*754e8b3dSkettenis break;
781*754e8b3dSkettenis case OPTION_NO_EXECUTE_ONLY:
782*754e8b3dSkettenis link_info.execute_only = FALSE;
783*754e8b3dSkettenis break;
7843d8817e4Smiod case OPTION_EXPORT_DYNAMIC:
7853d8817e4Smiod case 'E': /* HP/UX compatibility. */
7863d8817e4Smiod link_info.export_dynamic = TRUE;
7873d8817e4Smiod break;
7883d8817e4Smiod case 'e':
7893d8817e4Smiod lang_add_entry (optarg, TRUE);
7903d8817e4Smiod break;
7913d8817e4Smiod case 'f':
7923d8817e4Smiod if (command_line.auxiliary_filters == NULL)
7933d8817e4Smiod {
7943d8817e4Smiod command_line.auxiliary_filters = xmalloc (2 * sizeof (char *));
7953d8817e4Smiod command_line.auxiliary_filters[0] = optarg;
7963d8817e4Smiod command_line.auxiliary_filters[1] = NULL;
7973d8817e4Smiod }
7983d8817e4Smiod else
7993d8817e4Smiod {
8003d8817e4Smiod int c;
8013d8817e4Smiod char **p;
8023d8817e4Smiod
8033d8817e4Smiod c = 0;
8043d8817e4Smiod for (p = command_line.auxiliary_filters; *p != NULL; p++)
8053d8817e4Smiod ++c;
8063d8817e4Smiod command_line.auxiliary_filters
8073d8817e4Smiod = xrealloc (command_line.auxiliary_filters,
8083d8817e4Smiod (c + 2) * sizeof (char *));
8093d8817e4Smiod command_line.auxiliary_filters[c] = optarg;
8103d8817e4Smiod command_line.auxiliary_filters[c + 1] = NULL;
8113d8817e4Smiod }
8123d8817e4Smiod break;
8133d8817e4Smiod case 'F':
8143d8817e4Smiod command_line.filter_shlib = optarg;
8153d8817e4Smiod break;
8163d8817e4Smiod case OPTION_FORCE_EXE_SUFFIX:
8173d8817e4Smiod command_line.force_exe_suffix = TRUE;
8183d8817e4Smiod break;
8193d8817e4Smiod case 'G':
8203d8817e4Smiod {
8213d8817e4Smiod char *end;
8223d8817e4Smiod g_switch_value = strtoul (optarg, &end, 0);
8233d8817e4Smiod if (*end)
8243d8817e4Smiod einfo (_("%P%F: invalid number `%s'\n"), optarg);
8253d8817e4Smiod }
8263d8817e4Smiod break;
8273d8817e4Smiod case 'g':
8283d8817e4Smiod /* Ignore. */
8293d8817e4Smiod break;
8303d8817e4Smiod case OPTION_GC_SECTIONS:
8313d8817e4Smiod link_info.gc_sections = TRUE;
8323d8817e4Smiod break;
8333d8817e4Smiod case OPTION_HELP:
8343d8817e4Smiod help ();
8353d8817e4Smiod xexit (0);
8363d8817e4Smiod break;
8373d8817e4Smiod case 'L':
8383d8817e4Smiod ldfile_add_library_path (optarg, TRUE);
8393d8817e4Smiod break;
8403d8817e4Smiod case 'l':
8413d8817e4Smiod lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL);
8423d8817e4Smiod break;
8433d8817e4Smiod case 'M':
8443d8817e4Smiod config.map_filename = "-";
8453d8817e4Smiod break;
8463d8817e4Smiod case 'm':
8473d8817e4Smiod /* Ignore. Was handled in a pre-parse. */
8483d8817e4Smiod break;
8493d8817e4Smiod case OPTION_MAP:
8503d8817e4Smiod config.map_filename = optarg;
8513d8817e4Smiod break;
8523d8817e4Smiod case 'N':
8533d8817e4Smiod config.text_read_only = FALSE;
8543d8817e4Smiod config.magic_demand_paged = FALSE;
8553d8817e4Smiod config.dynamic_link = FALSE;
8563d8817e4Smiod break;
8573d8817e4Smiod case OPTION_NO_OMAGIC:
8583d8817e4Smiod config.text_read_only = TRUE;
8593d8817e4Smiod config.magic_demand_paged = TRUE;
8603d8817e4Smiod /* NB/ Does not set dynamic_link to TRUE.
8613d8817e4Smiod Use --call-shared or -Bdynamic for this. */
8623d8817e4Smiod break;
8633d8817e4Smiod case 'n':
8643d8817e4Smiod config.magic_demand_paged = FALSE;
8653d8817e4Smiod config.dynamic_link = FALSE;
8663d8817e4Smiod break;
8673d8817e4Smiod case OPTION_NO_DEFINE_COMMON:
8683d8817e4Smiod command_line.inhibit_common_definition = TRUE;
8693d8817e4Smiod break;
8703d8817e4Smiod case OPTION_NO_DEMANGLE:
8713d8817e4Smiod demangling = FALSE;
8723d8817e4Smiod break;
8733d8817e4Smiod case OPTION_NO_GC_SECTIONS:
8743d8817e4Smiod link_info.gc_sections = FALSE;
8753d8817e4Smiod break;
8763d8817e4Smiod case OPTION_NO_KEEP_MEMORY:
8773d8817e4Smiod link_info.keep_memory = FALSE;
8783d8817e4Smiod break;
8793d8817e4Smiod case OPTION_NO_UNDEFINED:
8803d8817e4Smiod link_info.unresolved_syms_in_objects
8813d8817e4Smiod = how_to_report_unresolved_symbols;
8823d8817e4Smiod break;
8833d8817e4Smiod case OPTION_ALLOW_SHLIB_UNDEFINED:
8843d8817e4Smiod link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
8853d8817e4Smiod break;
8863d8817e4Smiod case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
8873d8817e4Smiod link_info.unresolved_syms_in_shared_libs
8883d8817e4Smiod = how_to_report_unresolved_symbols;
8893d8817e4Smiod break;
8903d8817e4Smiod case OPTION_UNRESOLVED_SYMBOLS:
8913d8817e4Smiod if (strcmp (optarg, "ignore-all") == 0)
8923d8817e4Smiod {
8933d8817e4Smiod link_info.unresolved_syms_in_objects = RM_IGNORE;
8943d8817e4Smiod link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
8953d8817e4Smiod }
8963d8817e4Smiod else if (strcmp (optarg, "report-all") == 0)
8973d8817e4Smiod {
8983d8817e4Smiod link_info.unresolved_syms_in_objects
8993d8817e4Smiod = how_to_report_unresolved_symbols;
9003d8817e4Smiod link_info.unresolved_syms_in_shared_libs
9013d8817e4Smiod = how_to_report_unresolved_symbols;
9023d8817e4Smiod }
9033d8817e4Smiod else if (strcmp (optarg, "ignore-in-object-files") == 0)
9043d8817e4Smiod {
9053d8817e4Smiod link_info.unresolved_syms_in_objects = RM_IGNORE;
9063d8817e4Smiod link_info.unresolved_syms_in_shared_libs
9073d8817e4Smiod = how_to_report_unresolved_symbols;
9083d8817e4Smiod }
9093d8817e4Smiod else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
9103d8817e4Smiod {
9113d8817e4Smiod link_info.unresolved_syms_in_objects
9123d8817e4Smiod = how_to_report_unresolved_symbols;
9133d8817e4Smiod link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
9143d8817e4Smiod }
9153d8817e4Smiod else
9163d8817e4Smiod einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg);
9173d8817e4Smiod break;
9183d8817e4Smiod case OPTION_WARN_UNRESOLVED_SYMBOLS:
9193d8817e4Smiod how_to_report_unresolved_symbols = RM_GENERATE_WARNING;
9203d8817e4Smiod if (link_info.unresolved_syms_in_objects == RM_GENERATE_ERROR)
9213d8817e4Smiod link_info.unresolved_syms_in_objects = RM_GENERATE_WARNING;
9223d8817e4Smiod if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
9233d8817e4Smiod link_info.unresolved_syms_in_shared_libs = RM_GENERATE_WARNING;
9243d8817e4Smiod break;
9253d8817e4Smiod
9263d8817e4Smiod case OPTION_ERROR_UNRESOLVED_SYMBOLS:
9273d8817e4Smiod how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
9283d8817e4Smiod if (link_info.unresolved_syms_in_objects == RM_GENERATE_WARNING)
9293d8817e4Smiod link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
9303d8817e4Smiod if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_WARNING)
9313d8817e4Smiod link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
9323d8817e4Smiod break;
9333d8817e4Smiod case OPTION_ALLOW_MULTIPLE_DEFINITION:
9343d8817e4Smiod link_info.allow_multiple_definition = TRUE;
9353d8817e4Smiod break;
9363d8817e4Smiod case OPTION_NO_UNDEFINED_VERSION:
9373d8817e4Smiod link_info.allow_undefined_version = FALSE;
9383d8817e4Smiod break;
9393d8817e4Smiod case OPTION_DEFAULT_SYMVER:
9403d8817e4Smiod link_info.create_default_symver = TRUE;
9413d8817e4Smiod break;
9423d8817e4Smiod case OPTION_DEFAULT_IMPORTED_SYMVER:
9433d8817e4Smiod link_info.default_imported_symver = TRUE;
9443d8817e4Smiod break;
9453d8817e4Smiod case OPTION_NO_WARN_MISMATCH:
9463d8817e4Smiod command_line.warn_mismatch = FALSE;
9473d8817e4Smiod break;
9483d8817e4Smiod case OPTION_NOINHIBIT_EXEC:
9493d8817e4Smiod force_make_executable = TRUE;
9503d8817e4Smiod break;
9513d8817e4Smiod case OPTION_NOSTDLIB:
9523d8817e4Smiod config.only_cmd_line_lib_dirs = TRUE;
9533d8817e4Smiod break;
9543d8817e4Smiod case OPTION_NO_WHOLE_ARCHIVE:
9553d8817e4Smiod whole_archive = FALSE;
9563d8817e4Smiod break;
9573d8817e4Smiod case 'O':
9583d8817e4Smiod /* FIXME "-O<non-digits> <value>" used to set the address of
9593d8817e4Smiod section <non-digits>. Was this for compatibility with
9603d8817e4Smiod something, or can we create a new option to do that
9613d8817e4Smiod (with a syntax similar to -defsym)?
9623d8817e4Smiod getopt can't handle two args to an option without kludges. */
9633d8817e4Smiod
9643d8817e4Smiod /* Enable optimizations of output files. */
9653d8817e4Smiod link_info.optimize = strtoul (optarg, NULL, 0) ? TRUE : FALSE;
9663d8817e4Smiod break;
9673d8817e4Smiod case 'o':
9683d8817e4Smiod lang_add_output (optarg, 0);
9693d8817e4Smiod break;
9703d8817e4Smiod case OPTION_OFORMAT:
9713d8817e4Smiod lang_add_output_format (optarg, NULL, NULL, 0);
9723d8817e4Smiod break;
9733d8817e4Smiod case 'q':
9743d8817e4Smiod link_info.emitrelocations = TRUE;
9753d8817e4Smiod break;
9763d8817e4Smiod case 'i':
9773d8817e4Smiod case 'r':
9783d8817e4Smiod if (optind == last_optind)
9793d8817e4Smiod /* This can happen if the user put "-rpath,a" on the command
9803d8817e4Smiod line. (Or something similar. The comma is important).
9813d8817e4Smiod Getopt becomes confused and thinks that this is a -r option
9823d8817e4Smiod but it cannot parse the text after the -r so it refuses to
9833d8817e4Smiod increment the optind counter. Detect this case and issue
9843d8817e4Smiod an error message here. We cannot just make this a warning,
9853d8817e4Smiod increment optind, and continue because getopt is too confused
9863d8817e4Smiod and will seg-fault the next time around. */
9873d8817e4Smiod einfo(_("%P%F: bad -rpath option\n"));
9883d8817e4Smiod
9893d8817e4Smiod link_info.relocatable = TRUE;
9903d8817e4Smiod config.build_constructors = FALSE;
9913d8817e4Smiod config.magic_demand_paged = FALSE;
9923d8817e4Smiod config.text_read_only = FALSE;
9933d8817e4Smiod config.dynamic_link = FALSE;
9943d8817e4Smiod break;
9953d8817e4Smiod case 'R':
9963d8817e4Smiod /* The GNU linker traditionally uses -R to mean to include
9973d8817e4Smiod only the symbols from a file. The Solaris linker uses -R
9983d8817e4Smiod to set the path used by the runtime linker to find
9993d8817e4Smiod libraries. This is the GNU linker -rpath argument. We
10003d8817e4Smiod try to support both simultaneously by checking the file
10013d8817e4Smiod named. If it is a directory, rather than a regular file,
10023d8817e4Smiod we assume -rpath was meant. */
10033d8817e4Smiod {
10043d8817e4Smiod struct stat s;
10053d8817e4Smiod
10063d8817e4Smiod if (stat (optarg, &s) >= 0
10073d8817e4Smiod && ! S_ISDIR (s.st_mode))
10083d8817e4Smiod {
10093d8817e4Smiod lang_add_input_file (optarg,
10103d8817e4Smiod lang_input_file_is_symbols_only_enum,
10113d8817e4Smiod NULL);
10123d8817e4Smiod break;
10133d8817e4Smiod }
10143d8817e4Smiod }
10153d8817e4Smiod /* Fall through. */
10163d8817e4Smiod case OPTION_RPATH:
10173d8817e4Smiod if (command_line.rpath == NULL)
10183d8817e4Smiod command_line.rpath = xstrdup (optarg);
10193d8817e4Smiod else
10203d8817e4Smiod {
10213d8817e4Smiod size_t rpath_len = strlen (command_line.rpath);
10223d8817e4Smiod size_t optarg_len = strlen (optarg);
10233d8817e4Smiod char *buf;
10243d8817e4Smiod char *cp = command_line.rpath;
10253d8817e4Smiod
10263d8817e4Smiod /* First see whether OPTARG is already in the path. */
10273d8817e4Smiod do
10283d8817e4Smiod {
10293d8817e4Smiod size_t idx = 0;
10303d8817e4Smiod
10313d8817e4Smiod while (optarg[idx] != '\0' && optarg[idx] == cp[idx])
10323d8817e4Smiod ++idx;
10333d8817e4Smiod if (optarg[idx] == '\0'
10343d8817e4Smiod && (cp[idx] == '\0' || cp[idx] == ':'))
10353d8817e4Smiod /* We found it. */
10363d8817e4Smiod break;
10373d8817e4Smiod
10383d8817e4Smiod /* Not yet found. */
10393d8817e4Smiod cp = strchr (cp, ':');
10403d8817e4Smiod if (cp != NULL)
10413d8817e4Smiod ++cp;
10423d8817e4Smiod }
10433d8817e4Smiod while (cp != NULL);
10443d8817e4Smiod
10453d8817e4Smiod if (cp == NULL)
10463d8817e4Smiod {
10473d8817e4Smiod buf = xmalloc (rpath_len + optarg_len + 2);
10483d8817e4Smiod sprintf (buf, "%s:%s", command_line.rpath, optarg);
10493d8817e4Smiod free (command_line.rpath);
10503d8817e4Smiod command_line.rpath = buf;
10513d8817e4Smiod }
10523d8817e4Smiod }
10533d8817e4Smiod break;
10543d8817e4Smiod case OPTION_RPATH_LINK:
10553d8817e4Smiod if (command_line.rpath_link == NULL)
10563d8817e4Smiod command_line.rpath_link = xstrdup (optarg);
10573d8817e4Smiod else
10583d8817e4Smiod {
10593d8817e4Smiod char *buf;
10603d8817e4Smiod
10613d8817e4Smiod buf = xmalloc (strlen (command_line.rpath_link)
10623d8817e4Smiod + strlen (optarg)
10633d8817e4Smiod + 2);
10643d8817e4Smiod sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
10653d8817e4Smiod free (command_line.rpath_link);
10663d8817e4Smiod command_line.rpath_link = buf;
10673d8817e4Smiod }
10683d8817e4Smiod break;
10693d8817e4Smiod case OPTION_RELAX:
10703d8817e4Smiod command_line.relax = TRUE;
10713d8817e4Smiod break;
10723d8817e4Smiod case OPTION_RETAIN_SYMBOLS_FILE:
10733d8817e4Smiod add_keepsyms_file (optarg);
10743d8817e4Smiod break;
10753d8817e4Smiod case 'S':
10763d8817e4Smiod link_info.strip = strip_debugger;
10773d8817e4Smiod break;
10783d8817e4Smiod case 's':
10793d8817e4Smiod link_info.strip = strip_all;
10803d8817e4Smiod break;
10813d8817e4Smiod case OPTION_STRIP_DISCARDED:
10823d8817e4Smiod link_info.strip_discarded = TRUE;
10833d8817e4Smiod break;
10843d8817e4Smiod case OPTION_NO_STRIP_DISCARDED:
10853d8817e4Smiod link_info.strip_discarded = FALSE;
10863d8817e4Smiod break;
10873d8817e4Smiod case OPTION_SHARED:
10883d8817e4Smiod if (config.has_shared)
10893d8817e4Smiod {
10903d8817e4Smiod link_info.shared = TRUE;
10919622a78fSpascal link_info.pie = FALSE;
10923d8817e4Smiod /* When creating a shared library, the default
10933d8817e4Smiod behaviour is to ignore any unresolved references. */
10943d8817e4Smiod if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
10953d8817e4Smiod link_info.unresolved_syms_in_objects = RM_IGNORE;
10963d8817e4Smiod if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
10973d8817e4Smiod link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
10983d8817e4Smiod }
10993d8817e4Smiod else
11003d8817e4Smiod einfo (_("%P%F: -shared not supported\n"));
11013d8817e4Smiod break;
11023d8817e4Smiod case OPTION_PIE:
11033d8817e4Smiod if (config.has_shared)
11043d8817e4Smiod {
11053d8817e4Smiod link_info.shared = TRUE;
11063d8817e4Smiod link_info.pie = TRUE;
11073d8817e4Smiod }
11083d8817e4Smiod else
11093d8817e4Smiod einfo (_("%P%F: -pie not supported\n"));
11103d8817e4Smiod break;
11119622a78fSpascal case OPTION_NOPIE:
11129622a78fSpascal if (config.has_shared)
11139622a78fSpascal {
11149622a78fSpascal link_info.shared = FALSE;
11159622a78fSpascal link_info.pie = FALSE;
11169622a78fSpascal }
11179622a78fSpascal else
11189622a78fSpascal einfo (_("%P%F: -nopie not supported\n"));
11199622a78fSpascal break;
11203d8817e4Smiod case 'h': /* Used on Solaris. */
11213d8817e4Smiod case OPTION_SONAME:
11223d8817e4Smiod command_line.soname = optarg;
11233d8817e4Smiod break;
11243d8817e4Smiod case OPTION_SORT_COMMON:
11253d8817e4Smiod config.sort_common = TRUE;
11263d8817e4Smiod break;
11273d8817e4Smiod case OPTION_SORT_SECTION:
11283d8817e4Smiod if (strcmp (optarg, N_("name")) == 0)
11293d8817e4Smiod sort_section = by_name;
11303d8817e4Smiod else if (strcmp (optarg, N_("alignment")) == 0)
11313d8817e4Smiod sort_section = by_alignment;
11323d8817e4Smiod else
11333d8817e4Smiod einfo (_("%P%F: invalid section sorting option: %s\n"),
11343d8817e4Smiod optarg);
11353d8817e4Smiod break;
11363d8817e4Smiod case OPTION_STATS:
11373d8817e4Smiod config.stats = TRUE;
11383d8817e4Smiod break;
11393d8817e4Smiod case OPTION_SYMBOLIC:
11403d8817e4Smiod link_info.symbolic = TRUE;
11413d8817e4Smiod break;
11423d8817e4Smiod case 't':
11433d8817e4Smiod trace_files = TRUE;
11443d8817e4Smiod break;
11453d8817e4Smiod case 'T':
11463d8817e4Smiod ldfile_open_command_file (optarg);
11473d8817e4Smiod parser_input = input_script;
11483d8817e4Smiod yyparse ();
11493d8817e4Smiod break;
11503d8817e4Smiod case OPTION_SECTION_START:
11513d8817e4Smiod {
11523d8817e4Smiod char *optarg2;
11533d8817e4Smiod char *sec_name;
11543d8817e4Smiod int len;
11553d8817e4Smiod
11563d8817e4Smiod /* Check for <something>=<somthing>... */
11573d8817e4Smiod optarg2 = strchr (optarg, '=');
11583d8817e4Smiod if (optarg2 == NULL)
11593d8817e4Smiod einfo (_("%P%F: invalid argument to option"
11603d8817e4Smiod " \"--section-start\"\n"));
11613d8817e4Smiod
11623d8817e4Smiod optarg2++;
11633d8817e4Smiod
11643d8817e4Smiod /* So far so good. Are all the args present? */
11653d8817e4Smiod if ((*optarg == '\0') || (*optarg2 == '\0'))
11663d8817e4Smiod einfo (_("%P%F: missing argument(s) to option"
11673d8817e4Smiod " \"--section-start\"\n"));
11683d8817e4Smiod
11693d8817e4Smiod /* We must copy the section name as set_section_start
11703d8817e4Smiod doesn't do it for us. */
11713d8817e4Smiod len = optarg2 - optarg;
11723d8817e4Smiod sec_name = xmalloc (len);
11733d8817e4Smiod memcpy (sec_name, optarg, len - 1);
11743d8817e4Smiod sec_name[len - 1] = 0;
11753d8817e4Smiod
11763d8817e4Smiod /* Then set it... */
11773d8817e4Smiod set_section_start (sec_name, optarg2);
11783d8817e4Smiod }
11793d8817e4Smiod break;
11803d8817e4Smiod case OPTION_TARGET_HELP:
11813d8817e4Smiod /* Mention any target specific options. */
11823d8817e4Smiod ldemul_list_emulation_options (stdout);
11833d8817e4Smiod exit (0);
11843d8817e4Smiod case OPTION_TBSS:
11853d8817e4Smiod set_segment_start (".bss", optarg);
11863d8817e4Smiod break;
11873d8817e4Smiod case OPTION_TDATA:
11883d8817e4Smiod set_segment_start (".data", optarg);
11893d8817e4Smiod break;
11903d8817e4Smiod case OPTION_TTEXT:
11913d8817e4Smiod set_segment_start (".text", optarg);
11923d8817e4Smiod break;
11933d8817e4Smiod case OPTION_TRADITIONAL_FORMAT:
11943d8817e4Smiod link_info.traditional_format = TRUE;
11953d8817e4Smiod break;
11963d8817e4Smiod case OPTION_TASK_LINK:
11973d8817e4Smiod link_info.task_link = TRUE;
11983d8817e4Smiod /* Fall through - do an implied -r option. */
11993d8817e4Smiod case OPTION_UR:
12003d8817e4Smiod link_info.relocatable = TRUE;
12013d8817e4Smiod config.build_constructors = TRUE;
12023d8817e4Smiod config.magic_demand_paged = FALSE;
12033d8817e4Smiod config.text_read_only = FALSE;
12043d8817e4Smiod config.dynamic_link = FALSE;
12053d8817e4Smiod break;
12063d8817e4Smiod case 'u':
12073d8817e4Smiod ldlang_add_undef (optarg);
12083d8817e4Smiod break;
12093d8817e4Smiod case OPTION_UNIQUE:
12103d8817e4Smiod if (optarg != NULL)
12113d8817e4Smiod lang_add_unique (optarg);
12123d8817e4Smiod else
12133d8817e4Smiod config.unique_orphan_sections = TRUE;
12143d8817e4Smiod break;
12153d8817e4Smiod case OPTION_VERBOSE:
12163d8817e4Smiod ldversion (1);
12173d8817e4Smiod version_printed = TRUE;
12183d8817e4Smiod trace_file_tries = TRUE;
12193d8817e4Smiod overflow_cutoff_limit = -2;
12203d8817e4Smiod break;
12213d8817e4Smiod case 'v':
12223d8817e4Smiod ldversion (0);
12233d8817e4Smiod version_printed = TRUE;
12243d8817e4Smiod break;
12253d8817e4Smiod case 'V':
12263d8817e4Smiod ldversion (1);
12273d8817e4Smiod version_printed = TRUE;
12283d8817e4Smiod break;
12293d8817e4Smiod case OPTION_VERSION:
12303d8817e4Smiod ldversion (2);
12313d8817e4Smiod xexit (0);
12323d8817e4Smiod break;
12333d8817e4Smiod case OPTION_VERSION_SCRIPT:
12343d8817e4Smiod /* This option indicates a small script that only specifies
12353d8817e4Smiod version information. Read it, but don't assume that
12363d8817e4Smiod we've seen a linker script. */
12373d8817e4Smiod {
12383d8817e4Smiod FILE *hold_script_handle;
12393d8817e4Smiod
12403d8817e4Smiod hold_script_handle = saved_script_handle;
12413d8817e4Smiod ldfile_open_command_file (optarg);
12423d8817e4Smiod saved_script_handle = hold_script_handle;
12433d8817e4Smiod parser_input = input_version_script;
12443d8817e4Smiod yyparse ();
12453d8817e4Smiod }
12463d8817e4Smiod break;
12473d8817e4Smiod case OPTION_VERSION_EXPORTS_SECTION:
12483d8817e4Smiod /* This option records a version symbol to be applied to the
12493d8817e4Smiod symbols listed for export to be found in the object files
12503d8817e4Smiod .exports sections. */
12513d8817e4Smiod command_line.version_exports_section = optarg;
12523d8817e4Smiod break;
12533d8817e4Smiod case OPTION_WARN_COMMON:
12543d8817e4Smiod config.warn_common = TRUE;
12553d8817e4Smiod break;
12563d8817e4Smiod case OPTION_WARN_CONSTRUCTORS:
12573d8817e4Smiod config.warn_constructors = TRUE;
12583d8817e4Smiod break;
12593d8817e4Smiod case OPTION_WARN_FATAL:
12603d8817e4Smiod config.fatal_warnings = TRUE;
12613d8817e4Smiod break;
12623d8817e4Smiod case OPTION_WARN_MULTIPLE_GP:
12633d8817e4Smiod config.warn_multiple_gp = TRUE;
12643d8817e4Smiod break;
12653d8817e4Smiod case OPTION_WARN_ONCE:
12663d8817e4Smiod config.warn_once = TRUE;
12673d8817e4Smiod break;
12683d8817e4Smiod case OPTION_WARN_SECTION_ALIGN:
12693d8817e4Smiod config.warn_section_align = TRUE;
12703d8817e4Smiod break;
12713d8817e4Smiod case OPTION_WARN_SHARED_TEXTREL:
12723d8817e4Smiod link_info.warn_shared_textrel = TRUE;
12733d8817e4Smiod break;
12743d8817e4Smiod case OPTION_WHOLE_ARCHIVE:
12753d8817e4Smiod whole_archive = TRUE;
12763d8817e4Smiod break;
12773d8817e4Smiod case OPTION_ADD_NEEDED:
12783d8817e4Smiod add_needed = TRUE;
12793d8817e4Smiod break;
12803d8817e4Smiod case OPTION_NO_ADD_NEEDED:
12813d8817e4Smiod add_needed = FALSE;
12823d8817e4Smiod break;
12833d8817e4Smiod case OPTION_AS_NEEDED:
12843d8817e4Smiod as_needed = TRUE;
12853d8817e4Smiod break;
12863d8817e4Smiod case OPTION_NO_AS_NEEDED:
12873d8817e4Smiod as_needed = FALSE;
12883d8817e4Smiod break;
12893d8817e4Smiod case OPTION_WRAP:
12903d8817e4Smiod add_wrap (optarg);
12913d8817e4Smiod break;
12923d8817e4Smiod case OPTION_DISCARD_NONE:
12933d8817e4Smiod link_info.discard = discard_none;
12943d8817e4Smiod break;
12953d8817e4Smiod case 'X':
12963d8817e4Smiod link_info.discard = discard_l;
12973d8817e4Smiod break;
12983d8817e4Smiod case 'x':
12993d8817e4Smiod link_info.discard = discard_all;
13003d8817e4Smiod break;
13013d8817e4Smiod case 'Y':
13023d8817e4Smiod if (strncmp (optarg, "P,", 2) == 0)
13033d8817e4Smiod optarg += 2;
13043d8817e4Smiod if (default_dirlist != NULL)
13053d8817e4Smiod free (default_dirlist);
13063d8817e4Smiod default_dirlist = xstrdup (optarg);
13073d8817e4Smiod break;
13083d8817e4Smiod case 'y':
13093d8817e4Smiod add_ysym (optarg);
13103d8817e4Smiod break;
1311d2386abeSmiod case 'Z':
1312d2386abeSmiod config.data_bss_contig = TRUE;
1313d2386abeSmiod break;
13143d8817e4Smiod case OPTION_SPARE_DYNAMIC_TAGS:
13153d8817e4Smiod link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0);
13163d8817e4Smiod break;
13173d8817e4Smiod case OPTION_SPLIT_BY_RELOC:
13183d8817e4Smiod if (optarg != NULL)
13193d8817e4Smiod config.split_by_reloc = strtoul (optarg, NULL, 0);
13203d8817e4Smiod else
13213d8817e4Smiod config.split_by_reloc = 32768;
13223d8817e4Smiod break;
13233d8817e4Smiod case OPTION_SPLIT_BY_FILE:
13243d8817e4Smiod if (optarg != NULL)
13253d8817e4Smiod config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
13263d8817e4Smiod else
13273d8817e4Smiod config.split_by_file = 1;
13283d8817e4Smiod break;
13293d8817e4Smiod case OPTION_CHECK_SECTIONS:
13303d8817e4Smiod command_line.check_section_addresses = TRUE;
13313d8817e4Smiod break;
13323d8817e4Smiod case OPTION_NO_CHECK_SECTIONS:
13333d8817e4Smiod command_line.check_section_addresses = FALSE;
13343d8817e4Smiod break;
13353d8817e4Smiod case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
13363d8817e4Smiod command_line.accept_unknown_input_arch = TRUE;
13373d8817e4Smiod break;
13383d8817e4Smiod case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
13393d8817e4Smiod command_line.accept_unknown_input_arch = FALSE;
13403d8817e4Smiod break;
13413d8817e4Smiod case '(':
13423d8817e4Smiod if (ingroup)
13433d8817e4Smiod einfo (_("%P%F: may not nest groups (--help for usage)\n"));
13443d8817e4Smiod
13453d8817e4Smiod lang_enter_group ();
13463d8817e4Smiod ingroup = 1;
13473d8817e4Smiod break;
13483d8817e4Smiod case ')':
13493d8817e4Smiod if (! ingroup)
13503d8817e4Smiod einfo (_("%P%F: group ended before it began (--help for usage)\n"));
13513d8817e4Smiod
13523d8817e4Smiod lang_leave_group ();
13533d8817e4Smiod ingroup = 0;
13543d8817e4Smiod break;
13553d8817e4Smiod
13563d8817e4Smiod case OPTION_INIT:
13573d8817e4Smiod link_info.init_function = optarg;
13583d8817e4Smiod break;
13593d8817e4Smiod
13603d8817e4Smiod case OPTION_FINI:
13613d8817e4Smiod link_info.fini_function = optarg;
13623d8817e4Smiod break;
13633d8817e4Smiod
13643d8817e4Smiod case OPTION_REDUCE_MEMORY_OVERHEADS:
1365b8417449Sstefan link_info.reduce_memory_overheads = TRUE;
13663d8817e4Smiod if (config.hash_table_size == 0)
13673d8817e4Smiod config.hash_table_size = 1021;
13683d8817e4Smiod break;
13693d8817e4Smiod
13703d8817e4Smiod case OPTION_HASH_SIZE:
13713d8817e4Smiod {
13723d8817e4Smiod bfd_size_type new_size;
13733d8817e4Smiod
13743d8817e4Smiod new_size = strtoul (optarg, NULL, 0);
13753d8817e4Smiod if (new_size)
13763d8817e4Smiod config.hash_table_size = new_size;
13773d8817e4Smiod else
13783d8817e4Smiod einfo (_("%P%X: --hash-size needs a numeric argument\n"));
13793d8817e4Smiod }
13803d8817e4Smiod break;
13813d8817e4Smiod }
13823d8817e4Smiod }
13833d8817e4Smiod
13843d8817e4Smiod if (ingroup)
13853d8817e4Smiod lang_leave_group ();
13863d8817e4Smiod
13873d8817e4Smiod if (default_dirlist != NULL)
13883d8817e4Smiod {
13893d8817e4Smiod set_default_dirlist (default_dirlist);
13903d8817e4Smiod free (default_dirlist);
13913d8817e4Smiod }
13923d8817e4Smiod
13933d8817e4Smiod if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
13943d8817e4Smiod /* FIXME: Should we allow emulations a chance to set this ? */
13953d8817e4Smiod link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
13963d8817e4Smiod
13973d8817e4Smiod if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
13983d8817e4Smiod /* FIXME: Should we allow emulations a chance to set this ? */
13993d8817e4Smiod link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
14003d8817e4Smiod }
14013d8817e4Smiod
14023d8817e4Smiod /* Add the (colon-separated) elements of DIRLIST_PTR to the
14033d8817e4Smiod library search path. */
14043d8817e4Smiod
14053d8817e4Smiod static void
set_default_dirlist(char * dirlist_ptr)14063d8817e4Smiod set_default_dirlist (char *dirlist_ptr)
14073d8817e4Smiod {
14083d8817e4Smiod char *p;
14093d8817e4Smiod
14103d8817e4Smiod while (1)
14113d8817e4Smiod {
14123d8817e4Smiod p = strchr (dirlist_ptr, PATH_SEPARATOR);
14133d8817e4Smiod if (p != NULL)
14143d8817e4Smiod *p = '\0';
14153d8817e4Smiod if (*dirlist_ptr != '\0')
14163d8817e4Smiod ldfile_add_library_path (dirlist_ptr, TRUE);
14173d8817e4Smiod if (p == NULL)
14183d8817e4Smiod break;
14193d8817e4Smiod dirlist_ptr = p + 1;
14203d8817e4Smiod }
14213d8817e4Smiod }
14223d8817e4Smiod
14233d8817e4Smiod static void
set_section_start(char * sect,char * valstr)14243d8817e4Smiod set_section_start (char *sect, char *valstr)
14253d8817e4Smiod {
14263d8817e4Smiod const char *end;
14273d8817e4Smiod bfd_vma val = bfd_scan_vma (valstr, &end, 16);
14283d8817e4Smiod if (*end)
14293d8817e4Smiod einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
14303d8817e4Smiod lang_section_start (sect, exp_intop (val), NULL);
14313d8817e4Smiod }
14323d8817e4Smiod
14333d8817e4Smiod static void
set_segment_start(const char * section,char * valstr)14343d8817e4Smiod set_segment_start (const char *section, char *valstr)
14353d8817e4Smiod {
14363d8817e4Smiod const char *name;
14373d8817e4Smiod const char *end;
14383d8817e4Smiod segment_type *seg;
14393d8817e4Smiod
14403d8817e4Smiod bfd_vma val = bfd_scan_vma (valstr, &end, 16);
14413d8817e4Smiod if (*end)
14423d8817e4Smiod einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
14433d8817e4Smiod /* If we already have an entry for this segment, update the existing
14443d8817e4Smiod value. */
14453d8817e4Smiod name = section + 1;
14463d8817e4Smiod for (seg = segments; seg; seg = seg->next)
14473d8817e4Smiod if (strcmp (seg->name, name) == 0)
14483d8817e4Smiod {
14493d8817e4Smiod seg->value = val;
14503d8817e4Smiod return;
14513d8817e4Smiod }
14523d8817e4Smiod /* There was no existing value so we must create a new segment
14533d8817e4Smiod entry. */
14543d8817e4Smiod seg = stat_alloc (sizeof (*seg));
14553d8817e4Smiod seg->name = name;
14563d8817e4Smiod seg->value = val;
14573d8817e4Smiod seg->used = FALSE;
14583d8817e4Smiod /* Add it to the linked list of segments. */
14593d8817e4Smiod seg->next = segments;
14603d8817e4Smiod segments = seg;
14613d8817e4Smiod /* Historically, -Ttext and friends set the base address of a
14623d8817e4Smiod particular section. For backwards compatibility, we still do
14633d8817e4Smiod that. If a SEGMENT_START directive is seen, the section address
14643d8817e4Smiod assignment will be disabled. */
14653d8817e4Smiod lang_section_start (section, exp_intop (val), seg);
14663d8817e4Smiod }
14673d8817e4Smiod
14683d8817e4Smiod
14693d8817e4Smiod /* Print help messages for the options. */
14703d8817e4Smiod
14713d8817e4Smiod static void
help(void)14723d8817e4Smiod help (void)
14733d8817e4Smiod {
14743d8817e4Smiod unsigned i;
14753d8817e4Smiod const char **targets, **pp;
14763d8817e4Smiod int len;
14773d8817e4Smiod
14783d8817e4Smiod printf (_("Usage: %s [options] file...\n"), program_name);
14793d8817e4Smiod
14803d8817e4Smiod printf (_("Options:\n"));
14813d8817e4Smiod for (i = 0; i < OPTION_COUNT; i++)
14823d8817e4Smiod {
14833d8817e4Smiod if (ld_options[i].doc != NULL)
14843d8817e4Smiod {
14853d8817e4Smiod bfd_boolean comma;
14863d8817e4Smiod unsigned j;
14873d8817e4Smiod
14883d8817e4Smiod printf (" ");
14893d8817e4Smiod
14903d8817e4Smiod comma = FALSE;
14913d8817e4Smiod len = 2;
14923d8817e4Smiod
14933d8817e4Smiod j = i;
14943d8817e4Smiod do
14953d8817e4Smiod {
14963d8817e4Smiod if (ld_options[j].shortopt != '\0'
14973d8817e4Smiod && ld_options[j].control != NO_HELP)
14983d8817e4Smiod {
14993d8817e4Smiod printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
15003d8817e4Smiod len += (comma ? 2 : 0) + 2;
15013d8817e4Smiod if (ld_options[j].arg != NULL)
15023d8817e4Smiod {
15033d8817e4Smiod if (ld_options[j].opt.has_arg != optional_argument)
15043d8817e4Smiod {
15053d8817e4Smiod printf (" ");
15063d8817e4Smiod ++len;
15073d8817e4Smiod }
15083d8817e4Smiod printf ("%s", _(ld_options[j].arg));
15093d8817e4Smiod len += strlen (_(ld_options[j].arg));
15103d8817e4Smiod }
15113d8817e4Smiod comma = TRUE;
15123d8817e4Smiod }
15133d8817e4Smiod ++j;
15143d8817e4Smiod }
15153d8817e4Smiod while (j < OPTION_COUNT && ld_options[j].doc == NULL);
15163d8817e4Smiod
15173d8817e4Smiod j = i;
15183d8817e4Smiod do
15193d8817e4Smiod {
15203d8817e4Smiod if (ld_options[j].opt.name != NULL
15213d8817e4Smiod && ld_options[j].control != NO_HELP)
15223d8817e4Smiod {
15233d8817e4Smiod int two_dashes =
15243d8817e4Smiod (ld_options[j].control == TWO_DASHES
15253d8817e4Smiod || ld_options[j].control == EXACTLY_TWO_DASHES);
15263d8817e4Smiod
15273d8817e4Smiod printf ("%s-%s%s",
15283d8817e4Smiod comma ? ", " : "",
15293d8817e4Smiod two_dashes ? "-" : "",
15303d8817e4Smiod ld_options[j].opt.name);
15313d8817e4Smiod len += ((comma ? 2 : 0)
15323d8817e4Smiod + 1
15333d8817e4Smiod + (two_dashes ? 1 : 0)
15343d8817e4Smiod + strlen (ld_options[j].opt.name));
15353d8817e4Smiod if (ld_options[j].arg != NULL)
15363d8817e4Smiod {
15373d8817e4Smiod printf (" %s", _(ld_options[j].arg));
15383d8817e4Smiod len += 1 + strlen (_(ld_options[j].arg));
15393d8817e4Smiod }
15403d8817e4Smiod comma = TRUE;
15413d8817e4Smiod }
15423d8817e4Smiod ++j;
15433d8817e4Smiod }
15443d8817e4Smiod while (j < OPTION_COUNT && ld_options[j].doc == NULL);
15453d8817e4Smiod
15463d8817e4Smiod if (len >= 30)
15473d8817e4Smiod {
15483d8817e4Smiod printf ("\n");
15493d8817e4Smiod len = 0;
15503d8817e4Smiod }
15513d8817e4Smiod
15523d8817e4Smiod for (; len < 30; len++)
15533d8817e4Smiod putchar (' ');
15543d8817e4Smiod
15553d8817e4Smiod printf ("%s\n", _(ld_options[i].doc));
15563d8817e4Smiod }
15573d8817e4Smiod }
15583d8817e4Smiod printf (_(" @FILE"));
15593d8817e4Smiod for (len = strlen (" @FILE"); len < 30; len++)
15603d8817e4Smiod putchar (' ');
15613d8817e4Smiod printf (_("Read options from FILE\n"));
15623d8817e4Smiod
15633d8817e4Smiod /* Note: Various tools (such as libtool) depend upon the
15643d8817e4Smiod format of the listings below - do not change them. */
15653d8817e4Smiod /* xgettext:c-format */
15663d8817e4Smiod printf (_("%s: supported targets:"), program_name);
15673d8817e4Smiod targets = bfd_target_list ();
15683d8817e4Smiod for (pp = targets; *pp != NULL; pp++)
15693d8817e4Smiod printf (" %s", *pp);
15703d8817e4Smiod free (targets);
15713d8817e4Smiod printf ("\n");
15723d8817e4Smiod
15733d8817e4Smiod /* xgettext:c-format */
15743d8817e4Smiod printf (_("%s: supported emulations: "), program_name);
15753d8817e4Smiod ldemul_list_emulations (stdout);
15763d8817e4Smiod printf ("\n");
15773d8817e4Smiod
15783d8817e4Smiod /* xgettext:c-format */
15793d8817e4Smiod printf (_("%s: emulation specific options:\n"), program_name);
15803d8817e4Smiod ldemul_list_emulation_options (stdout);
15813d8817e4Smiod printf ("\n");
15823d8817e4Smiod
15833d8817e4Smiod printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);
15843d8817e4Smiod }
1585