Home | History | Annotate | Line # | Download | only in ld
      1   1.1     skrll /* Parse options for the GNU linker.
      2  1.14  christos    Copyright (C) 1991-2026 Free Software Foundation, Inc.
      3   1.1     skrll 
      4   1.1     skrll    This file is part of the GNU Binutils.
      5   1.1     skrll 
      6   1.1     skrll    This program is free software; you can redistribute it and/or modify
      7   1.1     skrll    it under the terms of the GNU General Public License as published by
      8   1.1     skrll    the Free Software Foundation; either version 3 of the License, or
      9   1.1     skrll    (at your option) any later version.
     10   1.1     skrll 
     11   1.1     skrll    This program is distributed in the hope that it will be useful,
     12   1.1     skrll    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   1.1     skrll    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   1.1     skrll    GNU General Public License for more details.
     15   1.1     skrll 
     16   1.1     skrll    You should have received a copy of the GNU General Public License
     17   1.1     skrll    along with this program; if not, write to the Free Software
     18   1.1     skrll    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     19   1.1     skrll    MA 02110-1301, USA.  */
     20   1.1     skrll 
     21   1.1     skrll #include "sysdep.h"
     22   1.1     skrll #include "bfd.h"
     23   1.1     skrll #include "bfdver.h"
     24   1.1     skrll #include "libiberty.h"
     25  1.11  christos #include "filenames.h"
     26   1.1     skrll #include <stdio.h>
     27   1.1     skrll #include <string.h>
     28  1.11  christos #include <errno.h>
     29   1.1     skrll #include "safe-ctype.h"
     30   1.1     skrll #include "getopt.h"
     31   1.1     skrll #include "bfdlink.h"
     32  1.10  christos #include "ctf-api.h"
     33   1.1     skrll #include "ld.h"
     34   1.1     skrll #include "ldmain.h"
     35   1.1     skrll #include "ldmisc.h"
     36   1.1     skrll #include "ldexp.h"
     37   1.1     skrll #include "ldlang.h"
     38   1.1     skrll #include <ldgram.h>
     39   1.1     skrll #include "ldlex.h"
     40   1.1     skrll #include "ldfile.h"
     41   1.1     skrll #include "ldver.h"
     42   1.1     skrll #include "ldemul.h"
     43   1.1     skrll #include "demangle.h"
     44   1.3  christos #include "plugin.h"
     45   1.1     skrll 
     46   1.1     skrll #ifndef PATH_SEPARATOR
     47   1.1     skrll #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
     48   1.1     skrll #define PATH_SEPARATOR ';'
     49   1.1     skrll #else
     50   1.1     skrll #define PATH_SEPARATOR ':'
     51   1.1     skrll #endif
     52   1.1     skrll #endif
     53   1.1     skrll 
     54   1.1     skrll /* Somewhere above, sys/stat.h got included . . . .  */
     55   1.1     skrll #if !defined(S_ISDIR) && defined(S_IFDIR)
     56   1.1     skrll #define	S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
     57   1.1     skrll #endif
     58   1.1     skrll 
     59   1.1     skrll static void set_default_dirlist (char *);
     60   1.1     skrll static void set_section_start (char *, char *);
     61   1.1     skrll static void set_segment_start (const char *, char *);
     62   1.1     skrll static void help (void);
     63   1.1     skrll 
     64   1.1     skrll /* The long options.  This structure is used for both the option
     65   1.1     skrll    parsing and the help text.  */
     66   1.1     skrll 
     67   1.3  christos enum control_enum {
     68   1.3  christos   /* Use one dash before long option name.  */
     69   1.5  christos   ONE_DASH = 1,
     70   1.3  christos   /* Use two dashes before long option name.  */
     71   1.5  christos   TWO_DASHES = 2,
     72   1.3  christos   /* Only accept two dashes before the long option name.
     73   1.3  christos      This is an overloading of the use of this enum, since originally it
     74   1.3  christos      was only intended to tell the --help display function how to display
     75   1.3  christos      the long option name.  This feature was added in order to resolve
     76   1.3  christos      the confusion about the -omagic command line switch.  Is it setting
     77   1.3  christos      the output file name to "magic" or is it setting the NMAGIC flag on
     78   1.3  christos      the output ?  It has been decided that it is setting the output file
     79   1.3  christos      name, and that if you want to set the NMAGIC flag you should use -N
     80   1.3  christos      or --omagic.  */
     81   1.3  christos   EXACTLY_TWO_DASHES,
     82   1.3  christos   /* Don't mention this option in --help output.  */
     83   1.3  christos   NO_HELP
     84   1.3  christos };
     85   1.3  christos 
     86   1.1     skrll struct ld_option
     87   1.1     skrll {
     88   1.1     skrll   /* The long option information.  */
     89   1.1     skrll   struct option opt;
     90   1.1     skrll   /* The short option with the same meaning ('\0' if none).  */
     91   1.1     skrll   char shortopt;
     92   1.1     skrll   /* The name of the argument (NULL if none).  */
     93   1.1     skrll   const char *arg;
     94   1.1     skrll   /* The documentation string.  If this is NULL, this is a synonym for
     95   1.1     skrll      the previous option.  */
     96   1.1     skrll   const char *doc;
     97   1.3  christos   enum control_enum control;
     98   1.1     skrll };
     99   1.1     skrll 
    100   1.1     skrll static const struct ld_option ld_options[] =
    101   1.1     skrll {
    102   1.1     skrll   { {NULL, required_argument, NULL, '\0'},
    103   1.1     skrll     'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"),
    104   1.1     skrll     ONE_DASH },
    105   1.1     skrll   { {"architecture", required_argument, NULL, 'A'},
    106  1.12  christos     'A', N_("ARCH"), N_("Set architecture") , EXACTLY_TWO_DASHES },
    107   1.1     skrll   { {"format", required_argument, NULL, 'b'},
    108   1.1     skrll     'b', N_("TARGET"), N_("Specify target for following input files"),
    109  1.12  christos     EXACTLY_TWO_DASHES },
    110   1.1     skrll   { {"mri-script", required_argument, NULL, 'c'},
    111  1.12  christos     'c', N_("FILE"), N_("Read MRI format linker script"), EXACTLY_TWO_DASHES },
    112   1.1     skrll   { {"dc", no_argument, NULL, 'd'},
    113   1.1     skrll     'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
    114   1.1     skrll   { {"dp", no_argument, NULL, 'd'},
    115   1.1     skrll     '\0', NULL, NULL, ONE_DASH },
    116  1.11  christos   { {"dependency-file", required_argument, NULL, OPTION_DEPENDENCY_FILE},
    117  1.11  christos     '\0', N_("FILE"), N_("Write dependency file"), TWO_DASHES },
    118   1.8  christos   { {"force-group-allocation", no_argument, NULL,
    119   1.8  christos      OPTION_FORCE_GROUP_ALLOCATION},
    120   1.8  christos     '\0', NULL, N_("Force group members out of groups"), TWO_DASHES },
    121   1.1     skrll   { {"entry", required_argument, NULL, 'e'},
    122   1.1     skrll     'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
    123   1.1     skrll   { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
    124   1.1     skrll     'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
    125   1.3  christos   { {"no-export-dynamic", no_argument, NULL, OPTION_NO_EXPORT_DYNAMIC},
    126   1.3  christos     '\0', NULL, N_("Undo the effect of --export-dynamic"), TWO_DASHES },
    127  1.11  christos   { {"enable-non-contiguous-regions", no_argument, NULL, OPTION_NON_CONTIGUOUS_REGIONS},
    128  1.11  christos     '\0', NULL, N_("Enable support of non-contiguous memory regions"), TWO_DASHES },
    129  1.11  christos   { {"enable-non-contiguous-regions-warnings", no_argument, NULL, OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS},
    130  1.11  christos     '\0', NULL, N_("Enable warnings when --enable-non-contiguous-regions may cause unexpected behaviour"), TWO_DASHES },
    131  1.12  christos   { {"disable-linker-version", no_argument, NULL, OPTION_DISABLE_LINKER_VERSION},
    132  1.12  christos     '\0', NULL, N_("Disable the LINKER_VERSION linker script directive"), TWO_DASHES },
    133  1.12  christos   { {"enable-linker-version", no_argument, NULL, OPTION_ENABLE_LINKER_VERSION},
    134  1.12  christos     '\0', NULL, N_("Enable the LINKER_VERSION linker script directive"), TWO_DASHES },
    135   1.1     skrll   { {"EB", no_argument, NULL, OPTION_EB},
    136   1.1     skrll     '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
    137   1.1     skrll   { {"EL", no_argument, NULL, OPTION_EL},
    138   1.1     skrll     '\0', NULL, N_("Link little-endian objects"), ONE_DASH },
    139   1.1     skrll   { {"auxiliary", required_argument, NULL, 'f'},
    140   1.1     skrll     'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"),
    141   1.1     skrll     TWO_DASHES },
    142   1.1     skrll   { {"filter", required_argument, NULL, 'F'},
    143   1.1     skrll     'F', N_("SHLIB"), N_("Filter for shared object symbol table"),
    144   1.1     skrll     TWO_DASHES },
    145   1.1     skrll   { {NULL, no_argument, NULL, '\0'},
    146   1.1     skrll     'g', NULL, N_("Ignored"), ONE_DASH },
    147   1.1     skrll   { {"gpsize", required_argument, NULL, 'G'},
    148   1.1     skrll     'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
    149   1.1     skrll     TWO_DASHES },
    150   1.1     skrll   { {"soname", required_argument, NULL, OPTION_SONAME},
    151   1.1     skrll     'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
    152   1.1     skrll   { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
    153   1.1     skrll     'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
    154   1.1     skrll     TWO_DASHES },
    155   1.5  christos   { {"no-dynamic-linker", no_argument, NULL, OPTION_NO_DYNAMIC_LINKER},
    156   1.5  christos     '\0', NULL, N_("Produce an executable with no program interpreter header"),
    157   1.5  christos     TWO_DASHES },
    158   1.1     skrll   { {"library", required_argument, NULL, 'l'},
    159   1.1     skrll     'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
    160   1.1     skrll   { {"library-path", required_argument, NULL, 'L'},
    161   1.1     skrll     'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
    162   1.1     skrll     TWO_DASHES },
    163   1.1     skrll   { {"sysroot=<DIRECTORY>", required_argument, NULL, OPTION_SYSROOT},
    164   1.1     skrll     '\0', NULL, N_("Override the default sysroot location"), TWO_DASHES },
    165   1.1     skrll   { {NULL, required_argument, NULL, '\0'},
    166   1.1     skrll     'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH },
    167   1.1     skrll   { {"print-map", no_argument, NULL, 'M'},
    168   1.1     skrll     'M', NULL, N_("Print map file on standard output"), TWO_DASHES },
    169   1.1     skrll   { {"nmagic", no_argument, NULL, 'n'},
    170   1.1     skrll     'n', NULL, N_("Do not page align data"), TWO_DASHES },
    171   1.1     skrll   { {"omagic", no_argument, NULL, 'N'},
    172   1.1     skrll     'N', NULL, N_("Do not page align data, do not make text readonly"),
    173   1.1     skrll     EXACTLY_TWO_DASHES },
    174   1.1     skrll   { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC},
    175   1.1     skrll     '\0', NULL, N_("Page align data, make text readonly"),
    176   1.1     skrll     EXACTLY_TWO_DASHES },
    177   1.1     skrll   { {"output", required_argument, NULL, 'o'},
    178   1.1     skrll     'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES },
    179   1.1     skrll   { {NULL, required_argument, NULL, '\0'},
    180   1.1     skrll     'O', NULL, N_("Optimize output file"), ONE_DASH },
    181   1.8  christos   { {"out-implib", required_argument, NULL, OPTION_OUT_IMPLIB},
    182   1.8  christos     '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES },
    183   1.3  christos   { {"plugin", required_argument, NULL, OPTION_PLUGIN},
    184   1.3  christos     '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
    185   1.3  christos   { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
    186   1.3  christos     '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
    187  1.13  christos   { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS},
    188  1.13  christos     '\0', NULL, N_("Store plugin intermediate files permanently"),
    189  1.13  christos     ONE_DASH },
    190   1.3  christos   { {"flto", optional_argument, NULL, OPTION_IGNORE},
    191   1.3  christos     '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
    192   1.3  christos     ONE_DASH },
    193   1.3  christos   { {"flto-partition=", required_argument, NULL, OPTION_IGNORE},
    194   1.3  christos     '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
    195   1.3  christos     ONE_DASH },
    196   1.5  christos   { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE},
    197   1.5  christos     '\0', NULL, N_("Ignored for GCC linker option compatibility"),
    198   1.5  christos     ONE_DASH },
    199   1.5  christos   { {"map-whole-files", optional_argument, NULL, OPTION_IGNORE},
    200   1.5  christos     '\0', NULL, N_("Ignored for gold option compatibility"),
    201   1.5  christos     TWO_DASHES },
    202   1.5  christos   { {"no-map-whole-files", optional_argument, NULL, OPTION_IGNORE},
    203   1.5  christos     '\0', NULL, N_("Ignored for gold option compatibility"),
    204   1.5  christos     TWO_DASHES },
    205   1.1     skrll   { {"Qy", no_argument, NULL, OPTION_IGNORE},
    206   1.1     skrll     '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
    207   1.1     skrll   { {"emit-relocs", no_argument, NULL, 'q'},
    208   1.1     skrll     'q', NULL, "Generate relocations in final output", TWO_DASHES },
    209   1.1     skrll   { {"relocatable", no_argument, NULL, 'r'},
    210   1.1     skrll     'r', NULL, N_("Generate relocatable output"), TWO_DASHES },
    211   1.1     skrll   { {NULL, no_argument, NULL, '\0'},
    212   1.1     skrll     'i', NULL, NULL, ONE_DASH },
    213   1.1     skrll   { {"just-symbols", required_argument, NULL, 'R'},
    214   1.1     skrll     'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"),
    215   1.1     skrll     TWO_DASHES },
    216  1.12  christos 
    217  1.12  christos   { {"remap-inputs-file", required_argument, NULL, OPTION_REMAP_INPUTS_FILE},
    218  1.12  christos     '\0', N_("FILE"), "Provide a FILE containing input remapings", TWO_DASHES },
    219  1.12  christos   { {"remap-inputs", required_argument, NULL, OPTION_REMAP_INPUTS},
    220  1.12  christos     '\0', N_("PATTERN=FILE"), "Remap input files matching PATTERN to FILE", TWO_DASHES },
    221  1.12  christos 
    222   1.1     skrll   { {"strip-all", no_argument, NULL, 's'},
    223   1.1     skrll     's', NULL, N_("Strip all symbols"), TWO_DASHES },
    224   1.1     skrll   { {"strip-debug", no_argument, NULL, 'S'},
    225   1.1     skrll     'S', NULL, N_("Strip debugging symbols"), TWO_DASHES },
    226   1.1     skrll   { {"strip-discarded", no_argument, NULL, OPTION_STRIP_DISCARDED},
    227   1.1     skrll     '\0', NULL, N_("Strip symbols in discarded sections"), TWO_DASHES },
    228   1.1     skrll   { {"no-strip-discarded", no_argument, NULL, OPTION_NO_STRIP_DISCARDED},
    229   1.1     skrll     '\0', NULL, N_("Do not strip symbols in discarded sections"), TWO_DASHES },
    230   1.1     skrll   { {"trace", no_argument, NULL, 't'},
    231   1.1     skrll     't', NULL, N_("Trace file opens"), TWO_DASHES },
    232   1.1     skrll   { {"script", required_argument, NULL, 'T'},
    233   1.1     skrll     'T', N_("FILE"), N_("Read linker script"), TWO_DASHES },
    234   1.1     skrll   { {"default-script", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
    235   1.1     skrll     '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES },
    236   1.1     skrll   { {"dT", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
    237   1.1     skrll     '\0', NULL, NULL, ONE_DASH },
    238   1.1     skrll   { {"undefined", required_argument, NULL, 'u'},
    239   1.1     skrll     'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
    240   1.1     skrll     TWO_DASHES },
    241   1.5  christos   { {"require-defined", required_argument, NULL, OPTION_REQUIRE_DEFINED_SYMBOL},
    242   1.5  christos     '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
    243   1.5  christos     TWO_DASHES },
    244   1.1     skrll   { {"unique", optional_argument, NULL, OPTION_UNIQUE},
    245   1.1     skrll     '\0', N_("[=SECTION]"),
    246   1.1     skrll     N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
    247   1.1     skrll   { {"Ur", no_argument, NULL, OPTION_UR},
    248   1.1     skrll     '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
    249   1.1     skrll   { {"version", no_argument, NULL, OPTION_VERSION},
    250   1.1     skrll     'v', NULL, N_("Print version information"), TWO_DASHES },
    251   1.1     skrll   { {NULL, no_argument, NULL, '\0'},
    252   1.1     skrll     'V', NULL, N_("Print version and emulation information"), ONE_DASH },
    253   1.1     skrll   { {"discard-all", no_argument, NULL, 'x'},
    254   1.1     skrll     'x', NULL, N_("Discard all local symbols"), TWO_DASHES },
    255   1.1     skrll   { {"discard-locals", no_argument, NULL, 'X'},
    256   1.1     skrll     'X', NULL, N_("Discard temporary local symbols (default)"), TWO_DASHES },
    257   1.1     skrll   { {"discard-none", no_argument, NULL, OPTION_DISCARD_NONE},
    258   1.1     skrll     '\0', NULL, N_("Don't discard any local symbols"), TWO_DASHES },
    259   1.1     skrll   { {"trace-symbol", required_argument, NULL, 'y'},
    260   1.1     skrll     'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
    261   1.1     skrll   { {NULL, required_argument, NULL, '\0'},
    262   1.1     skrll     'Y', N_("PATH"), N_("Default search path for Solaris compatibility"),
    263   1.1     skrll     ONE_DASH },
    264   1.1     skrll   { {"start-group", no_argument, NULL, '('},
    265   1.1     skrll     '(', NULL, N_("Start a group"), TWO_DASHES },
    266   1.1     skrll   { {"end-group", no_argument, NULL, ')'},
    267   1.1     skrll     ')', NULL, N_("End a group"), TWO_DASHES },
    268   1.1     skrll   { {"accept-unknown-input-arch", no_argument, NULL,
    269   1.1     skrll      OPTION_ACCEPT_UNKNOWN_INPUT_ARCH},
    270   1.1     skrll     '\0', NULL,
    271   1.1     skrll     N_("Accept input files whose architecture cannot be determined"),
    272   1.1     skrll     TWO_DASHES },
    273   1.1     skrll   { {"no-accept-unknown-input-arch", no_argument, NULL,
    274   1.1     skrll      OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
    275   1.1     skrll     '\0', NULL, N_("Reject input files whose architecture is unknown"),
    276   1.1     skrll     TWO_DASHES },
    277   1.3  christos 
    278   1.3  christos   /* The next two options are deprecated because of their similarity to
    279   1.3  christos      --as-needed and --no-as-needed.  They have been replaced by
    280   1.4  christos      --copy-dt-needed-entries and --no-copy-dt-needed-entries.  */
    281   1.3  christos   { {"add-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
    282   1.3  christos     '\0', NULL, NULL, NO_HELP },
    283   1.3  christos   { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
    284   1.3  christos     '\0', NULL, NULL, NO_HELP },
    285   1.3  christos 
    286   1.3  christos   { {"as-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_REGULAR},
    287   1.1     skrll     '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
    288   1.1     skrll     TWO_DASHES },
    289   1.3  christos   { {"no-as-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR},
    290   1.3  christos     '\0', NULL, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
    291   1.3  christos 		   "                                the command line"),
    292   1.1     skrll     TWO_DASHES },
    293   1.1     skrll   { {"assert", required_argument, NULL, OPTION_ASSERT},
    294   1.1     skrll     '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
    295   1.1     skrll   { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
    296   1.1     skrll     '\0', NULL, N_("Link against shared libraries"), ONE_DASH },
    297   1.1     skrll   { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
    298   1.1     skrll     '\0', NULL, NULL, ONE_DASH },
    299   1.1     skrll   { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
    300   1.1     skrll     '\0', NULL, NULL, ONE_DASH },
    301   1.1     skrll   { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
    302   1.1     skrll     '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
    303   1.1     skrll   { {"dn", no_argument, NULL, OPTION_NON_SHARED},
    304   1.1     skrll     '\0', NULL, NULL, ONE_DASH },
    305   1.1     skrll   { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
    306   1.1     skrll     '\0', NULL, NULL, ONE_DASH },
    307   1.1     skrll   { {"static", no_argument, NULL, OPTION_NON_SHARED},
    308   1.1     skrll     '\0', NULL, NULL, ONE_DASH },
    309  1.11  christos   { {"Bno-symbolic", no_argument, NULL, OPTION_NO_SYMBOLIC},
    310  1.11  christos     '\0', NULL, N_("Don't bind global references locally"), ONE_DASH },
    311   1.1     skrll   { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
    312   1.1     skrll     '\0', NULL, N_("Bind global references locally"), ONE_DASH },
    313   1.1     skrll   { {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS},
    314   1.1     skrll     '\0', NULL, N_("Bind global function references locally"), ONE_DASH },
    315   1.1     skrll   { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS},
    316   1.1     skrll     '\0', NULL, N_("Check section addresses for overlaps (default)"),
    317   1.1     skrll     TWO_DASHES },
    318   1.1     skrll   { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
    319   1.1     skrll     '\0', NULL, N_("Do not check section addresses for overlaps"),
    320   1.1     skrll     TWO_DASHES },
    321   1.3  christos   { {"copy-dt-needed-entries", no_argument, NULL,
    322   1.3  christos      OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
    323   1.3  christos     '\0', NULL, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
    324   1.3  christos     TWO_DASHES },
    325   1.3  christos   { {"no-copy-dt-needed-entries", no_argument, NULL,
    326   1.3  christos      OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
    327   1.3  christos     '\0', NULL, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
    328   1.3  christos     TWO_DASHES },
    329   1.3  christos 
    330   1.1     skrll   { {"cref", no_argument, NULL, OPTION_CREF},
    331   1.1     skrll     '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
    332   1.1     skrll   { {"defsym", required_argument, NULL, OPTION_DEFSYM},
    333   1.1     skrll     '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
    334   1.1     skrll   { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
    335   1.1     skrll     '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
    336   1.1     skrll     TWO_DASHES },
    337   1.9  christos   { {"disable-multiple-abs-defs", no_argument, NULL,
    338   1.9  christos      OPTION_DISABLE_MULTIPLE_DEFS_ABS},
    339   1.9  christos     '\0', NULL, N_("Do not allow multiple definitions with symbols included\n"
    340  1.11  christos 		   "                                in filename invoked by -R "
    341  1.11  christos 		   "or --just-symbols"),
    342   1.9  christos     TWO_DASHES},
    343   1.1     skrll   { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
    344   1.1     skrll     '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
    345   1.1     skrll   { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
    346   1.1     skrll     '\0', NULL, N_("Treat warnings as errors"),
    347   1.1     skrll     TWO_DASHES },
    348   1.1     skrll   { {"no-fatal-warnings", no_argument, NULL, OPTION_NO_WARN_FATAL},
    349   1.1     skrll     '\0', NULL, N_("Do not treat warnings as errors (default)"),
    350   1.1     skrll     TWO_DASHES },
    351   1.1     skrll   { {"fini", required_argument, NULL, OPTION_FINI},
    352   1.1     skrll     '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
    353   1.1     skrll   { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
    354   1.1     skrll     '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
    355   1.1     skrll   { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
    356   1.1     skrll     '\0', NULL, N_("Remove unused sections (on some targets)"),
    357   1.1     skrll     TWO_DASHES },
    358   1.1     skrll   { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
    359   1.1     skrll     '\0', NULL, N_("Don't remove unused sections (default)"),
    360   1.1     skrll     TWO_DASHES },
    361   1.1     skrll   { {"print-gc-sections", no_argument, NULL, OPTION_PRINT_GC_SECTIONS},
    362   1.1     skrll     '\0', NULL, N_("List removed unused sections on stderr"),
    363   1.1     skrll     TWO_DASHES },
    364   1.1     skrll   { {"no-print-gc-sections", no_argument, NULL, OPTION_NO_PRINT_GC_SECTIONS},
    365   1.1     skrll     '\0', NULL, N_("Do not list removed unused sections"),
    366   1.1     skrll     TWO_DASHES },
    367   1.8  christos   { {"gc-keep-exported", no_argument, NULL, OPTION_GC_KEEP_EXPORTED},
    368   1.8  christos     '\0', NULL, N_("Keep exported symbols when removing unused sections"),
    369   1.8  christos     TWO_DASHES },
    370   1.1     skrll   { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
    371   1.1     skrll     '\0', NULL, N_("Set default hash table size close to <NUMBER>"),
    372   1.1     skrll     TWO_DASHES },
    373   1.1     skrll   { {"help", no_argument, NULL, OPTION_HELP},
    374   1.1     skrll     '\0', NULL, N_("Print option help"), TWO_DASHES },
    375   1.1     skrll   { {"init", required_argument, NULL, OPTION_INIT},
    376   1.1     skrll     '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
    377   1.1     skrll   { {"Map", required_argument, NULL, OPTION_MAP},
    378  1.11  christos     '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH },
    379   1.1     skrll   { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
    380   1.1     skrll     '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
    381   1.1     skrll   { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
    382   1.1     skrll     '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
    383   1.1     skrll   { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
    384   1.1     skrll     '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES },
    385   1.1     skrll   { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED},
    386   1.1     skrll     '\0', NULL, N_("Do not allow unresolved references in object files"),
    387   1.1     skrll     TWO_DASHES },
    388  1.12  christos   { {"no-warnings", no_argument, NULL, OPTION_NO_WARNINGS},
    389  1.12  christos     'w', NULL, N_("Do not display any warning or error messages"),
    390  1.12  christos     TWO_DASHES },
    391   1.1     skrll   { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED},
    392   1.4  christos     '\0', NULL, N_("Allow unresolved references in shared libraries"),
    393   1.1     skrll     TWO_DASHES },
    394   1.1     skrll   { {"no-allow-shlib-undefined", no_argument, NULL,
    395   1.1     skrll      OPTION_NO_ALLOW_SHLIB_UNDEFINED},
    396   1.1     skrll     '\0', NULL, N_("Do not allow unresolved references in shared libs"),
    397   1.1     skrll     TWO_DASHES },
    398   1.1     skrll   { {"allow-multiple-definition", no_argument, NULL,
    399   1.1     skrll      OPTION_ALLOW_MULTIPLE_DEFINITION},
    400   1.1     skrll     '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES },
    401  1.11  christos #if SUPPORT_ERROR_HANDLING_SCRIPT
    402  1.11  christos   { {"error-handling-script", required_argument, NULL,
    403  1.11  christos      OPTION_ERROR_HANDLING_SCRIPT},
    404  1.11  christos     '\0', N_("SCRIPT"), N_("Provide a script to help with undefined symbol errors"), TWO_DASHES},
    405  1.11  christos #endif
    406  1.12  christos   { {"undefined-version", no_argument, NULL, OPTION_UNDEFINED_VERSION},
    407  1.12  christos     '\0', NULL, N_("Allow undefined version"), EXACTLY_TWO_DASHES },
    408   1.1     skrll   { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
    409   1.1     skrll     '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
    410   1.1     skrll   { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER},
    411   1.1     skrll     '\0', NULL, N_("Create default symbol version"), TWO_DASHES },
    412   1.1     skrll   { {"default-imported-symver", no_argument, NULL,
    413   1.1     skrll       OPTION_DEFAULT_IMPORTED_SYMVER},
    414   1.1     skrll     '\0', NULL, N_("Create default symbol version for imported symbols"),
    415   1.1     skrll     TWO_DASHES },
    416   1.1     skrll   { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
    417   1.1     skrll     '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
    418   1.1     skrll   { {"no-warn-search-mismatch", no_argument, NULL,
    419   1.1     skrll      OPTION_NO_WARN_SEARCH_MISMATCH},
    420   1.1     skrll     '\0', NULL, N_("Don't warn on finding an incompatible library"),
    421   1.1     skrll     TWO_DASHES},
    422   1.1     skrll   { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
    423   1.1     skrll     '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
    424   1.1     skrll   { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
    425   1.1     skrll     '\0', NULL, N_("Create an output file even if errors occur"),
    426   1.1     skrll     TWO_DASHES },
    427   1.1     skrll   { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
    428   1.1     skrll     '\0', NULL, NULL, NO_HELP },
    429   1.1     skrll   { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB},
    430   1.1     skrll     '\0', NULL, N_("Only use library directories specified on\n"
    431   1.1     skrll 		   "                                the command line"),
    432   1.1     skrll     ONE_DASH },
    433   1.1     skrll   { {"oformat", required_argument, NULL, OPTION_OFORMAT},
    434   1.1     skrll     '\0', N_("TARGET"), N_("Specify target of output file"),
    435   1.1     skrll     EXACTLY_TWO_DASHES },
    436   1.4  christos   { {"print-output-format", no_argument, NULL, OPTION_PRINT_OUTPUT_FORMAT},
    437   1.4  christos     '\0', NULL, N_("Print default output format"), TWO_DASHES },
    438   1.5  christos   { {"print-sysroot", no_argument, NULL, OPTION_PRINT_SYSROOT},
    439   1.5  christos     '\0', NULL, N_("Print current sysroot"), TWO_DASHES },
    440   1.1     skrll   { {"qmagic", no_argument, NULL, OPTION_IGNORE},
    441   1.1     skrll     '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
    442   1.1     skrll   { {"reduce-memory-overheads", no_argument, NULL,
    443   1.1     skrll      OPTION_REDUCE_MEMORY_OVERHEADS},
    444   1.1     skrll     '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
    445   1.1     skrll     TWO_DASHES },
    446  1.11  christos   { {"max-cache-size=SIZE", required_argument, NULL,
    447  1.11  christos     OPTION_MAX_CACHE_SIZE},
    448  1.11  christos     '\0', NULL, N_("Set the maximum cache size to SIZE bytes"),
    449  1.11  christos     TWO_DASHES },
    450   1.1     skrll   { {"relax", no_argument, NULL, OPTION_RELAX},
    451   1.3  christos     '\0', NULL, N_("Reduce code size by using target specific optimizations"), TWO_DASHES },
    452   1.3  christos   { {"no-relax", no_argument, NULL, OPTION_NO_RELAX},
    453   1.3  christos     '\0', NULL, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES },
    454   1.1     skrll   { {"retain-symbols-file", required_argument, NULL,
    455   1.1     skrll      OPTION_RETAIN_SYMBOLS_FILE},
    456   1.1     skrll     '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
    457   1.1     skrll   { {"rpath", required_argument, NULL, OPTION_RPATH},
    458   1.1     skrll     '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH },
    459   1.1     skrll   { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
    460   1.1     skrll     '\0', N_("PATH"), N_("Set link time shared library search path"),
    461   1.1     skrll     ONE_DASH },
    462   1.1     skrll   { {"shared", no_argument, NULL, OPTION_SHARED},
    463   1.1     skrll     '\0', NULL, N_("Create a shared library"), ONE_DASH },
    464   1.2     skrll   { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD, NetBSD.  */
    465   1.1     skrll     '\0', NULL, NULL, ONE_DASH },
    466   1.1     skrll   { {"pie", no_argument, NULL, OPTION_PIE},
    467   1.1     skrll     '\0', NULL, N_("Create a position independent executable"), ONE_DASH },
    468   1.1     skrll   { {"pic-executable", no_argument, NULL, OPTION_PIE},
    469   1.1     skrll     '\0', NULL, NULL, TWO_DASHES },
    470  1.11  christos   { {"no-pie", no_argument, NULL, OPTION_NO_PIE},
    471  1.11  christos     '\0', NULL, N_("Create a position dependent executable (default)"), ONE_DASH },
    472   1.1     skrll   { {"sort-common", optional_argument, NULL, OPTION_SORT_COMMON},
    473   1.4  christos     '\0', N_("[=ascending|descending]"),
    474   1.4  christos     N_("Sort common symbols by alignment [in specified order]"),
    475   1.1     skrll     TWO_DASHES },
    476   1.1     skrll   { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
    477   1.1     skrll     '\0', NULL, NULL, NO_HELP },
    478   1.1     skrll   { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
    479   1.4  christos     '\0', N_("name|alignment"),
    480   1.1     skrll     N_("Sort sections by name or maximum alignment"), TWO_DASHES },
    481  1.13  christos   { {"section-ordering-file", required_argument, NULL, OPTION_SECTION_ORDERING_FILE},
    482  1.13  christos     '\0', N_("FILE"),
    483  1.13  christos     N_("Sort sections by statements in FILE"), TWO_DASHES },
    484   1.1     skrll   { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
    485   1.1     skrll     '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
    486   1.1     skrll     TWO_DASHES },
    487   1.1     skrll   { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE},
    488   1.1     skrll     '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"),
    489   1.1     skrll     TWO_DASHES },
    490   1.1     skrll   { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC},
    491   1.1     skrll     '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"),
    492   1.1     skrll     TWO_DASHES },
    493  1.13  christos   { {"stats", optional_argument, NULL, OPTION_STATS},
    494  1.13  christos     '\0', NULL, N_("Print resource usage statistics"), TWO_DASHES },
    495  1.13  christos   { {"no-stats", optional_argument, NULL, OPTION_NO_STATS},
    496  1.13  christos     '\0', NULL, N_("Do not print resource usage statistics"), TWO_DASHES },
    497   1.1     skrll   { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
    498   1.1     skrll     '\0', NULL, N_("Display target specific options"), TWO_DASHES },
    499   1.1     skrll   { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
    500   1.1     skrll     '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
    501   1.1     skrll   { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
    502   1.1     skrll     '\0', NULL, N_("Use same format as native linker"), TWO_DASHES },
    503   1.1     skrll   { {"section-start", required_argument, NULL, OPTION_SECTION_START},
    504   1.1     skrll     '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"),
    505   1.1     skrll     TWO_DASHES },
    506  1.13  christos   { {"image-base", required_argument, NULL, OPTION_IMAGE_BASE},
    507  1.13  christos     '\0', N_("ADDRESS"), N_("Set image base address"), TWO_DASHES },
    508   1.1     skrll   { {"Tbss", required_argument, NULL, OPTION_TBSS},
    509   1.1     skrll     '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH },
    510   1.1     skrll   { {"Tdata", required_argument, NULL, OPTION_TDATA},
    511   1.1     skrll     '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
    512   1.1     skrll   { {"Ttext", required_argument, NULL, OPTION_TTEXT},
    513   1.1     skrll     '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
    514   1.3  christos   { {"Ttext-segment", required_argument, NULL, OPTION_TTEXT_SEGMENT},
    515   1.3  christos     '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH },
    516   1.4  christos   { {"Trodata-segment", required_argument, NULL, OPTION_TRODATA_SEGMENT},
    517   1.4  christos     '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH },
    518   1.5  christos   { {"Tldata-segment", required_argument, NULL, OPTION_TLDATA_SEGMENT},
    519   1.5  christos     '\0', N_("ADDRESS"), N_("Set address of ldata segment"), ONE_DASH },
    520   1.1     skrll   { {"unresolved-symbols=<method>", required_argument, NULL,
    521   1.1     skrll      OPTION_UNRESOLVED_SYMBOLS},
    522   1.1     skrll     '\0', NULL, N_("How to handle unresolved symbols.  <method> is:\n"
    523   1.1     skrll 		   "                                ignore-all, report-all, ignore-in-object-files,\n"
    524   1.1     skrll 		   "                                ignore-in-shared-libs"),
    525   1.1     skrll     TWO_DASHES },
    526   1.3  christos   { {"verbose", optional_argument, NULL, OPTION_VERBOSE},
    527   1.3  christos     '\0', N_("[=NUMBER]"),
    528   1.3  christos     N_("Output lots of information during link"), TWO_DASHES },
    529   1.1     skrll   { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux.  */
    530   1.1     skrll     '\0', NULL, NULL, NO_HELP },
    531   1.1     skrll   { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT },
    532   1.1     skrll     '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES },
    533   1.1     skrll   { {"version-exports-section", required_argument, NULL,
    534   1.1     skrll      OPTION_VERSION_EXPORTS_SECTION },
    535   1.1     skrll     '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
    536   1.1     skrll 			   "                                SYMBOL as the version."),
    537   1.1     skrll     TWO_DASHES },
    538   1.1     skrll   { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
    539   1.1     skrll     '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
    540   1.1     skrll   { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
    541   1.1     skrll     '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES },
    542   1.1     skrll   { {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO},
    543   1.1     skrll     '\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
    544   1.1     skrll   { {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
    545   1.1     skrll     '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
    546  1.11  christos   { {"export-dynamic-symbol", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL},
    547  1.11  christos     '\0', N_("SYMBOL"), N_("Export the specified symbol"), EXACTLY_TWO_DASHES },
    548  1.11  christos   { {"export-dynamic-symbol-list", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL_LIST},
    549  1.11  christos     '\0', N_("FILE"), N_("Read export dynamic symbol list"), EXACTLY_TWO_DASHES },
    550   1.1     skrll   { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
    551   1.1     skrll     '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
    552   1.1     skrll   { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
    553   1.1     skrll     '\0', NULL, N_("Warn if global constructors/destructors are seen"),
    554   1.1     skrll     TWO_DASHES },
    555  1.12  christos 
    556  1.12  christos   { {"error-execstack", no_argument, NULL, OPTION_ERROR_EXECSTACK},
    557  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    558  1.12  christos   { {"no-error-execstack", no_argument, NULL, OPTION_NO_ERROR_EXECSTACK},
    559  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    560  1.12  christos   { {"warn-execstack-objects", no_argument, NULL, OPTION_WARN_EXECSTACK_OBJECTS},
    561  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    562  1.11  christos   { {"warn-execstack", no_argument, NULL, OPTION_WARN_EXECSTACK},
    563  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    564  1.11  christos   { {"no-warn-execstack", no_argument, NULL, OPTION_NO_WARN_EXECSTACK},
    565  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    566  1.12  christos 
    567  1.12  christos   { {"error-rwx-segments", no_argument, NULL, OPTION_ERROR_RWX_SEGMENTS},
    568  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    569  1.12  christos   { {"no-error-rwx-segments", no_argument, NULL, OPTION_NO_ERROR_RWX_SEGMENTS},
    570  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    571  1.11  christos   { {"warn-rwx-segments", no_argument, NULL, OPTION_WARN_RWX_SEGMENTS},
    572  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    573  1.11  christos   { {"no-warn-rwx-segments", no_argument, NULL, OPTION_NO_WARN_RWX_SEGMENTS},
    574  1.12  christos     '\0', NULL, NULL, TWO_DASHES },
    575  1.12  christos 
    576   1.1     skrll   { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
    577   1.1     skrll     '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
    578   1.1     skrll   { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
    579   1.1     skrll     '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES },
    580   1.1     skrll   { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN},
    581   1.1     skrll     '\0', NULL, N_("Warn if start of section changes due to alignment"),
    582   1.1     skrll     TWO_DASHES },
    583  1.11  christos   { {"warn-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
    584  1.11  christos     '\0', NULL,
    585  1.11  christos #if DEFAULT_LD_TEXTREL_CHECK_WARNING
    586  1.11  christos     N_("Warn if output has DT_TEXTREL (default)"),
    587  1.11  christos #else
    588  1.11  christos     N_("Warn if output has DT_TEXTREL"),
    589  1.11  christos #endif
    590   1.1     skrll     TWO_DASHES },
    591  1.11  christos   { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
    592  1.11  christos     '\0', NULL, NULL, NO_HELP },
    593   1.3  christos   { {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM},
    594   1.3  christos     '\0', NULL, N_("Warn if an object has alternate ELF machine code"),
    595   1.3  christos     TWO_DASHES },
    596   1.1     skrll   { {"warn-unresolved-symbols", no_argument, NULL,
    597   1.1     skrll      OPTION_WARN_UNRESOLVED_SYMBOLS},
    598   1.1     skrll     '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
    599   1.1     skrll   { {"error-unresolved-symbols", no_argument, NULL,
    600   1.1     skrll      OPTION_ERROR_UNRESOLVED_SYMBOLS},
    601   1.1     skrll     '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES },
    602   1.1     skrll   { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
    603   1.1     skrll     '\0', NULL, N_("Include all objects from following archives"),
    604   1.1     skrll     TWO_DASHES },
    605   1.2     skrll   { {"Bforcearchive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
    606   1.2     skrll       '\0', NULL, NULL, TWO_DASHES },	/* NetBSD.  */
    607   1.1     skrll   { {"wrap", required_argument, NULL, OPTION_WRAP},
    608   1.1     skrll     '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
    609   1.2     skrll   { {"ignore-unresolved-symbol", required_argument, NULL,
    610   1.2     skrll     OPTION_IGNORE_UNRESOLVED_SYMBOL},
    611   1.2     skrll     '\0', N_("SYMBOL"),
    612   1.2     skrll     N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
    613   1.5  christos   { {"push-state", no_argument, NULL, OPTION_PUSH_STATE},
    614   1.5  christos     '\0', NULL, N_("Push state of flags governing input file handling"),
    615   1.5  christos     TWO_DASHES },
    616   1.5  christos   { {"pop-state", no_argument, NULL, OPTION_POP_STATE},
    617   1.5  christos     '\0', NULL, N_("Pop state of flags governing input file handling"),
    618   1.5  christos     TWO_DASHES },
    619   1.5  christos   { {"print-memory-usage", no_argument, NULL, OPTION_PRINT_MEMORY_USAGE},
    620   1.5  christos     '\0', NULL, N_("Report target memory usage"), TWO_DASHES },
    621   1.5  christos   { {"orphan-handling", required_argument, NULL, OPTION_ORPHAN_HANDLING},
    622   1.5  christos     '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
    623   1.5  christos     TWO_DASHES },
    624  1.10  christos   { {"print-map-discarded", no_argument, NULL, OPTION_PRINT_MAP_DISCARDED},
    625  1.10  christos     '\0', NULL, N_("Show discarded sections in map file output (default)"),
    626  1.10  christos     TWO_DASHES },
    627  1.10  christos   { {"no-print-map-discarded", no_argument, NULL, OPTION_NO_PRINT_MAP_DISCARDED},
    628  1.10  christos     '\0', NULL, N_("Do not show discarded sections in map file output"),
    629  1.10  christos     TWO_DASHES },
    630  1.12  christos   { {"print-map-locals", no_argument, NULL, OPTION_PRINT_MAP_LOCALS},
    631  1.12  christos     '\0', NULL, N_("Show local symbols in map file output"),
    632  1.12  christos     TWO_DASHES },
    633  1.12  christos   { {"no-print-map-locals", no_argument, NULL, OPTION_NO_PRINT_MAP_LOCALS},
    634  1.12  christos     '\0', NULL, N_("Do not show local symbols in map file output (default)"),
    635  1.12  christos     TWO_DASHES },
    636  1.11  christos   { {"ctf-variables", no_argument, NULL, OPTION_CTF_VARIABLES},
    637  1.11  christos     '\0', NULL, N_("Emit names and types of static variables in CTF"),
    638  1.11  christos     TWO_DASHES },
    639  1.11  christos   { {"no-ctf-variables", no_argument, NULL, OPTION_NO_CTF_VARIABLES},
    640  1.11  christos     '\0', NULL, N_("Do not emit names and types of static variables in CTF"),
    641  1.11  christos     TWO_DASHES },
    642  1.11  christos   { {"ctf-share-types=<method>", required_argument, NULL,
    643  1.11  christos      OPTION_CTF_SHARE_TYPES},
    644  1.11  christos     '\0', NULL, N_("How to share CTF types between translation units.\n"
    645  1.11  christos 		   "                                <method> is: share-unconflicted (default),\n"
    646  1.11  christos 		   "                                             share-duplicated"),
    647  1.11  christos     TWO_DASHES },
    648   1.1     skrll };
    649   1.1     skrll 
    650   1.1     skrll #define OPTION_COUNT ARRAY_SIZE (ld_options)
    651   1.1     skrll 
    652   1.1     skrll void
    653   1.1     skrll parse_args (unsigned argc, char **argv)
    654   1.1     skrll {
    655   1.1     skrll   unsigned i;
    656   1.1     skrll   int is, il, irl;
    657   1.1     skrll   int ingroup = 0;
    658   1.1     skrll   char *default_dirlist = NULL;
    659   1.1     skrll   char *shortopts;
    660   1.1     skrll   struct option *longopts;
    661   1.1     skrll   struct option *really_longopts;
    662   1.1     skrll   int last_optind;
    663  1.10  christos   enum symbolic_enum
    664  1.10  christos   {
    665  1.10  christos     symbolic_unset = 0,
    666  1.10  christos     symbolic,
    667  1.10  christos     symbolic_functions,
    668  1.10  christos   } opt_symbolic = symbolic_unset;
    669  1.10  christos   enum dynamic_list_enum
    670  1.10  christos   {
    671  1.10  christos     dynamic_list_unset = 0,
    672  1.10  christos     dynamic_list_data,
    673  1.10  christos     dynamic_list
    674  1.10  christos   } opt_dynamic_list = dynamic_list_unset;
    675  1.11  christos   struct bfd_elf_dynamic_list *export_list = NULL;
    676   1.1     skrll 
    677   1.3  christos   shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
    678   1.3  christos   longopts = (struct option *)
    679   1.3  christos       xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
    680   1.3  christos   really_longopts = (struct option *)
    681  1.11  christos       xmalloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
    682   1.1     skrll 
    683   1.1     skrll   /* Starting the short option string with '-' is for programs that
    684   1.1     skrll      expect options and other ARGV-elements in any order and that care about
    685   1.1     skrll      the ordering of the two.  We describe each non-option ARGV-element
    686   1.1     skrll      as if it were the argument of an option with character code 1.  */
    687   1.1     skrll   shortopts[0] = '-';
    688   1.1     skrll   is = 1;
    689   1.1     skrll   il = 0;
    690   1.1     skrll   irl = 0;
    691   1.1     skrll   for (i = 0; i < OPTION_COUNT; i++)
    692   1.1     skrll     {
    693   1.1     skrll       if (ld_options[i].shortopt != '\0')
    694   1.1     skrll 	{
    695   1.1     skrll 	  shortopts[is] = ld_options[i].shortopt;
    696   1.1     skrll 	  ++is;
    697   1.1     skrll 	  if (ld_options[i].opt.has_arg == required_argument
    698   1.1     skrll 	      || ld_options[i].opt.has_arg == optional_argument)
    699   1.1     skrll 	    {
    700   1.1     skrll 	      shortopts[is] = ':';
    701   1.1     skrll 	      ++is;
    702   1.1     skrll 	      if (ld_options[i].opt.has_arg == optional_argument)
    703   1.1     skrll 		{
    704   1.1     skrll 		  shortopts[is] = ':';
    705   1.1     skrll 		  ++is;
    706   1.1     skrll 		}
    707   1.1     skrll 	    }
    708   1.1     skrll 	}
    709   1.1     skrll       if (ld_options[i].opt.name != NULL)
    710   1.1     skrll 	{
    711   1.1     skrll 	  if (ld_options[i].control == EXACTLY_TWO_DASHES)
    712   1.1     skrll 	    {
    713   1.1     skrll 	      really_longopts[irl] = ld_options[i].opt;
    714   1.1     skrll 	      ++irl;
    715   1.1     skrll 	    }
    716   1.1     skrll 	  else
    717   1.1     skrll 	    {
    718   1.1     skrll 	      longopts[il] = ld_options[i].opt;
    719   1.1     skrll 	      ++il;
    720   1.1     skrll 	    }
    721   1.1     skrll 	}
    722   1.1     skrll     }
    723   1.1     skrll   shortopts[is] = '\0';
    724   1.1     skrll   longopts[il].name = NULL;
    725   1.1     skrll   really_longopts[irl].name = NULL;
    726   1.1     skrll 
    727   1.1     skrll   ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
    728   1.1     skrll 
    729   1.1     skrll   /* The -G option is ambiguous on different platforms.  Sometimes it
    730   1.1     skrll      specifies the largest data size to put into the small data
    731   1.1     skrll      section.  Sometimes it is equivalent to --shared.  Unfortunately,
    732   1.1     skrll      the first form takes an argument, while the second does not.
    733   1.1     skrll 
    734   1.1     skrll      We need to permit the --shared form because on some platforms,
    735   1.1     skrll      such as Solaris, gcc -shared will pass -G to the linker.
    736   1.1     skrll 
    737   1.1     skrll      To permit either usage, we look through the argument list.  If we
    738   1.1     skrll      find -G not followed by a number, we change it into --shared.
    739   1.1     skrll      This will work for most normal cases.  */
    740   1.1     skrll   for (i = 1; i < argc; i++)
    741   1.1     skrll     if (strcmp (argv[i], "-G") == 0
    742   1.1     skrll 	&& (i + 1 >= argc
    743   1.1     skrll 	    || ! ISDIGIT (argv[i + 1][0])))
    744   1.1     skrll       argv[i] = (char *) "--shared";
    745   1.1     skrll 
    746   1.1     skrll   /* Because we permit long options to start with a single dash, and
    747   1.1     skrll      we have a --library option, and the -l option is conventionally
    748   1.1     skrll      used with an immediately following argument, we can have bad
    749   1.1     skrll      results if somebody tries to use -l with a library whose name
    750   1.1     skrll      happens to start with "ibrary", as in -li.  We avoid problems by
    751   1.1     skrll      simply turning -l into --library.  This means that users will
    752   1.1     skrll      have to use two dashes in order to use --library, which is OK
    753   1.1     skrll      since that's how it is documented.
    754   1.1     skrll 
    755   1.1     skrll      FIXME: It's possible that this problem can arise for other short
    756   1.1     skrll      options as well, although the user does always have the recourse
    757   1.1     skrll      of adding a space between the option and the argument.  */
    758   1.1     skrll   for (i = 1; i < argc; i++)
    759   1.1     skrll     {
    760   1.1     skrll       if (argv[i][0] == '-'
    761   1.1     skrll 	  && argv[i][1] == 'l'
    762   1.1     skrll 	  && argv[i][2] != '\0')
    763   1.1     skrll 	{
    764   1.1     skrll 	  char *n;
    765   1.1     skrll 
    766   1.3  christos 	  n = (char *) xmalloc (strlen (argv[i]) + 20);
    767   1.1     skrll 	  sprintf (n, "--library=%s", argv[i] + 2);
    768   1.1     skrll 	  argv[i] = n;
    769   1.1     skrll 	}
    770   1.1     skrll     }
    771   1.1     skrll 
    772   1.1     skrll   last_optind = -1;
    773   1.1     skrll   while (1)
    774   1.1     skrll     {
    775  1.11  christos       int longind = 0;
    776   1.1     skrll       int optc;
    777   1.4  christos       static unsigned int defsym_count;
    778   1.1     skrll 
    779   1.1     skrll       /* Using last_optind lets us avoid calling ldemul_parse_args
    780   1.1     skrll 	 multiple times on a single option, which would lead to
    781   1.1     skrll 	 confusion in the internal static variables maintained by
    782   1.1     skrll 	 getopt.  This could otherwise happen for an argument like
    783   1.1     skrll 	 -nx, in which the -n is parsed as a single option, and we
    784   1.1     skrll 	 loop around to pick up the -x.  */
    785   1.1     skrll       if (optind != last_optind)
    786   1.1     skrll 	if (ldemul_parse_args (argc, argv))
    787   1.1     skrll 	  continue;
    788   1.1     skrll 
    789   1.1     skrll       /* getopt_long_only is like getopt_long, but '-' as well as '--'
    790   1.1     skrll 	 can indicate a long option.  */
    791   1.1     skrll       opterr = 0;
    792   1.1     skrll       last_optind = optind;
    793   1.1     skrll       optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
    794   1.1     skrll       if (optc == '?')
    795   1.1     skrll 	{
    796   1.1     skrll 	  optind = last_optind;
    797   1.1     skrll 	  optc = getopt_long (argc, argv, "-", really_longopts, &longind);
    798   1.1     skrll 	}
    799  1.11  christos       /* Attempt to detect grouped short options,  eg: "-non-start".
    800  1.11  christos 	 Accepting such options is error prone as it is not clear if the user
    801  1.11  christos 	 intended "-n -o n-start" or "--non-start".  */
    802  1.11  christos       else if (longind == 0  /* This is a short option.  */
    803  1.11  christos 	       && optc > 32  /* It is a valid option.  */
    804  1.11  christos         /* The character is not the second character of argv[last_optind].  */
    805  1.11  christos 	       && optc != argv[last_optind][1])
    806  1.11  christos 	{
    807  1.11  christos 	  if (optarg)
    808  1.13  christos 	    fatal (_("%P: Error: unable to disambiguate: "
    809  1.13  christos 		     "%s (did you mean -%s ?)\n"),
    810  1.11  christos 		   argv[last_optind], argv[last_optind]);
    811  1.11  christos 	  else
    812  1.11  christos 	    einfo (_("%P: Warning: grouped short command line options are deprecated: %s\n"), argv[last_optind]);
    813  1.11  christos 	}
    814   1.1     skrll 
    815   1.1     skrll       if (ldemul_handle_option (optc))
    816   1.1     skrll 	continue;
    817   1.1     skrll 
    818   1.1     skrll       if (optc == -1)
    819   1.1     skrll 	break;
    820   1.1     skrll 
    821   1.1     skrll       switch (optc)
    822   1.1     skrll 	{
    823   1.1     skrll 	case '?':
    824   1.5  christos 	  {
    825   1.5  christos 	    /* If the last word on the command line is an option that
    826   1.5  christos 	       requires an argument, getopt will refuse to recognise it.
    827   1.5  christos 	       Try to catch such options here and issue a more helpful
    828   1.5  christos 	       error message than just "unrecognized option".  */
    829   1.5  christos 	    int opt;
    830   1.5  christos 
    831   1.5  christos 	    for (opt = ARRAY_SIZE (ld_options); opt--;)
    832   1.5  christos 	      if (ld_options[opt].opt.has_arg == required_argument
    833   1.5  christos 		  /* FIXME: There are a few short options that do not
    834   1.5  christos 		     have long equivalents, but which require arguments.
    835   1.5  christos 		     We should handle them too.  */
    836   1.5  christos 		  && ld_options[opt].opt.name != NULL
    837   1.5  christos 		  && strcmp (argv[last_optind] + ld_options[opt].control, ld_options[opt].opt.name) == 0)
    838   1.5  christos 		{
    839   1.5  christos 		  einfo (_("%P: %s: missing argument\n"), argv[last_optind]);
    840   1.5  christos 		  break;
    841   1.5  christos 		}
    842   1.5  christos 
    843   1.5  christos 	    if (opt == -1)
    844   1.5  christos 	      einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
    845   1.5  christos 	  }
    846   1.1     skrll 	  /* Fall through.  */
    847   1.1     skrll 
    848   1.1     skrll 	default:
    849  1.13  christos 	  fatal (_("%P: use the --help option for usage information\n"));
    850   1.8  christos 	  break;
    851   1.1     skrll 
    852   1.1     skrll 	case 1:			/* File name.  */
    853   1.1     skrll 	  lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL);
    854   1.1     skrll 	  break;
    855   1.1     skrll 
    856   1.1     skrll 	case OPTION_IGNORE:
    857   1.1     skrll 	  break;
    858   1.1     skrll 	case 'a':
    859   1.1     skrll 	  /* For HP/UX compatibility.  Actually -a shared should mean
    860   1.1     skrll 	     ``use only shared libraries'' but, then, we don't
    861   1.1     skrll 	     currently support shared libraries on HP/UX anyhow.  */
    862   1.1     skrll 	  if (strcmp (optarg, "archive") == 0)
    863  1.11  christos 	    input_flags.dynamic = false;
    864   1.1     skrll 	  else if (strcmp (optarg, "shared") == 0
    865   1.1     skrll 		   || strcmp (optarg, "default") == 0)
    866  1.11  christos 	    input_flags.dynamic = true;
    867   1.1     skrll 	  else
    868  1.13  christos 	    fatal (_("%P: unrecognized -a option `%s'\n"), optarg);
    869   1.1     skrll 	  break;
    870   1.1     skrll 	case OPTION_ASSERT:
    871   1.1     skrll 	  /* FIXME: We just ignore these, but we should handle them.  */
    872   1.1     skrll 	  if (strcmp (optarg, "definitions") == 0)
    873   1.1     skrll 	    ;
    874   1.1     skrll 	  else if (strcmp (optarg, "nodefinitions") == 0)
    875   1.1     skrll 	    ;
    876   1.1     skrll 	  else if (strcmp (optarg, "nosymbolic") == 0)
    877   1.1     skrll 	    ;
    878   1.1     skrll 	  else if (strcmp (optarg, "pure-text") == 0)
    879   1.1     skrll 	    ;
    880   1.1     skrll 	  else
    881  1.13  christos 	    fatal (_("%P: unrecognized -assert option `%s'\n"), optarg);
    882   1.1     skrll 	  break;
    883   1.1     skrll 	case 'A':
    884   1.1     skrll 	  ldfile_add_arch (optarg);
    885   1.1     skrll 	  break;
    886   1.1     skrll 	case 'b':
    887   1.1     skrll 	  lang_add_target (optarg);
    888   1.1     skrll 	  break;
    889   1.1     skrll 	case 'c':
    890   1.1     skrll 	  ldfile_open_command_file (optarg);
    891   1.1     skrll 	  parser_input = input_mri_script;
    892   1.1     skrll 	  yyparse ();
    893   1.1     skrll 	  break;
    894   1.1     skrll 	case OPTION_CALL_SHARED:
    895  1.11  christos 	  input_flags.dynamic = true;
    896   1.1     skrll 	  break;
    897   1.1     skrll 	case OPTION_NON_SHARED:
    898  1.11  christos 	  input_flags.dynamic = false;
    899   1.1     skrll 	  break;
    900   1.1     skrll 	case OPTION_CREF:
    901  1.11  christos 	  command_line.cref = true;
    902  1.11  christos 	  link_info.notice_all = true;
    903   1.1     skrll 	  break;
    904   1.1     skrll 	case 'd':
    905  1.11  christos 	  command_line.force_common_definition = true;
    906   1.1     skrll 	  break;
    907   1.8  christos 	case OPTION_FORCE_GROUP_ALLOCATION:
    908  1.11  christos 	  command_line.force_group_allocation = true;
    909   1.8  christos 	  break;
    910   1.1     skrll 	case OPTION_DEFSYM:
    911   1.1     skrll 	  lex_string = optarg;
    912   1.4  christos 	  lex_redirect (optarg, "--defsym", ++defsym_count);
    913   1.1     skrll 	  parser_input = input_defsym;
    914   1.1     skrll 	  yyparse ();
    915   1.1     skrll 	  lex_string = NULL;
    916   1.1     skrll 	  break;
    917   1.1     skrll 	case OPTION_DEMANGLE:
    918  1.11  christos 	  demangling = true;
    919   1.1     skrll 	  if (optarg != NULL)
    920   1.1     skrll 	    {
    921   1.1     skrll 	      enum demangling_styles style;
    922   1.1     skrll 
    923   1.1     skrll 	      style = cplus_demangle_name_to_style (optarg);
    924   1.1     skrll 	      if (style == unknown_demangling)
    925  1.13  christos 		fatal (_("%P: unknown demangling style `%s'\n"), optarg);
    926   1.1     skrll 
    927   1.1     skrll 	      cplus_demangle_set_style (style);
    928   1.1     skrll 	    }
    929   1.1     skrll 	  break;
    930   1.1     skrll 	case 'I':		/* Used on Solaris.  */
    931   1.1     skrll 	case OPTION_DYNAMIC_LINKER:
    932   1.1     skrll 	  command_line.interpreter = optarg;
    933   1.5  christos 	  link_info.nointerp = 0;
    934   1.5  christos 	  break;
    935   1.5  christos 	case OPTION_NO_DYNAMIC_LINKER:
    936   1.5  christos 	  link_info.nointerp = 1;
    937   1.1     skrll 	  break;
    938   1.1     skrll 	case OPTION_SYSROOT:
    939   1.1     skrll 	  /* Already handled in ldmain.c.  */
    940   1.1     skrll 	  break;
    941   1.1     skrll 	case OPTION_EB:
    942   1.1     skrll 	  command_line.endian = ENDIAN_BIG;
    943   1.1     skrll 	  break;
    944   1.1     skrll 	case OPTION_EL:
    945   1.1     skrll 	  command_line.endian = ENDIAN_LITTLE;
    946   1.1     skrll 	  break;
    947   1.1     skrll 	case OPTION_EMBEDDED_RELOCS:
    948  1.11  christos 	  command_line.embedded_relocs = true;
    949   1.1     skrll 	  break;
    950   1.1     skrll 	case OPTION_EXPORT_DYNAMIC:
    951   1.1     skrll 	case 'E': /* HP/UX compatibility.  */
    952  1.11  christos 	  link_info.export_dynamic = true;
    953   1.1     skrll 	  break;
    954   1.3  christos 	case OPTION_NO_EXPORT_DYNAMIC:
    955  1.11  christos 	  link_info.export_dynamic = false;
    956  1.11  christos 	  break;
    957  1.11  christos 	case OPTION_NON_CONTIGUOUS_REGIONS:
    958  1.11  christos 	  link_info.non_contiguous_regions = true;
    959  1.11  christos 	  break;
    960  1.11  christos 	case OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS:
    961  1.11  christos 	  link_info.non_contiguous_regions_warnings = true;
    962  1.11  christos 	  break;
    963  1.12  christos 
    964  1.12  christos 	case OPTION_ERROR_EXECSTACK:
    965  1.12  christos 	  link_info.error_execstack = 1;
    966  1.12  christos 	  break;
    967  1.12  christos 	case OPTION_NO_ERROR_EXECSTACK:
    968  1.12  christos 	  link_info.error_execstack = 0;
    969  1.12  christos 	  break;
    970  1.12  christos 	case OPTION_WARN_EXECSTACK_OBJECTS:
    971  1.12  christos 	  link_info.warn_execstack = 2;
    972  1.12  christos 	  break;
    973  1.11  christos 	case OPTION_WARN_EXECSTACK:
    974  1.11  christos 	  link_info.warn_execstack = 1;
    975  1.11  christos 	  break;
    976  1.11  christos 	case OPTION_NO_WARN_EXECSTACK:
    977  1.11  christos 	  link_info.warn_execstack = 0;
    978  1.11  christos 	  break;
    979  1.12  christos 
    980  1.12  christos 	case OPTION_ERROR_RWX_SEGMENTS:
    981  1.12  christos 	  link_info.warn_is_error_for_rwx_segments = 1;
    982  1.12  christos 	  break;
    983  1.12  christos 	case OPTION_NO_ERROR_RWX_SEGMENTS:
    984  1.12  christos 	  link_info.warn_is_error_for_rwx_segments = 0;
    985  1.12  christos 	  break;
    986  1.11  christos 	case OPTION_WARN_RWX_SEGMENTS:
    987  1.11  christos 	  link_info.no_warn_rwx_segments = 0;
    988  1.12  christos 	  link_info.user_warn_rwx_segments = 1;
    989  1.11  christos 	  break;
    990  1.11  christos 	case OPTION_NO_WARN_RWX_SEGMENTS:
    991  1.11  christos 	  link_info.no_warn_rwx_segments = 1;
    992  1.12  christos 	  link_info.user_warn_rwx_segments = 1;
    993   1.3  christos 	  break;
    994  1.12  christos 
    995   1.1     skrll 	case 'e':
    996  1.11  christos 	  lang_add_entry (optarg, true);
    997   1.1     skrll 	  break;
    998   1.1     skrll 	case 'f':
    999   1.1     skrll 	  if (command_line.auxiliary_filters == NULL)
   1000   1.1     skrll 	    {
   1001   1.3  christos 	      command_line.auxiliary_filters = (char **)
   1002   1.8  christos 		xmalloc (2 * sizeof (char *));
   1003   1.1     skrll 	      command_line.auxiliary_filters[0] = optarg;
   1004   1.1     skrll 	      command_line.auxiliary_filters[1] = NULL;
   1005   1.1     skrll 	    }
   1006   1.1     skrll 	  else
   1007   1.1     skrll 	    {
   1008   1.1     skrll 	      int c;
   1009   1.1     skrll 	      char **p;
   1010   1.1     skrll 
   1011   1.1     skrll 	      c = 0;
   1012   1.1     skrll 	      for (p = command_line.auxiliary_filters; *p != NULL; p++)
   1013   1.1     skrll 		++c;
   1014   1.3  christos 	      command_line.auxiliary_filters = (char **)
   1015   1.8  christos 		xrealloc (command_line.auxiliary_filters,
   1016   1.8  christos 			  (c + 2) * sizeof (char *));
   1017   1.1     skrll 	      command_line.auxiliary_filters[c] = optarg;
   1018   1.1     skrll 	      command_line.auxiliary_filters[c + 1] = NULL;
   1019   1.1     skrll 	    }
   1020   1.1     skrll 	  break;
   1021   1.1     skrll 	case 'F':
   1022   1.1     skrll 	  command_line.filter_shlib = optarg;
   1023   1.1     skrll 	  break;
   1024   1.1     skrll 	case OPTION_FORCE_EXE_SUFFIX:
   1025  1.11  christos 	  command_line.force_exe_suffix = true;
   1026   1.1     skrll 	  break;
   1027   1.1     skrll 	case 'G':
   1028   1.1     skrll 	  {
   1029   1.1     skrll 	    char *end;
   1030   1.1     skrll 	    g_switch_value = strtoul (optarg, &end, 0);
   1031   1.1     skrll 	    if (*end)
   1032  1.13  christos 	      fatal (_("%P: invalid number `%s'\n"), optarg);
   1033   1.1     skrll 	  }
   1034   1.1     skrll 	  break;
   1035   1.1     skrll 	case 'g':
   1036   1.1     skrll 	  /* Ignore.  */
   1037   1.1     skrll 	  break;
   1038   1.1     skrll 	case OPTION_GC_SECTIONS:
   1039  1.11  christos 	  link_info.gc_sections = true;
   1040   1.1     skrll 	  break;
   1041   1.1     skrll 	case OPTION_PRINT_GC_SECTIONS:
   1042  1.11  christos 	  link_info.print_gc_sections = true;
   1043   1.1     skrll 	  break;
   1044   1.8  christos 	case OPTION_GC_KEEP_EXPORTED:
   1045  1.11  christos 	  link_info.gc_keep_exported = true;
   1046   1.8  christos 	  break;
   1047   1.1     skrll 	case OPTION_HELP:
   1048   1.1     skrll 	  help ();
   1049   1.1     skrll 	  xexit (0);
   1050   1.1     skrll 	  break;
   1051   1.1     skrll 	case 'L':
   1052  1.11  christos 	  ldfile_add_library_path (optarg, true);
   1053   1.1     skrll 	  break;
   1054   1.1     skrll 	case 'l':
   1055   1.1     skrll 	  lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL);
   1056   1.1     skrll 	  break;
   1057   1.1     skrll 	case 'M':
   1058   1.1     skrll 	  config.map_filename = "-";
   1059   1.1     skrll 	  break;
   1060   1.1     skrll 	case 'm':
   1061   1.1     skrll 	  /* Ignore.  Was handled in a pre-parse.   */
   1062   1.1     skrll 	  break;
   1063   1.1     skrll 	case OPTION_MAP:
   1064   1.1     skrll 	  config.map_filename = optarg;
   1065   1.1     skrll 	  break;
   1066   1.1     skrll 	case 'N':
   1067  1.11  christos 	  config.text_read_only = false;
   1068  1.11  christos 	  config.magic_demand_paged = false;
   1069  1.11  christos 	  input_flags.dynamic = false;
   1070   1.1     skrll 	  break;
   1071   1.1     skrll 	case OPTION_NO_OMAGIC:
   1072  1.11  christos 	  config.text_read_only = true;
   1073  1.11  christos 	  config.magic_demand_paged = true;
   1074   1.4  christos 	  /* NB/ Does not set input_flags.dynamic to TRUE.
   1075   1.1     skrll 	     Use --call-shared or -Bdynamic for this.  */
   1076   1.1     skrll 	  break;
   1077   1.1     skrll 	case 'n':
   1078  1.11  christos 	  config.text_read_only = true;
   1079  1.11  christos 	  config.magic_demand_paged = false;
   1080  1.11  christos 	  input_flags.dynamic = false;
   1081   1.1     skrll 	  break;
   1082   1.1     skrll 	case OPTION_NO_DEFINE_COMMON:
   1083  1.11  christos 	  link_info.inhibit_common_definition = true;
   1084   1.1     skrll 	  break;
   1085   1.1     skrll 	case OPTION_NO_DEMANGLE:
   1086  1.11  christos 	  demangling = false;
   1087   1.1     skrll 	  break;
   1088   1.1     skrll 	case OPTION_NO_GC_SECTIONS:
   1089  1.11  christos 	  link_info.gc_sections = false;
   1090   1.1     skrll 	  break;
   1091   1.1     skrll 	case OPTION_NO_PRINT_GC_SECTIONS:
   1092  1.11  christos 	  link_info.print_gc_sections = false;
   1093   1.1     skrll 	  break;
   1094   1.1     skrll 	case OPTION_NO_KEEP_MEMORY:
   1095  1.11  christos 	  link_info.keep_memory = false;
   1096   1.1     skrll 	  break;
   1097   1.1     skrll 	case OPTION_NO_UNDEFINED:
   1098  1.11  christos 	  link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
   1099   1.1     skrll 	  break;
   1100   1.1     skrll 	case OPTION_ALLOW_SHLIB_UNDEFINED:
   1101   1.1     skrll 	  link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
   1102   1.1     skrll 	  break;
   1103   1.1     skrll 	case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
   1104  1.11  christos 	  link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
   1105   1.1     skrll 	  break;
   1106   1.1     skrll 	case OPTION_UNRESOLVED_SYMBOLS:
   1107   1.1     skrll 	  if (strcmp (optarg, "ignore-all") == 0)
   1108   1.1     skrll 	    {
   1109   1.1     skrll 	      link_info.unresolved_syms_in_objects = RM_IGNORE;
   1110   1.1     skrll 	      link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
   1111   1.1     skrll 	    }
   1112   1.1     skrll 	  else if (strcmp (optarg, "report-all") == 0)
   1113   1.1     skrll 	    {
   1114  1.11  christos 	      link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
   1115  1.11  christos 	      link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
   1116   1.1     skrll 	    }
   1117   1.1     skrll 	  else if (strcmp (optarg, "ignore-in-object-files") == 0)
   1118   1.1     skrll 	    {
   1119   1.1     skrll 	      link_info.unresolved_syms_in_objects = RM_IGNORE;
   1120  1.11  christos 	      link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
   1121   1.1     skrll 	    }
   1122   1.8  christos 	  else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
   1123   1.1     skrll 	    {
   1124  1.11  christos 	      link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
   1125   1.1     skrll 	      link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
   1126   1.1     skrll 	    }
   1127   1.1     skrll 	  else
   1128  1.13  christos 	    fatal (_("%P: bad --unresolved-symbols option: %s\n"), optarg);
   1129   1.1     skrll 	  break;
   1130   1.1     skrll 	case OPTION_WARN_UNRESOLVED_SYMBOLS:
   1131  1.11  christos 	  link_info.warn_unresolved_syms = true;
   1132   1.1     skrll 	  break;
   1133   1.1     skrll 	case OPTION_ERROR_UNRESOLVED_SYMBOLS:
   1134  1.11  christos 	  link_info.warn_unresolved_syms = false;
   1135   1.1     skrll 	  break;
   1136   1.1     skrll 	case OPTION_ALLOW_MULTIPLE_DEFINITION:
   1137  1.11  christos 	  link_info.allow_multiple_definition = true;
   1138   1.1     skrll 	  break;
   1139  1.11  christos 
   1140  1.11  christos #if SUPPORT_ERROR_HANDLING_SCRIPT
   1141  1.11  christos 	case OPTION_ERROR_HANDLING_SCRIPT:
   1142  1.11  christos 	  /* FIXME: Should we warn if the script is being overridden by another ?
   1143  1.11  christos 	     Or maybe they should be chained together ?  */
   1144  1.11  christos 	  error_handling_script = optarg;
   1145  1.11  christos 	  break;
   1146  1.11  christos #endif
   1147  1.11  christos 
   1148  1.12  christos 	case OPTION_ENABLE_LINKER_VERSION:
   1149  1.12  christos 	  enable_linker_version = true;
   1150  1.12  christos 	  break;
   1151  1.12  christos 	case OPTION_DISABLE_LINKER_VERSION:
   1152  1.12  christos 	  enable_linker_version = false;
   1153  1.12  christos 	  break;
   1154  1.12  christos 
   1155  1.12  christos 	case OPTION_UNDEFINED_VERSION:
   1156  1.12  christos 	  link_info.allow_undefined_version = true;
   1157  1.12  christos 	  break;
   1158   1.1     skrll 	case OPTION_NO_UNDEFINED_VERSION:
   1159  1.11  christos 	  link_info.allow_undefined_version = false;
   1160   1.1     skrll 	  break;
   1161   1.1     skrll 	case OPTION_DEFAULT_SYMVER:
   1162  1.11  christos 	  link_info.create_default_symver = true;
   1163   1.1     skrll 	  break;
   1164   1.1     skrll 	case OPTION_DEFAULT_IMPORTED_SYMVER:
   1165  1.11  christos 	  link_info.default_imported_symver = true;
   1166   1.1     skrll 	  break;
   1167   1.1     skrll 	case OPTION_NO_WARN_MISMATCH:
   1168  1.11  christos 	  command_line.warn_mismatch = false;
   1169   1.1     skrll 	  break;
   1170   1.1     skrll 	case OPTION_NO_WARN_SEARCH_MISMATCH:
   1171  1.11  christos 	  command_line.warn_search_mismatch = false;
   1172   1.1     skrll 	  break;
   1173   1.1     skrll 	case OPTION_NOINHIBIT_EXEC:
   1174  1.11  christos 	  force_make_executable = true;
   1175   1.1     skrll 	  break;
   1176   1.1     skrll 	case OPTION_NOSTDLIB:
   1177  1.11  christos 	  config.only_cmd_line_lib_dirs = true;
   1178   1.1     skrll 	  break;
   1179   1.1     skrll 	case OPTION_NO_WHOLE_ARCHIVE:
   1180  1.11  christos 	  input_flags.whole_archive = false;
   1181   1.1     skrll 	  break;
   1182   1.1     skrll 	case 'O':
   1183   1.1     skrll 	  /* FIXME "-O<non-digits> <value>" used to set the address of
   1184   1.1     skrll 	     section <non-digits>.  Was this for compatibility with
   1185   1.1     skrll 	     something, or can we create a new option to do that
   1186   1.1     skrll 	     (with a syntax similar to -defsym)?
   1187   1.1     skrll 	     getopt can't handle two args to an option without kludges.  */
   1188   1.1     skrll 
   1189   1.1     skrll 	  /* Enable optimizations of output files.  */
   1190  1.11  christos 	  link_info.optimize = strtoul (optarg, NULL, 0) != 0;
   1191   1.1     skrll 	  break;
   1192   1.1     skrll 	case 'o':
   1193   1.1     skrll 	  lang_add_output (optarg, 0);
   1194   1.1     skrll 	  break;
   1195   1.1     skrll 	case OPTION_OFORMAT:
   1196   1.1     skrll 	  lang_add_output_format (optarg, NULL, NULL, 0);
   1197   1.1     skrll 	  break;
   1198   1.8  christos 	case OPTION_OUT_IMPLIB:
   1199   1.8  christos 	  command_line.out_implib_filename = xstrdup (optarg);
   1200   1.8  christos 	  break;
   1201   1.5  christos 	case OPTION_PRINT_SYSROOT:
   1202   1.5  christos 	  if (*ld_sysroot)
   1203   1.5  christos 	    puts (ld_sysroot);
   1204   1.5  christos 	  xexit (0);
   1205   1.5  christos 	  break;
   1206   1.4  christos 	case OPTION_PRINT_OUTPUT_FORMAT:
   1207  1.11  christos 	  command_line.print_output_format = true;
   1208   1.4  christos 	  break;
   1209   1.3  christos 	case OPTION_PLUGIN:
   1210  1.14  christos 	  if (bfd_plugin_enabled ())
   1211  1.14  christos 	    plugin_opt_plugin (optarg);
   1212   1.3  christos 	  break;
   1213   1.3  christos 	case OPTION_PLUGIN_OPT:
   1214  1.14  christos 	  if (bfd_plugin_enabled ()
   1215  1.14  christos 	      && plugin_opt_plugin_arg (optarg))
   1216  1.13  christos 	    fatal (_("%P: bad -plugin-opt option\n"));
   1217  1.13  christos 	  break;
   1218  1.13  christos 	case OPTION_PLUGIN_SAVE_TEMPS:
   1219  1.13  christos 	  config.plugin_save_temps = true;
   1220   1.3  christos 	  break;
   1221   1.1     skrll 	case 'q':
   1222  1.11  christos 	  link_info.emitrelocations = true;
   1223   1.1     skrll 	  break;
   1224   1.1     skrll 	case 'i':
   1225   1.1     skrll 	case 'r':
   1226   1.1     skrll 	  if (optind == last_optind)
   1227   1.1     skrll 	    /* This can happen if the user put "-rpath,a" on the command
   1228   1.1     skrll 	       line.  (Or something similar.  The comma is important).
   1229   1.1     skrll 	       Getopt becomes confused and thinks that this is a -r option
   1230   1.1     skrll 	       but it cannot parse the text after the -r so it refuses to
   1231   1.1     skrll 	       increment the optind counter.  Detect this case and issue
   1232   1.1     skrll 	       an error message here.  We cannot just make this a warning,
   1233   1.1     skrll 	       increment optind, and continue because getopt is too confused
   1234   1.1     skrll 	       and will seg-fault the next time around.  */
   1235  1.13  christos 	    fatal(_("%P: unrecognised option: %s\n"), argv[optind]);
   1236   1.5  christos 
   1237   1.5  christos 	  if (bfd_link_pic (&link_info))
   1238  1.13  christos 	    fatal (_("%P: -r and %s may not be used together\n"),
   1239  1.13  christos 		   bfd_link_dll (&link_info) ? "-shared" : "-pie");
   1240   1.1     skrll 
   1241   1.5  christos 	  link_info.type = type_relocatable;
   1242  1.11  christos 	  config.build_constructors = false;
   1243  1.11  christos 	  config.magic_demand_paged = false;
   1244  1.11  christos 	  config.text_read_only = false;
   1245  1.11  christos 	  input_flags.dynamic = false;
   1246   1.1     skrll 	  break;
   1247   1.1     skrll 	case 'R':
   1248   1.1     skrll 	  /* The GNU linker traditionally uses -R to mean to include
   1249   1.1     skrll 	     only the symbols from a file.  The Solaris linker uses -R
   1250   1.1     skrll 	     to set the path used by the runtime linker to find
   1251   1.1     skrll 	     libraries.  This is the GNU linker -rpath argument.  We
   1252   1.1     skrll 	     try to support both simultaneously by checking the file
   1253   1.1     skrll 	     named.  If it is a directory, rather than a regular file,
   1254   1.1     skrll 	     we assume -rpath was meant.  */
   1255   1.1     skrll 	  {
   1256   1.1     skrll 	    struct stat s;
   1257   1.1     skrll 
   1258   1.1     skrll 	    if (stat (optarg, &s) >= 0
   1259   1.1     skrll 		&& ! S_ISDIR (s.st_mode))
   1260   1.1     skrll 	      {
   1261   1.1     skrll 		lang_add_input_file (optarg,
   1262   1.1     skrll 				     lang_input_file_is_symbols_only_enum,
   1263   1.1     skrll 				     NULL);
   1264   1.1     skrll 		break;
   1265   1.1     skrll 	      }
   1266   1.1     skrll 	  }
   1267   1.1     skrll 	  /* Fall through.  */
   1268   1.1     skrll 	case OPTION_RPATH:
   1269   1.1     skrll 	  if (command_line.rpath == NULL)
   1270   1.1     skrll 	    command_line.rpath = xstrdup (optarg);
   1271   1.1     skrll 	  else
   1272   1.1     skrll 	    {
   1273   1.1     skrll 	      size_t rpath_len = strlen (command_line.rpath);
   1274   1.1     skrll 	      size_t optarg_len = strlen (optarg);
   1275   1.1     skrll 	      char *buf;
   1276   1.1     skrll 	      char *cp = command_line.rpath;
   1277   1.1     skrll 
   1278   1.1     skrll 	      /* First see whether OPTARG is already in the path.  */
   1279   1.1     skrll 	      do
   1280   1.1     skrll 		{
   1281   1.1     skrll 		  if (strncmp (optarg, cp, optarg_len) == 0
   1282   1.1     skrll 		      && (cp[optarg_len] == 0
   1283   1.1     skrll 			  || cp[optarg_len] == config.rpath_separator))
   1284   1.1     skrll 		    /* We found it.  */
   1285   1.1     skrll 		    break;
   1286   1.1     skrll 
   1287   1.1     skrll 		  /* Not yet found.  */
   1288   1.1     skrll 		  cp = strchr (cp, config.rpath_separator);
   1289   1.1     skrll 		  if (cp != NULL)
   1290   1.1     skrll 		    ++cp;
   1291   1.1     skrll 		}
   1292   1.1     skrll 	      while (cp != NULL);
   1293   1.1     skrll 
   1294   1.1     skrll 	      if (cp == NULL)
   1295   1.1     skrll 		{
   1296   1.3  christos 		  buf = (char *) xmalloc (rpath_len + optarg_len + 2);
   1297   1.1     skrll 		  sprintf (buf, "%s%c%s", command_line.rpath,
   1298   1.1     skrll 			   config.rpath_separator, optarg);
   1299   1.1     skrll 		  free (command_line.rpath);
   1300   1.1     skrll 		  command_line.rpath = buf;
   1301   1.1     skrll 		}
   1302   1.1     skrll 	    }
   1303   1.1     skrll 	  break;
   1304   1.1     skrll 	case OPTION_RPATH_LINK:
   1305   1.1     skrll 	  if (command_line.rpath_link == NULL)
   1306   1.1     skrll 	    command_line.rpath_link = xstrdup (optarg);
   1307   1.1     skrll 	  else
   1308   1.1     skrll 	    {
   1309   1.1     skrll 	      char *buf;
   1310   1.1     skrll 
   1311   1.3  christos 	      buf = (char *) xmalloc (strlen (command_line.rpath_link)
   1312   1.8  christos 				      + strlen (optarg)
   1313   1.8  christos 				      + 2);
   1314   1.1     skrll 	      sprintf (buf, "%s%c%s", command_line.rpath_link,
   1315   1.1     skrll 		       config.rpath_separator, optarg);
   1316   1.1     skrll 	      free (command_line.rpath_link);
   1317   1.1     skrll 	      command_line.rpath_link = buf;
   1318   1.1     skrll 	    }
   1319   1.1     skrll 	  break;
   1320   1.3  christos 	case OPTION_NO_RELAX:
   1321   1.3  christos 	  DISABLE_RELAXATION;
   1322   1.3  christos 	  break;
   1323   1.1     skrll 	case OPTION_RELAX:
   1324   1.3  christos 	  ENABLE_RELAXATION;
   1325   1.1     skrll 	  break;
   1326   1.1     skrll 	case OPTION_RETAIN_SYMBOLS_FILE:
   1327   1.1     skrll 	  add_keepsyms_file (optarg);
   1328   1.1     skrll 	  break;
   1329   1.1     skrll 	case 'S':
   1330   1.1     skrll 	  link_info.strip = strip_debugger;
   1331   1.1     skrll 	  break;
   1332   1.1     skrll 	case 's':
   1333   1.1     skrll 	  link_info.strip = strip_all;
   1334   1.1     skrll 	  break;
   1335   1.1     skrll 	case OPTION_STRIP_DISCARDED:
   1336  1.11  christos 	  link_info.strip_discarded = true;
   1337   1.1     skrll 	  break;
   1338   1.1     skrll 	case OPTION_NO_STRIP_DISCARDED:
   1339  1.11  christos 	  link_info.strip_discarded = false;
   1340   1.1     skrll 	  break;
   1341   1.9  christos 	case OPTION_DISABLE_MULTIPLE_DEFS_ABS:
   1342  1.11  christos 	  link_info.prohibit_multiple_definition_absolute = true;
   1343   1.9  christos 	  break;
   1344   1.1     skrll 	case OPTION_SHARED:
   1345   1.1     skrll 	  if (config.has_shared)
   1346   1.1     skrll 	    {
   1347   1.5  christos 	      if (bfd_link_relocatable (&link_info))
   1348  1.13  christos 		fatal (_("%P: -r and %s may not be used together\n"),
   1349   1.9  christos 		       "-shared");
   1350   1.5  christos 
   1351   1.5  christos 	      link_info.type = type_dll;
   1352   1.1     skrll 	      /* When creating a shared library, the default
   1353   1.1     skrll 		 behaviour is to ignore any unresolved references.  */
   1354   1.1     skrll 	      if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
   1355   1.1     skrll 		link_info.unresolved_syms_in_objects = RM_IGNORE;
   1356   1.1     skrll 	      if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
   1357   1.1     skrll 		link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
   1358   1.1     skrll 	    }
   1359   1.1     skrll 	  else
   1360  1.13  christos 	    fatal (_("%P: -shared not supported\n"));
   1361   1.1     skrll 	  break;
   1362  1.11  christos 	case OPTION_NO_PIE:
   1363  1.11  christos 	  link_info.type = type_pde;
   1364  1.11  christos 	  break;
   1365   1.1     skrll 	case OPTION_PIE:
   1366   1.1     skrll 	  if (config.has_shared)
   1367   1.1     skrll 	    {
   1368   1.5  christos 	      if (bfd_link_relocatable (&link_info))
   1369  1.13  christos 		fatal (_("%P: -r and %s may not be used together\n"), "-pie");
   1370   1.5  christos 
   1371   1.5  christos 	      link_info.type = type_pie;
   1372   1.1     skrll 	    }
   1373   1.1     skrll 	  else
   1374  1.13  christos 	    fatal (_("%P: -pie not supported\n"));
   1375   1.1     skrll 	  break;
   1376   1.1     skrll 	case 'h':		/* Used on Solaris.  */
   1377   1.1     skrll 	case OPTION_SONAME:
   1378   1.5  christos 	  if (optarg[0] == '\0' && command_line.soname
   1379   1.5  christos 	      && command_line.soname[0])
   1380   1.5  christos 	    einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
   1381   1.5  christos 	  else
   1382   1.5  christos 	    command_line.soname = optarg;
   1383   1.1     skrll 	  break;
   1384   1.1     skrll 	case OPTION_SORT_COMMON:
   1385   1.1     skrll 	  if (optarg == NULL
   1386   1.1     skrll 	      || strcmp (optarg, N_("descending")) == 0)
   1387   1.8  christos 	    config.sort_common = sort_descending;
   1388   1.8  christos 	  else if (strcmp (optarg, N_("ascending")) == 0)
   1389   1.1     skrll 	    config.sort_common = sort_ascending;
   1390   1.1     skrll 	  else
   1391  1.13  christos 	    fatal (_("%P: invalid common section sorting option: %s\n"),
   1392   1.1     skrll 		   optarg);
   1393   1.1     skrll 	  break;
   1394   1.1     skrll 	case OPTION_SORT_SECTION:
   1395   1.1     skrll 	  if (strcmp (optarg, N_("name")) == 0)
   1396   1.1     skrll 	    sort_section = by_name;
   1397   1.1     skrll 	  else if (strcmp (optarg, N_("alignment")) == 0)
   1398   1.1     skrll 	    sort_section = by_alignment;
   1399   1.1     skrll 	  else
   1400  1.13  christos 	    fatal (_("%P: invalid section sorting option: %s\n"), optarg);
   1401  1.13  christos 	  break;
   1402  1.13  christos 	case OPTION_SECTION_ORDERING_FILE:
   1403  1.13  christos 	  if (command_line.section_ordering_file != NULL
   1404  1.13  christos 	      && strcmp (optarg, command_line.section_ordering_file) != 0)
   1405  1.13  christos 	    einfo (_("%P: warning: section ordering file changed.  Ignoring earlier definition\n"));
   1406  1.13  christos 	  command_line.section_ordering_file = optarg;
   1407   1.1     skrll 	  break;
   1408   1.1     skrll 	case OPTION_STATS:
   1409  1.11  christos 	  config.stats = true;
   1410  1.13  christos 	  if (optarg)
   1411  1.13  christos 	    config.stats_filename = optarg;
   1412  1.13  christos 	  else
   1413  1.13  christos 	    {
   1414  1.13  christos 	      config.stats_filename = NULL;
   1415  1.13  christos 	      config.stats_file = stderr;
   1416  1.13  christos 	    }
   1417  1.13  christos 	  break;
   1418  1.13  christos 	case OPTION_NO_STATS:
   1419  1.13  christos 	  config.stats = false;
   1420  1.13  christos 	  config.stats_filename = NULL;
   1421  1.11  christos 	  break;
   1422  1.11  christos 	case OPTION_NO_SYMBOLIC:
   1423  1.11  christos 	  opt_symbolic = symbolic_unset;
   1424   1.1     skrll 	  break;
   1425   1.1     skrll 	case OPTION_SYMBOLIC:
   1426  1.10  christos 	  opt_symbolic = symbolic;
   1427   1.1     skrll 	  break;
   1428   1.1     skrll 	case OPTION_SYMBOLIC_FUNCTIONS:
   1429  1.10  christos 	  opt_symbolic = symbolic_functions;
   1430   1.1     skrll 	  break;
   1431   1.1     skrll 	case 't':
   1432  1.10  christos 	  ++trace_files;
   1433   1.1     skrll 	  break;
   1434   1.1     skrll 	case 'T':
   1435   1.1     skrll 	  previous_script_handle = saved_script_handle;
   1436  1.10  christos 	  ldfile_open_script_file (optarg);
   1437   1.1     skrll 	  parser_input = input_script;
   1438   1.1     skrll 	  yyparse ();
   1439   1.1     skrll 	  previous_script_handle = NULL;
   1440   1.1     skrll 	  break;
   1441   1.1     skrll 	case OPTION_DEFAULT_SCRIPT:
   1442   1.1     skrll 	  command_line.default_script = optarg;
   1443   1.1     skrll 	  break;
   1444   1.1     skrll 	case OPTION_SECTION_START:
   1445   1.1     skrll 	  {
   1446   1.1     skrll 	    char *optarg2;
   1447   1.1     skrll 	    char *sec_name;
   1448   1.1     skrll 	    int len;
   1449   1.1     skrll 
   1450   1.1     skrll 	    /* Check for <something>=<somthing>...  */
   1451   1.1     skrll 	    optarg2 = strchr (optarg, '=');
   1452   1.1     skrll 	    if (optarg2 == NULL)
   1453  1.13  christos 	      fatal (_("%P: invalid argument to option"
   1454   1.1     skrll 		       " \"--section-start\"\n"));
   1455   1.1     skrll 
   1456   1.1     skrll 	    optarg2++;
   1457   1.1     skrll 
   1458   1.1     skrll 	    /* So far so good.  Are all the args present?  */
   1459   1.1     skrll 	    if ((*optarg == '\0') || (*optarg2 == '\0'))
   1460  1.13  christos 	      fatal (_("%P: missing argument(s) to option"
   1461   1.1     skrll 		       " \"--section-start\"\n"));
   1462   1.1     skrll 
   1463   1.1     skrll 	    /* We must copy the section name as set_section_start
   1464   1.1     skrll 	       doesn't do it for us.  */
   1465   1.1     skrll 	    len = optarg2 - optarg;
   1466   1.3  christos 	    sec_name = (char *) xmalloc (len);
   1467   1.1     skrll 	    memcpy (sec_name, optarg, len - 1);
   1468   1.1     skrll 	    sec_name[len - 1] = 0;
   1469   1.1     skrll 
   1470   1.1     skrll 	    /* Then set it...  */
   1471   1.1     skrll 	    set_section_start (sec_name, optarg2);
   1472   1.1     skrll 	  }
   1473   1.1     skrll 	  break;
   1474   1.1     skrll 	case OPTION_TARGET_HELP:
   1475   1.1     skrll 	  /* Mention any target specific options.  */
   1476   1.1     skrll 	  ldemul_list_emulation_options (stdout);
   1477   1.1     skrll 	  exit (0);
   1478   1.1     skrll 	case OPTION_TBSS:
   1479   1.1     skrll 	  set_segment_start (".bss", optarg);
   1480   1.1     skrll 	  break;
   1481   1.1     skrll 	case OPTION_TDATA:
   1482   1.1     skrll 	  set_segment_start (".data", optarg);
   1483   1.1     skrll 	  break;
   1484   1.1     skrll 	case OPTION_TTEXT:
   1485   1.1     skrll 	  set_segment_start (".text", optarg);
   1486   1.1     skrll 	  break;
   1487  1.13  christos 	case OPTION_IMAGE_BASE:
   1488  1.13  christos 	  /* Unless PE, --image-base and -Ttext-segment behavior is the same
   1489  1.13  christos 	     PE-specific functionality is implemented in emultempl/{pe, pep, beos}.em  */
   1490   1.3  christos 	case OPTION_TTEXT_SEGMENT:
   1491   1.3  christos 	  set_segment_start (".text-segment", optarg);
   1492   1.3  christos 	  break;
   1493   1.4  christos 	case OPTION_TRODATA_SEGMENT:
   1494   1.4  christos 	  set_segment_start (".rodata-segment", optarg);
   1495   1.4  christos 	  break;
   1496   1.5  christos 	case OPTION_TLDATA_SEGMENT:
   1497   1.5  christos 	  set_segment_start (".ldata-segment", optarg);
   1498   1.5  christos 	  break;
   1499   1.1     skrll 	case OPTION_TRADITIONAL_FORMAT:
   1500  1.11  christos 	  link_info.traditional_format = true;
   1501   1.1     skrll 	  break;
   1502   1.1     skrll 	case OPTION_TASK_LINK:
   1503  1.11  christos 	  link_info.task_link = true;
   1504   1.8  christos 	  /* Fall through.  */
   1505   1.1     skrll 	case OPTION_UR:
   1506   1.5  christos 	  if (bfd_link_pic (&link_info))
   1507  1.13  christos 	    fatal (_("%P: -r and %s may not be used together\n"),
   1508  1.13  christos 		   bfd_link_dll (&link_info) ? "-shared" : "-pie");
   1509   1.5  christos 
   1510   1.5  christos 	  link_info.type = type_relocatable;
   1511  1.11  christos 	  config.build_constructors = true;
   1512  1.11  christos 	  config.magic_demand_paged = false;
   1513  1.11  christos 	  config.text_read_only = false;
   1514  1.11  christos 	  input_flags.dynamic = false;
   1515   1.1     skrll 	  break;
   1516   1.1     skrll 	case 'u':
   1517  1.11  christos 	  ldlang_add_undef (optarg, true);
   1518   1.1     skrll 	  break;
   1519   1.8  christos 	case OPTION_REQUIRE_DEFINED_SYMBOL:
   1520   1.8  christos 	  ldlang_add_require_defined (optarg);
   1521   1.5  christos 	  break;
   1522   1.1     skrll 	case OPTION_UNIQUE:
   1523   1.1     skrll 	  if (optarg != NULL)
   1524   1.1     skrll 	    lang_add_unique (optarg);
   1525   1.1     skrll 	  else
   1526  1.11  christos 	    config.unique_orphan_sections = true;
   1527   1.1     skrll 	  break;
   1528   1.1     skrll 	case OPTION_VERBOSE:
   1529   1.1     skrll 	  ldversion (1);
   1530  1.11  christos 	  version_printed = true;
   1531  1.11  christos 	  verbose = true;
   1532   1.1     skrll 	  overflow_cutoff_limit = -2;
   1533   1.3  christos 	  if (optarg != NULL)
   1534   1.3  christos 	    {
   1535   1.3  christos 	      char *end;
   1536   1.3  christos 	      int level ATTRIBUTE_UNUSED = strtoul (optarg, &end, 0);
   1537   1.3  christos 	      if (*end)
   1538  1.13  christos 		fatal (_("%P: invalid number `%s'\n"), optarg);
   1539   1.3  christos 	      report_plugin_symbols = level > 1;
   1540   1.3  christos 	    }
   1541   1.1     skrll 	  break;
   1542   1.1     skrll 	case 'v':
   1543   1.1     skrll 	  ldversion (0);
   1544  1.11  christos 	  version_printed = true;
   1545   1.1     skrll 	  break;
   1546   1.1     skrll 	case 'V':
   1547   1.1     skrll 	  ldversion (1);
   1548  1.11  christos 	  version_printed = true;
   1549   1.1     skrll 	  break;
   1550   1.1     skrll 	case OPTION_VERSION:
   1551   1.1     skrll 	  ldversion (2);
   1552   1.1     skrll 	  xexit (0);
   1553   1.1     skrll 	  break;
   1554   1.1     skrll 	case OPTION_VERSION_SCRIPT:
   1555   1.1     skrll 	  /* This option indicates a small script that only specifies
   1556   1.1     skrll 	     version information.  Read it, but don't assume that
   1557   1.1     skrll 	     we've seen a linker script.  */
   1558   1.1     skrll 	  {
   1559   1.1     skrll 	    FILE *hold_script_handle;
   1560   1.1     skrll 
   1561   1.1     skrll 	    hold_script_handle = saved_script_handle;
   1562   1.1     skrll 	    ldfile_open_command_file (optarg);
   1563   1.1     skrll 	    saved_script_handle = hold_script_handle;
   1564   1.1     skrll 	    parser_input = input_version_script;
   1565   1.1     skrll 	    yyparse ();
   1566   1.1     skrll 	  }
   1567   1.1     skrll 	  break;
   1568   1.1     skrll 	case OPTION_VERSION_EXPORTS_SECTION:
   1569   1.1     skrll 	  /* This option records a version symbol to be applied to the
   1570   1.1     skrll 	     symbols listed for export to be found in the object files
   1571   1.1     skrll 	     .exports sections.  */
   1572   1.1     skrll 	  command_line.version_exports_section = optarg;
   1573   1.1     skrll 	  break;
   1574   1.1     skrll 	case OPTION_DYNAMIC_LIST_DATA:
   1575  1.10  christos 	  opt_dynamic_list = dynamic_list_data;
   1576   1.1     skrll 	  break;
   1577   1.1     skrll 	case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
   1578   1.1     skrll 	  lang_append_dynamic_list_cpp_typeinfo ();
   1579  1.10  christos 	  if (opt_dynamic_list != dynamic_list_data)
   1580  1.10  christos 	    opt_dynamic_list = dynamic_list;
   1581   1.1     skrll 	  break;
   1582   1.1     skrll 	case OPTION_DYNAMIC_LIST_CPP_NEW:
   1583   1.1     skrll 	  lang_append_dynamic_list_cpp_new ();
   1584  1.10  christos 	  if (opt_dynamic_list != dynamic_list_data)
   1585  1.10  christos 	    opt_dynamic_list = dynamic_list;
   1586   1.1     skrll 	  break;
   1587   1.1     skrll 	case OPTION_DYNAMIC_LIST:
   1588   1.1     skrll 	  /* This option indicates a small script that only specifies
   1589   1.1     skrll 	     a dynamic list.  Read it, but don't assume that we've
   1590   1.1     skrll 	     seen a linker script.  */
   1591   1.1     skrll 	  {
   1592   1.1     skrll 	    FILE *hold_script_handle;
   1593   1.1     skrll 
   1594   1.1     skrll 	    hold_script_handle = saved_script_handle;
   1595   1.1     skrll 	    ldfile_open_command_file (optarg);
   1596   1.1     skrll 	    saved_script_handle = hold_script_handle;
   1597   1.1     skrll 	    parser_input = input_dynamic_list;
   1598  1.11  christos 	    current_dynamic_list_p = &link_info.dynamic_list;
   1599   1.1     skrll 	    yyparse ();
   1600   1.1     skrll 	  }
   1601  1.10  christos 	  if (opt_dynamic_list != dynamic_list_data)
   1602  1.10  christos 	    opt_dynamic_list = dynamic_list;
   1603  1.11  christos 	  break;
   1604  1.11  christos 	case OPTION_EXPORT_DYNAMIC_SYMBOL:
   1605  1.11  christos 	  {
   1606  1.11  christos 	    struct bfd_elf_version_expr *expr
   1607  1.11  christos 	      = lang_new_vers_pattern (NULL, xstrdup (optarg), NULL,
   1608  1.11  christos 				       false);
   1609  1.11  christos 	    lang_append_dynamic_list (&export_list, expr);
   1610  1.11  christos 	  }
   1611  1.11  christos 	  break;
   1612  1.11  christos 	case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST:
   1613  1.11  christos 	  /* This option indicates a small script that only specifies
   1614  1.11  christos 	     an export list.  Read it, but don't assume that we've
   1615  1.11  christos 	     seen a linker script.  */
   1616  1.11  christos 	  {
   1617  1.11  christos 	    FILE *hold_script_handle;
   1618  1.11  christos 
   1619  1.11  christos 	    hold_script_handle = saved_script_handle;
   1620  1.11  christos 	    ldfile_open_command_file (optarg);
   1621  1.11  christos 	    saved_script_handle = hold_script_handle;
   1622  1.11  christos 	    parser_input = input_dynamic_list;
   1623  1.11  christos 	    current_dynamic_list_p = &export_list;
   1624  1.11  christos 	    yyparse ();
   1625  1.11  christos 	  }
   1626   1.1     skrll 	  break;
   1627   1.1     skrll 	case OPTION_WARN_COMMON:
   1628  1.11  christos 	  config.warn_common = true;
   1629   1.1     skrll 	  break;
   1630   1.1     skrll 	case OPTION_WARN_CONSTRUCTORS:
   1631  1.11  christos 	  config.warn_constructors = true;
   1632   1.1     skrll 	  break;
   1633   1.1     skrll 	case OPTION_WARN_FATAL:
   1634  1.11  christos 	  config.fatal_warnings = true;
   1635   1.1     skrll 	  break;
   1636   1.1     skrll 	case OPTION_NO_WARN_FATAL:
   1637  1.11  christos 	  config.fatal_warnings = false;
   1638   1.1     skrll 	  break;
   1639  1.12  christos 	case OPTION_NO_WARNINGS:
   1640  1.12  christos 	case 'w':
   1641  1.12  christos 	  config.no_warnings = true;
   1642  1.12  christos 	  config.fatal_warnings = false;
   1643  1.12  christos 	  break;
   1644   1.1     skrll 	case OPTION_WARN_MULTIPLE_GP:
   1645  1.11  christos 	  config.warn_multiple_gp = true;
   1646   1.1     skrll 	  break;
   1647   1.1     skrll 	case OPTION_WARN_ONCE:
   1648  1.11  christos 	  config.warn_once = true;
   1649   1.1     skrll 	  break;
   1650   1.1     skrll 	case OPTION_WARN_SECTION_ALIGN:
   1651  1.11  christos 	  config.warn_section_align = true;
   1652   1.1     skrll 	  break;
   1653  1.11  christos 	case OPTION_WARN_TEXTREL:
   1654  1.11  christos 	  link_info.textrel_check = textrel_check_warning;
   1655   1.1     skrll 	  break;
   1656   1.3  christos 	case OPTION_WARN_ALTERNATE_EM:
   1657  1.11  christos 	  link_info.warn_alternate_em = true;
   1658   1.3  christos 	  break;
   1659   1.1     skrll 	case OPTION_WHOLE_ARCHIVE:
   1660  1.11  christos 	  input_flags.whole_archive = true;
   1661   1.1     skrll 	  break;
   1662   1.3  christos 	case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC:
   1663  1.11  christos 	  input_flags.add_DT_NEEDED_for_dynamic = true;
   1664   1.1     skrll 	  break;
   1665   1.3  christos 	case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC:
   1666  1.11  christos 	  input_flags.add_DT_NEEDED_for_dynamic = false;
   1667   1.1     skrll 	  break;
   1668   1.3  christos 	case OPTION_ADD_DT_NEEDED_FOR_REGULAR:
   1669  1.11  christos 	  input_flags.add_DT_NEEDED_for_regular = true;
   1670   1.1     skrll 	  break;
   1671   1.3  christos 	case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR:
   1672  1.11  christos 	  input_flags.add_DT_NEEDED_for_regular = false;
   1673   1.1     skrll 	  break;
   1674   1.1     skrll 	case OPTION_WRAP:
   1675   1.1     skrll 	  add_wrap (optarg);
   1676   1.1     skrll 	  break;
   1677   1.2     skrll 	case OPTION_IGNORE_UNRESOLVED_SYMBOL:
   1678   1.5  christos 	  add_ignoresym (&link_info, optarg);
   1679   1.2     skrll 	  break;
   1680   1.1     skrll 	case OPTION_DISCARD_NONE:
   1681   1.1     skrll 	  link_info.discard = discard_none;
   1682   1.1     skrll 	  break;
   1683   1.1     skrll 	case 'X':
   1684   1.1     skrll 	  link_info.discard = discard_l;
   1685   1.1     skrll 	  break;
   1686   1.1     skrll 	case 'x':
   1687   1.1     skrll 	  link_info.discard = discard_all;
   1688   1.1     skrll 	  break;
   1689   1.1     skrll 	case 'Y':
   1690  1.11  christos 	  if (startswith (optarg, "P,"))
   1691   1.1     skrll 	    optarg += 2;
   1692  1.11  christos 	  free (default_dirlist);
   1693   1.1     skrll 	  default_dirlist = xstrdup (optarg);
   1694   1.1     skrll 	  break;
   1695   1.1     skrll 	case 'y':
   1696   1.1     skrll 	  add_ysym (optarg);
   1697   1.1     skrll 	  break;
   1698   1.1     skrll 	case OPTION_SPARE_DYNAMIC_TAGS:
   1699   1.1     skrll 	  link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0);
   1700   1.1     skrll 	  break;
   1701   1.1     skrll 	case OPTION_SPLIT_BY_RELOC:
   1702   1.1     skrll 	  if (optarg != NULL)
   1703   1.1     skrll 	    config.split_by_reloc = strtoul (optarg, NULL, 0);
   1704   1.1     skrll 	  else
   1705   1.1     skrll 	    config.split_by_reloc = 32768;
   1706   1.1     skrll 	  break;
   1707   1.1     skrll 	case OPTION_SPLIT_BY_FILE:
   1708   1.1     skrll 	  if (optarg != NULL)
   1709   1.1     skrll 	    config.split_by_file = bfd_scan_vma (optarg, NULL, 0);
   1710   1.1     skrll 	  else
   1711   1.1     skrll 	    config.split_by_file = 1;
   1712   1.1     skrll 	  break;
   1713   1.1     skrll 	case OPTION_CHECK_SECTIONS:
   1714   1.3  christos 	  command_line.check_section_addresses = 1;
   1715   1.1     skrll 	  break;
   1716   1.1     skrll 	case OPTION_NO_CHECK_SECTIONS:
   1717   1.3  christos 	  command_line.check_section_addresses = 0;
   1718   1.1     skrll 	  break;
   1719   1.1     skrll 	case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
   1720  1.11  christos 	  command_line.accept_unknown_input_arch = true;
   1721   1.1     skrll 	  break;
   1722   1.1     skrll 	case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
   1723  1.11  christos 	  command_line.accept_unknown_input_arch = false;
   1724   1.1     skrll 	  break;
   1725   1.1     skrll 	case '(':
   1726   1.1     skrll 	  lang_enter_group ();
   1727   1.3  christos 	  ingroup++;
   1728   1.1     skrll 	  break;
   1729   1.1     skrll 	case ')':
   1730   1.1     skrll 	  if (! ingroup)
   1731  1.13  christos 	    fatal (_("%P: group ended before it began (--help for usage)\n"));
   1732   1.1     skrll 
   1733   1.1     skrll 	  lang_leave_group ();
   1734   1.3  christos 	  ingroup--;
   1735   1.1     skrll 	  break;
   1736   1.1     skrll 
   1737   1.1     skrll 	case OPTION_INIT:
   1738   1.1     skrll 	  link_info.init_function = optarg;
   1739   1.1     skrll 	  break;
   1740   1.1     skrll 
   1741   1.1     skrll 	case OPTION_FINI:
   1742   1.1     skrll 	  link_info.fini_function = optarg;
   1743   1.1     skrll 	  break;
   1744   1.1     skrll 
   1745  1.12  christos 	case OPTION_REMAP_INPUTS_FILE:
   1746  1.12  christos 	  if (! ldfile_add_remap_file (optarg))
   1747  1.13  christos 	    fatal (_("%P: failed to add remap file %s\n"), optarg);
   1748  1.12  christos 	  break;
   1749  1.12  christos 
   1750  1.12  christos 	case OPTION_REMAP_INPUTS:
   1751  1.12  christos 	  {
   1752  1.12  christos 	    char *optarg2 = strchr (optarg, '=');
   1753  1.12  christos 	    if (optarg2 == NULL)
   1754  1.12  christos 	      /* FIXME: Should we allow --remap-inputs=@myfile as a synonym
   1755  1.12  christos 		 for --remap-inputs-file=myfile ?  */
   1756  1.13  christos 	      fatal (_("%P: invalid argument to option --remap-inputs\n"));
   1757  1.12  christos 	    size_t len = optarg2 - optarg;
   1758  1.12  christos 	    char * pattern = xmalloc (len + 1);
   1759  1.12  christos 	    memcpy (pattern, optarg, len);
   1760  1.12  christos 	    pattern[len] = 0;
   1761  1.12  christos 	    ldfile_add_remap (pattern, optarg2 + 1);
   1762  1.12  christos 	    free (pattern);
   1763  1.12  christos 	  }
   1764  1.12  christos 	  break;
   1765  1.12  christos 
   1766   1.1     skrll 	case OPTION_REDUCE_MEMORY_OVERHEADS:
   1767  1.11  christos 	  link_info.reduce_memory_overheads = true;
   1768   1.1     skrll 	  if (config.hash_table_size == 0)
   1769   1.1     skrll 	    config.hash_table_size = 1021;
   1770   1.1     skrll 	  break;
   1771   1.1     skrll 
   1772  1.11  christos 	case OPTION_MAX_CACHE_SIZE:
   1773  1.11  christos 	  {
   1774  1.11  christos 	    char *end;
   1775  1.11  christos 	    bfd_size_type cache_size = strtoul (optarg, &end, 0);
   1776  1.11  christos 	    if (*end != '\0')
   1777  1.13  christos 	      fatal (_("%P: invalid cache memory size: %s\n"), optarg);
   1778  1.11  christos 	    link_info.max_cache_size = cache_size;
   1779  1.11  christos 	  }
   1780  1.11  christos 	  break;
   1781  1.11  christos 
   1782   1.8  christos 	case OPTION_HASH_SIZE:
   1783   1.1     skrll 	  {
   1784   1.1     skrll 	    bfd_size_type new_size;
   1785   1.1     skrll 
   1786   1.8  christos 	    new_size = strtoul (optarg, NULL, 0);
   1787   1.8  christos 	    if (new_size)
   1788   1.8  christos 	      config.hash_table_size = new_size;
   1789   1.8  christos 	    else
   1790   1.9  christos 	      einfo (_("%X%P: --hash-size needs a numeric argument\n"));
   1791   1.8  christos 	  }
   1792   1.8  christos 	  break;
   1793   1.5  christos 
   1794   1.5  christos 	case OPTION_PUSH_STATE:
   1795   1.5  christos 	  input_flags.pushed = xmemdup (&input_flags,
   1796   1.5  christos 					sizeof (input_flags),
   1797   1.5  christos 					sizeof (input_flags));
   1798   1.5  christos 	  break;
   1799   1.5  christos 
   1800   1.5  christos 	case OPTION_POP_STATE:
   1801   1.5  christos 	  if (input_flags.pushed == NULL)
   1802  1.13  christos 	    fatal (_("%P: no state pushed before popping\n"));
   1803   1.5  christos 	  else
   1804   1.5  christos 	    {
   1805   1.5  christos 	      struct lang_input_statement_flags *oldp = input_flags.pushed;
   1806   1.5  christos 	      memcpy (&input_flags, oldp, sizeof (input_flags));
   1807   1.5  christos 	      free (oldp);
   1808   1.5  christos 	    }
   1809   1.5  christos 	  break;
   1810   1.5  christos 
   1811   1.5  christos 	case OPTION_PRINT_MEMORY_USAGE:
   1812  1.11  christos 	  command_line.print_memory_usage = true;
   1813   1.5  christos 	  break;
   1814   1.5  christos 
   1815   1.5  christos 	case OPTION_ORPHAN_HANDLING:
   1816   1.5  christos 	  if (strcasecmp (optarg, "place") == 0)
   1817   1.5  christos 	    config.orphan_handling = orphan_handling_place;
   1818   1.5  christos 	  else if (strcasecmp (optarg, "warn") == 0)
   1819   1.5  christos 	    config.orphan_handling = orphan_handling_warn;
   1820   1.5  christos 	  else if (strcasecmp (optarg, "error") == 0)
   1821   1.5  christos 	    config.orphan_handling = orphan_handling_error;
   1822   1.5  christos 	  else if (strcasecmp (optarg, "discard") == 0)
   1823   1.5  christos 	    config.orphan_handling = orphan_handling_discard;
   1824   1.5  christos 	  else
   1825  1.13  christos 	    fatal (_("%P: invalid argument to option"
   1826   1.5  christos 		     " \"--orphan-handling\"\n"));
   1827   1.5  christos 	  break;
   1828  1.10  christos 
   1829  1.10  christos 	case OPTION_NO_PRINT_MAP_DISCARDED:
   1830  1.11  christos 	  config.print_map_discarded = false;
   1831  1.10  christos 	  break;
   1832  1.10  christos 
   1833  1.10  christos 	case OPTION_PRINT_MAP_DISCARDED:
   1834  1.11  christos 	  config.print_map_discarded = true;
   1835  1.10  christos 	  break;
   1836  1.11  christos 
   1837  1.12  christos 	case OPTION_NO_PRINT_MAP_LOCALS:
   1838  1.12  christos 	  config.print_map_locals = false;
   1839  1.12  christos 	  break;
   1840  1.12  christos 
   1841  1.12  christos 	case OPTION_PRINT_MAP_LOCALS:
   1842  1.12  christos 	  config.print_map_locals = true;
   1843  1.12  christos 	  break;
   1844  1.12  christos 
   1845  1.11  christos 	case OPTION_DEPENDENCY_FILE:
   1846  1.11  christos 	  config.dependency_file = optarg;
   1847  1.11  christos 	  break;
   1848  1.11  christos 
   1849  1.11  christos 	case OPTION_CTF_VARIABLES:
   1850  1.11  christos 	  config.ctf_variables = true;
   1851  1.11  christos 	  break;
   1852  1.11  christos 
   1853  1.11  christos 	case OPTION_NO_CTF_VARIABLES:
   1854  1.11  christos 	  config.ctf_variables = false;
   1855  1.11  christos 	  break;
   1856  1.11  christos 
   1857  1.11  christos 	case OPTION_CTF_SHARE_TYPES:
   1858  1.11  christos 	  if (strcmp (optarg, "share-unconflicted") == 0)
   1859  1.11  christos 	    config.ctf_share_duplicated = false;
   1860  1.11  christos 	  else if (strcmp (optarg, "share-duplicated") == 0)
   1861  1.11  christos 	    config.ctf_share_duplicated = true;
   1862  1.11  christos 	  else
   1863  1.13  christos 	    fatal (_("%P: bad --ctf-share-types option: %s\n"), optarg);
   1864  1.11  christos 	  break;
   1865  1.11  christos 	}
   1866  1.11  christos     }
   1867  1.11  christos 
   1868  1.11  christos   free (really_longopts);
   1869  1.11  christos   free (longopts);
   1870  1.11  christos   free (shortopts);
   1871  1.11  christos 
   1872  1.11  christos   /* Run a couple of checks on the map filename.  */
   1873  1.11  christos   if (config.map_filename)
   1874  1.11  christos     {
   1875  1.11  christos       char * new_name = NULL;
   1876  1.11  christos       char * percent;
   1877  1.11  christos 
   1878  1.11  christos       if (config.map_filename[0] == 0)
   1879  1.11  christos 	{
   1880  1.11  christos 	  einfo (_("%P: no file/directory name provided for map output; ignored\n"));
   1881  1.11  christos 	  config.map_filename = NULL;
   1882  1.11  christos 	}
   1883  1.11  christos       else if (strcmp (config.map_filename, "-") == 0)
   1884  1.11  christos 	; /* Write to stdout.  Handled in main().  */
   1885  1.11  christos       else if ((percent = strchr (config.map_filename, '%')) != NULL)
   1886  1.11  christos 	{
   1887  1.11  christos 	  /* FIXME: Check for a second % character and issue an error ?  */
   1888  1.11  christos 
   1889  1.11  christos 	  /* Construct a map file by replacing the % character with the (full)
   1890  1.11  christos 	     output filename.  If the % character was the last character in
   1891  1.11  christos 	     the original map filename then add a .map extension.  */
   1892  1.11  christos 	  percent[0] = 0;
   1893  1.13  christos 	  new_name = xasprintf ("%s%s%s", config.map_filename,
   1894  1.13  christos 				output_filename,
   1895  1.13  christos 				percent[1] ? percent + 1 : ".map");
   1896  1.11  christos 
   1897  1.11  christos 	  /* FIXME: Should we ensure that any directory components in new_name exist ?  */
   1898  1.11  christos 	}
   1899  1.11  christos       else
   1900  1.11  christos 	{
   1901  1.11  christos 	  struct stat s;
   1902  1.11  christos 
   1903  1.11  christos 	  /* If the map filename is actually a directory then create
   1904  1.11  christos 	     a file inside it, based upon the output filename.  */
   1905  1.11  christos 	  if (stat (config.map_filename, &s) < 0)
   1906  1.11  christos 	    {
   1907  1.11  christos 	      if (errno != ENOENT)
   1908  1.11  christos 		einfo (_("%P: cannot stat linker map file: %E\n"));
   1909  1.11  christos 	    }
   1910  1.11  christos 	  else if (S_ISDIR (s.st_mode))
   1911  1.11  christos 	    {
   1912  1.11  christos 	      char lastc = config.map_filename[strlen (config.map_filename) - 1];
   1913  1.13  christos 	      new_name = xasprintf ("%s%s%s.map", config.map_filename,
   1914  1.13  christos 				    IS_DIR_SEPARATOR (lastc) ? "" : "/",
   1915  1.13  christos 				    lbasename (output_filename));
   1916  1.11  christos 	    }
   1917  1.11  christos 	  else if (! S_ISREG (s.st_mode))
   1918  1.11  christos 	    {
   1919  1.11  christos 	      einfo (_("%P: linker map file is not a regular file\n"));
   1920  1.11  christos 	      config.map_filename = NULL;
   1921  1.11  christos 	    }
   1922  1.11  christos 	  /* else FIXME: Check write permission ?  */
   1923  1.11  christos 	}
   1924  1.11  christos 
   1925  1.13  christos       if (new_name != NULL)
   1926  1.11  christos 	{
   1927  1.11  christos 	  /* This is a trivial memory leak.  */
   1928  1.11  christos 	  config.map_filename = new_name;
   1929   1.1     skrll 	}
   1930   1.1     skrll     }
   1931   1.1     skrll 
   1932   1.5  christos   if (command_line.soname && command_line.soname[0] == '\0')
   1933   1.5  christos     {
   1934   1.5  christos       einfo (_("%P: SONAME must not be empty string; ignored\n"));
   1935   1.5  christos       command_line.soname = NULL;
   1936   1.5  christos     }
   1937   1.5  christos 
   1938   1.3  christos   while (ingroup)
   1939   1.3  christos     {
   1940  1.10  christos       einfo (_("%P: missing --end-group; added as last command line option\n"));
   1941   1.3  christos       lang_leave_group ();
   1942   1.3  christos       ingroup--;
   1943   1.3  christos     }
   1944   1.1     skrll 
   1945   1.1     skrll   if (default_dirlist != NULL)
   1946   1.1     skrll     {
   1947   1.1     skrll       set_default_dirlist (default_dirlist);
   1948   1.1     skrll       free (default_dirlist);
   1949   1.1     skrll     }
   1950   1.1     skrll 
   1951   1.1     skrll   if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
   1952   1.1     skrll     /* FIXME: Should we allow emulations a chance to set this ?  */
   1953  1.11  christos     link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
   1954   1.1     skrll 
   1955   1.1     skrll   if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
   1956   1.1     skrll     /* FIXME: Should we allow emulations a chance to set this ?  */
   1957  1.11  christos     link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
   1958   1.3  christos 
   1959   1.5  christos   if (bfd_link_relocatable (&link_info)
   1960   1.5  christos       && command_line.check_section_addresses < 0)
   1961   1.5  christos     command_line.check_section_addresses = 0;
   1962   1.4  christos 
   1963  1.11  christos   if (export_list)
   1964  1.11  christos     {
   1965  1.11  christos       struct bfd_elf_version_expr *head = export_list->head.list;
   1966  1.11  christos       struct bfd_elf_version_expr *next;
   1967  1.11  christos 
   1968  1.11  christos       /* For --export-dynamic-symbol[-list]:
   1969  1.11  christos 	 1. When building executable, treat like --dynamic-list.
   1970  1.11  christos 	 2. When building shared object:
   1971  1.11  christos 	    a. If -Bsymbolic or --dynamic-list are used, treat like
   1972  1.11  christos 	       --dynamic-list.
   1973  1.11  christos 	    b. Otherwise, ignored.
   1974  1.11  christos        */
   1975  1.11  christos       if (!bfd_link_relocatable (&link_info)
   1976  1.11  christos 	  && (bfd_link_executable (&link_info)
   1977  1.11  christos 	      || opt_symbolic != symbolic_unset
   1978  1.11  christos 	      || opt_dynamic_list != dynamic_list_unset))
   1979  1.11  christos 	{
   1980  1.11  christos 	  /* Append the export list to link_info.dynamic_list.  */
   1981  1.11  christos 	  if (link_info.dynamic_list)
   1982  1.11  christos 	    {
   1983  1.11  christos 	      for (next = head; next->next != NULL; next = next->next)
   1984  1.11  christos 		;
   1985  1.11  christos 	      next->next = link_info.dynamic_list->head.list;
   1986  1.11  christos 	      link_info.dynamic_list->head.list = head;
   1987  1.11  christos 	    }
   1988  1.11  christos 	  else
   1989  1.11  christos 	    link_info.dynamic_list = export_list;
   1990  1.11  christos 
   1991  1.11  christos 	  if (opt_dynamic_list != dynamic_list_data)
   1992  1.11  christos 	    opt_dynamic_list = dynamic_list;
   1993  1.11  christos 	}
   1994  1.11  christos     }
   1995  1.11  christos 
   1996  1.11  christos   switch (opt_dynamic_list)
   1997  1.11  christos     {
   1998  1.11  christos     case dynamic_list_unset:
   1999  1.11  christos       break;
   2000  1.11  christos     case dynamic_list_data:
   2001  1.11  christos       link_info.dynamic_data = true;
   2002  1.11  christos       /* Fall through.  */
   2003  1.11  christos     case dynamic_list:
   2004  1.11  christos       link_info.dynamic = true;
   2005  1.11  christos       opt_symbolic = symbolic_unset;
   2006  1.11  christos       break;
   2007  1.11  christos     }
   2008  1.11  christos 
   2009  1.10  christos   /* -Bsymbolic and -Bsymbols-functions are for shared library output.  */
   2010  1.10  christos   if (bfd_link_dll (&link_info))
   2011  1.10  christos     switch (opt_symbolic)
   2012  1.10  christos       {
   2013  1.10  christos       case symbolic_unset:
   2014  1.10  christos 	break;
   2015  1.10  christos       case symbolic:
   2016  1.11  christos 	link_info.symbolic = true;
   2017  1.13  christos 	link_info.dynamic_list = NULL;
   2018  1.10  christos 	break;
   2019  1.10  christos       case symbolic_functions:
   2020  1.11  christos 	link_info.dynamic = true;
   2021  1.11  christos 	link_info.dynamic_data = true;
   2022  1.10  christos 	break;
   2023  1.10  christos       }
   2024   1.4  christos 
   2025  1.12  christos   /* -z nosectionheader implies --strip-all.  */
   2026  1.12  christos   if (config.no_section_header)
   2027  1.12  christos     {
   2028  1.12  christos       if (bfd_link_relocatable (&link_info))
   2029  1.13  christos 	fatal (_("%P: -r and -z nosectionheader may not be used together\n"));
   2030  1.12  christos 
   2031  1.12  christos       link_info.strip = strip_all;
   2032  1.12  christos     }
   2033  1.12  christos 
   2034   1.5  christos   if (!bfd_link_dll (&link_info))
   2035   1.4  christos     {
   2036   1.4  christos       if (command_line.filter_shlib)
   2037  1.13  christos 	fatal (_("%P: -F may not be used without -shared\n"));
   2038   1.4  christos       if (command_line.auxiliary_filters)
   2039  1.13  christos 	fatal (_("%P: -f may not be used without -shared\n"));
   2040   1.4  christos     }
   2041   1.4  christos 
   2042   1.4  christos   /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols).  I
   2043   1.4  christos      don't see how else this can be handled, since in this case we
   2044   1.4  christos      must preserve all externally visible symbols.  */
   2045   1.5  christos   if (bfd_link_relocatable (&link_info) && link_info.strip == strip_all)
   2046   1.4  christos     {
   2047   1.4  christos       link_info.strip = strip_debugger;
   2048   1.4  christos       if (link_info.discard == discard_sec_merge)
   2049   1.4  christos 	link_info.discard = discard_all;
   2050   1.4  christos     }
   2051   1.1     skrll }
   2052   1.1     skrll 
   2053   1.1     skrll /* Add the (colon-separated) elements of DIRLIST_PTR to the
   2054   1.1     skrll    library search path.  */
   2055   1.1     skrll 
   2056   1.1     skrll static void
   2057   1.1     skrll set_default_dirlist (char *dirlist_ptr)
   2058   1.1     skrll {
   2059   1.1     skrll   char *p;
   2060   1.1     skrll 
   2061   1.1     skrll   while (1)
   2062   1.1     skrll     {
   2063   1.1     skrll       p = strchr (dirlist_ptr, PATH_SEPARATOR);
   2064   1.1     skrll       if (p != NULL)
   2065   1.1     skrll 	*p = '\0';
   2066   1.1     skrll       if (*dirlist_ptr != '\0')
   2067  1.11  christos 	ldfile_add_library_path (dirlist_ptr, true);
   2068   1.1     skrll       if (p == NULL)
   2069   1.1     skrll 	break;
   2070   1.1     skrll       dirlist_ptr = p + 1;
   2071   1.1     skrll     }
   2072   1.1     skrll }
   2073   1.1     skrll 
   2074   1.1     skrll static void
   2075   1.1     skrll set_section_start (char *sect, char *valstr)
   2076   1.1     skrll {
   2077   1.1     skrll   const char *end;
   2078   1.1     skrll   bfd_vma val = bfd_scan_vma (valstr, &end, 16);
   2079   1.1     skrll   if (*end)
   2080  1.13  christos     fatal (_("%P: invalid hex number `%s'\n"), valstr);
   2081   1.1     skrll   lang_section_start (sect, exp_intop (val), NULL);
   2082   1.1     skrll }
   2083   1.1     skrll 
   2084   1.1     skrll static void
   2085   1.1     skrll set_segment_start (const char *section, char *valstr)
   2086   1.1     skrll {
   2087   1.1     skrll   const char *name;
   2088   1.1     skrll   const char *end;
   2089   1.1     skrll   segment_type *seg;
   2090   1.1     skrll 
   2091   1.1     skrll   bfd_vma val = bfd_scan_vma (valstr, &end, 16);
   2092   1.1     skrll   if (*end)
   2093  1.13  christos     fatal (_("%P: invalid hex number `%s'\n"), valstr);
   2094   1.1     skrll   /* If we already have an entry for this segment, update the existing
   2095   1.1     skrll      value.  */
   2096   1.1     skrll   name = section + 1;
   2097   1.1     skrll   for (seg = segments; seg; seg = seg->next)
   2098   1.1     skrll     if (strcmp (seg->name, name) == 0)
   2099   1.1     skrll       {
   2100   1.1     skrll 	seg->value = val;
   2101   1.7  christos 	lang_section_start (section, exp_intop (val), seg);
   2102   1.1     skrll 	return;
   2103   1.1     skrll       }
   2104   1.1     skrll   /* There was no existing value so we must create a new segment
   2105   1.1     skrll      entry.  */
   2106  1.10  christos   seg = stat_alloc (sizeof (*seg));
   2107   1.1     skrll   seg->name = name;
   2108   1.1     skrll   seg->value = val;
   2109  1.11  christos   seg->used = false;
   2110   1.1     skrll   /* Add it to the linked list of segments.  */
   2111   1.1     skrll   seg->next = segments;
   2112   1.1     skrll   segments = seg;
   2113   1.1     skrll   /* Historically, -Ttext and friends set the base address of a
   2114   1.1     skrll      particular section.  For backwards compatibility, we still do
   2115   1.1     skrll      that.  If a SEGMENT_START directive is seen, the section address
   2116   1.1     skrll      assignment will be disabled.  */
   2117   1.1     skrll   lang_section_start (section, exp_intop (val), seg);
   2118   1.1     skrll }
   2119   1.1     skrll 
   2120   1.5  christos static void
   2121   1.5  christos elf_shlib_list_options (FILE *file)
   2122   1.5  christos {
   2123   1.5  christos   fprintf (file, _("\
   2124   1.5  christos   --audit=AUDITLIB            Specify a library to use for auditing\n"));
   2125   1.5  christos   fprintf (file, _("\
   2126   1.5  christos   -Bgroup                     Selects group name lookup rules for DSO\n"));
   2127   1.5  christos   fprintf (file, _("\
   2128   1.5  christos   --disable-new-dtags         Disable new dynamic tags\n"));
   2129   1.5  christos   fprintf (file, _("\
   2130   1.5  christos   --enable-new-dtags          Enable new dynamic tags\n"));
   2131   1.5  christos   fprintf (file, _("\
   2132   1.5  christos   --eh-frame-hdr              Create .eh_frame_hdr section\n"));
   2133   1.5  christos   fprintf (file, _("\
   2134   1.8  christos   --no-eh-frame-hdr           Do not create .eh_frame_hdr section\n"));
   2135   1.8  christos   fprintf (file, _("\
   2136   1.5  christos   --exclude-libs=LIBS         Make all symbols in LIBS hidden\n"));
   2137   1.5  christos   fprintf (file, _("\
   2138  1.11  christos   --hash-style=STYLE          Set hash style to sysv/gnu/both.  Default: "));
   2139  1.11  christos   if (DEFAULT_EMIT_SYSV_HASH)
   2140  1.11  christos     {
   2141  1.11  christos       /* Note - these strings are not translated as
   2142  1.11  christos 	 they are keywords not descriptive text.  */
   2143  1.11  christos       if (DEFAULT_EMIT_GNU_HASH)
   2144  1.11  christos 	fprintf (file, "both\n");
   2145  1.11  christos       else
   2146  1.11  christos 	fprintf (file, "sysv\n");
   2147  1.11  christos     }
   2148  1.11  christos   else
   2149  1.11  christos     {
   2150  1.11  christos       if (DEFAULT_EMIT_GNU_HASH)
   2151  1.11  christos 	fprintf (file, "gnu\n");
   2152  1.11  christos       else
   2153  1.11  christos 	/* FIXME: Can this happen ?  */
   2154  1.11  christos 	fprintf (file, "none\n");
   2155  1.11  christos     }
   2156   1.5  christos   fprintf (file, _("\
   2157   1.5  christos   -P AUDITLIB, --depaudit=AUDITLIB\n" "\
   2158   1.9  christos                               Specify a library to use for auditing dependencies\n"));
   2159   1.5  christos   fprintf (file, _("\
   2160   1.5  christos   -z combreloc                Merge dynamic relocs into one section and sort\n"));
   2161   1.5  christos   fprintf (file, _("\
   2162   1.5  christos   -z nocombreloc              Don't merge dynamic relocs into one section\n"));
   2163   1.5  christos   fprintf (file, _("\
   2164   1.5  christos   -z global                   Make symbols in DSO available for subsequently\n\
   2165  1.11  christos                                 loaded objects\n"));
   2166   1.5  christos   fprintf (file, _("\
   2167   1.5  christos   -z initfirst                Mark DSO to be initialized first at runtime\n"));
   2168   1.5  christos   fprintf (file, _("\
   2169   1.5  christos   -z interpose                Mark object to interpose all DSOs but executable\n"));
   2170   1.5  christos   fprintf (file, _("\
   2171  1.11  christos   -z unique                   Mark DSO to be loaded at most once by default, and only in the main namespace\n"));
   2172  1.11  christos   fprintf (file, _("\
   2173  1.11  christos   -z nounique                 Don't mark DSO as a loadable at most once\n"));
   2174  1.11  christos   fprintf (file, _("\
   2175   1.5  christos   -z lazy                     Mark object lazy runtime binding (default)\n"));
   2176   1.5  christos   fprintf (file, _("\
   2177   1.5  christos   -z loadfltr                 Mark object requiring immediate process\n"));
   2178   1.5  christos   fprintf (file, _("\
   2179   1.5  christos   -z nocopyreloc              Don't create copy relocs\n"));
   2180   1.5  christos   fprintf (file, _("\
   2181   1.5  christos   -z nodefaultlib             Mark object not to use default search paths\n"));
   2182   1.5  christos   fprintf (file, _("\
   2183   1.5  christos   -z nodelete                 Mark DSO non-deletable at runtime\n"));
   2184   1.5  christos   fprintf (file, _("\
   2185   1.5  christos   -z nodlopen                 Mark DSO not available to dlopen\n"));
   2186   1.5  christos   fprintf (file, _("\
   2187   1.5  christos   -z nodump                   Mark DSO not available to dldump\n"));
   2188   1.5  christos   fprintf (file, _("\
   2189   1.5  christos   -z now                      Mark object non-lazy runtime binding\n"));
   2190   1.5  christos   fprintf (file, _("\
   2191   1.5  christos   -z origin                   Mark object requiring immediate $ORIGIN\n\
   2192   1.9  christos                                 processing at runtime\n"));
   2193   1.7  christos #if DEFAULT_LD_Z_RELRO
   2194   1.7  christos   fprintf (file, _("\
   2195   1.7  christos   -z relro                    Create RELRO program header (default)\n"));
   2196   1.7  christos   fprintf (file, _("\
   2197   1.7  christos   -z norelro                  Don't create RELRO program header\n"));
   2198   1.7  christos #else
   2199   1.5  christos   fprintf (file, _("\
   2200   1.5  christos   -z relro                    Create RELRO program header\n"));
   2201   1.5  christos   fprintf (file, _("\
   2202   1.7  christos   -z norelro                  Don't create RELRO program header (default)\n"));
   2203   1.7  christos #endif
   2204   1.9  christos #if DEFAULT_LD_Z_SEPARATE_CODE
   2205   1.9  christos   fprintf (file, _("\
   2206   1.9  christos   -z separate-code            Create separate code program header (default)\n"));
   2207   1.9  christos   fprintf (file, _("\
   2208   1.9  christos   -z noseparate-code          Don't create separate code program header\n"));
   2209   1.9  christos #else
   2210   1.7  christos   fprintf (file, _("\
   2211   1.8  christos   -z separate-code            Create separate code program header\n"));
   2212   1.8  christos   fprintf (file, _("\
   2213   1.8  christos   -z noseparate-code          Don't create separate code program header (default)\n"));
   2214   1.9  christos #endif
   2215  1.13  christos #if DEFAULT_LD_ROSEGMENT
   2216  1.13  christos   fprintf (file, _("\
   2217  1.13  christos   --rosegment                 With -z separate-code, create a single read-only segment (default)\n"));
   2218  1.13  christos   fprintf (file, _("\
   2219  1.13  christos   --no-rosegment              With -z separate-code, creste two read-only segments\n"));
   2220  1.13  christos #else
   2221  1.13  christos   fprintf (file, _("\
   2222  1.13  christos   --rosegment                 With -z separate-code, create a single read-only segment\n"));
   2223  1.13  christos   fprintf (file, _("\
   2224  1.13  christos   --no-rosegment              With -z separate-code, creste two read-only segments (default)\n"));
   2225  1.13  christos #endif
   2226   1.8  christos   fprintf (file, _("\
   2227   1.7  christos   -z common                   Generate common symbols with STT_COMMON type\n"));
   2228   1.7  christos   fprintf (file, _("\
   2229   1.7  christos   -z nocommon                 Generate common symbols with STT_OBJECT type\n"));
   2230  1.11  christos   if (link_info.textrel_check == textrel_check_error)
   2231  1.11  christos     fprintf (file, _("\
   2232  1.11  christos   -z text                     Treat DT_TEXTREL in output as error (default)\n"));
   2233  1.11  christos   else
   2234  1.11  christos     fprintf (file, _("\
   2235  1.11  christos   -z text                     Treat DT_TEXTREL in output as error\n"));
   2236  1.11  christos   if (link_info.textrel_check == textrel_check_none)
   2237  1.11  christos     {
   2238  1.11  christos       fprintf (file, _("\
   2239  1.11  christos   -z notext                   Don't treat DT_TEXTREL in output as error (default)\n"));
   2240  1.11  christos       fprintf (file, _("\
   2241  1.11  christos   -z textoff                  Don't treat DT_TEXTREL in output as error (default)\n"));
   2242  1.11  christos     }
   2243  1.11  christos   else
   2244  1.11  christos     {
   2245  1.11  christos       fprintf (file, _("\
   2246  1.11  christos   -z notext                   Don't treat DT_TEXTREL in output as error\n"));
   2247  1.11  christos       fprintf (file, _("\
   2248  1.11  christos   -z textoff                  Don't treat DT_TEXTREL in output as error\n"));
   2249  1.11  christos     }
   2250  1.13  christos #if DEFAULT_LD_Z_MEMORY_SEAL
   2251  1.13  christos   fprintf (file, _("\
   2252  1.13  christos   -z memory-seal              Mark object be memory sealed (default)\n"));
   2253  1.13  christos   fprintf (file, _("\
   2254  1.13  christos   -z nomemory-seal            Don't mark oject to be memory sealed\n"));
   2255  1.13  christos #else
   2256  1.13  christos   fprintf (file, _("\
   2257  1.13  christos   -z memory-seal              Mark object be memory sealed\n"));
   2258  1.13  christos   fprintf (file, _("\
   2259  1.13  christos   -z nomemory-seal            Don't mark oject to be memory sealed (default)\n"));
   2260  1.13  christos #endif
   2261   1.5  christos }
   2262   1.5  christos 
   2263   1.5  christos static void
   2264   1.5  christos elf_static_list_options (FILE *file)
   2265   1.5  christos {
   2266   1.5  christos   fprintf (file, _("\
   2267   1.5  christos   --build-id[=STYLE]          Generate build ID note\n"));
   2268  1.13  christos   /* DEFAULT_BUILD_ID_STYLE n/a here */
   2269  1.13  christos #ifdef WITH_XXHASH
   2270  1.13  christos   fprintf (file, _("\
   2271  1.13  christos                                 Styles: none,md5,sha1,xx,uuid,0xHEX\n"));
   2272  1.13  christos   /* NB: testsuite/ld-elf/build-id.exp depends on this syntax */
   2273  1.13  christos #else
   2274  1.13  christos   fprintf (file, _("\
   2275  1.13  christos                                 Styles: none,md5,sha1,uuid,0xHEX\n"));
   2276  1.13  christos #endif
   2277   1.5  christos   fprintf (file, _("\
   2278  1.11  christos   --package-metadata[=JSON]   Generate package metadata note\n"));
   2279  1.11  christos   fprintf (file, _("\
   2280  1.12  christos   --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi|zstd]\n\
   2281  1.12  christos 			      Compress DWARF debug sections\n"));
   2282   1.5  christos   fprintf (file, _("\
   2283  1.12  christos                                 Default: %s\n"),
   2284  1.12  christos 	   bfd_get_compression_algorithm_name (config.compress_debug));
   2285   1.5  christos   fprintf (file, _("\
   2286   1.5  christos   -z common-page-size=SIZE    Set common page size to SIZE\n"));
   2287   1.5  christos   fprintf (file, _("\
   2288   1.5  christos   -z max-page-size=SIZE       Set maximum page size to SIZE\n"));
   2289   1.5  christos   fprintf (file, _("\
   2290   1.9  christos   -z defs                     Report unresolved symbols in object files\n"));
   2291   1.5  christos   fprintf (file, _("\
   2292  1.11  christos   -z undefs                   Ignore unresolved symbols in object files\n"));
   2293  1.11  christos   fprintf (file, _("\
   2294   1.5  christos   -z muldefs                  Allow multiple definitions\n"));
   2295   1.5  christos   fprintf (file, _("\
   2296  1.11  christos   -z stack-size=SIZE          Set size of stack segment\n"));
   2297  1.12  christos 
   2298  1.11  christos   fprintf (file, _("\
   2299   1.5  christos   -z execstack                Mark executable as requiring executable stack\n"));
   2300   1.5  christos   fprintf (file, _("\
   2301  1.12  christos   -z noexecstack              Mark executable as not requiring executable stack\n"));
   2302  1.12  christos   fprintf (file, _("\
   2303  1.12  christos   --warn-execstack-objects    Generate a warning if an object file requests an executable stack\n"));
   2304  1.12  christos #if DEFAULT_LD_WARN_EXECSTACK == 0
   2305  1.11  christos   fprintf (file, _("\
   2306  1.12  christos   --warn-execstack            Generate a warning if creating an executable stack\n"));
   2307  1.11  christos #else
   2308  1.11  christos   fprintf (file, _("\
   2309  1.12  christos   --warn-execstack            Generate a warning if creating an executable stack (default)\n"));
   2310  1.11  christos #endif
   2311  1.11  christos #if DEFAULT_LD_WARN_EXECSTACK == 0
   2312  1.11  christos   fprintf (file, _("\
   2313  1.12  christos   --no-warn-execstack         Do not generate a warning if creating an executable stack (default)\n"));
   2314  1.11  christos #else
   2315  1.11  christos   fprintf (file, _("\
   2316  1.12  christos   --no-warn-execstack         Do not generate a warning if creating an executable stack\n"));
   2317  1.11  christos #endif
   2318  1.12  christos   fprintf (file, _("\
   2319  1.12  christos   --error-execstack           Turn warnings about executable stacks into errors\n"));
   2320  1.12  christos   fprintf (file, _("\
   2321  1.13  christos   --no-error-execstack        Do not turn warnings about executable stacks into errors\n"));
   2322  1.12  christos 
   2323  1.11  christos #if DEFAULT_LD_WARN_RWX_SEGMENTS
   2324  1.11  christos   fprintf (file, _("\
   2325  1.11  christos   --warn-rwx-segments         Generate a warning if a LOAD segment has RWX permissions (default)\n"));
   2326  1.11  christos   fprintf (file, _("\
   2327  1.11  christos   --no-warn-rwx-segments      Do not generate a warning if a LOAD segments has RWX permissions\n"));
   2328  1.11  christos #else
   2329  1.11  christos   fprintf (file, _("\
   2330  1.11  christos   --warn-rwx-segments         Generate a warning if a LOAD segment has RWX permissions\n"));
   2331  1.11  christos   fprintf (file, _("\
   2332  1.11  christos   --no-warn-rwx-segments      Do not generate a warning if a LOAD segments has RWX permissions (default)\n"));
   2333  1.11  christos #endif
   2334  1.11  christos   fprintf (file, _("\
   2335  1.12  christos   --error-rwx-segments        Turn warnings about loadable RWX segments into errors\n"));
   2336  1.12  christos   fprintf (file, _("\
   2337  1.12  christos   --no-error-rwx-segments     Do not turn warnings about loadable RWX segments into errors\n"));
   2338  1.12  christos 
   2339  1.12  christos   fprintf (file, _("\
   2340  1.11  christos   -z unique-symbol            Avoid duplicated local symbol names\n"));
   2341  1.11  christos   fprintf (file, _("\
   2342  1.11  christos   -z nounique-symbol          Keep duplicated local symbol names (default)\n"));
   2343   1.8  christos   fprintf (file, _("\
   2344   1.8  christos   -z globalaudit              Mark executable requiring global auditing\n"));
   2345  1.11  christos   fprintf (file, _("\
   2346  1.11  christos   -z start-stop-gc            Enable garbage collection on __start/__stop\n"));
   2347  1.11  christos   fprintf (file, _("\
   2348  1.11  christos   -z nostart-stop-gc          Don't garbage collect __start/__stop (default)\n"));
   2349  1.11  christos   fprintf (file, _("\
   2350  1.11  christos   -z start-stop-visibility=V  Set visibility of built-in __start/__stop symbols\n\
   2351  1.11  christos                                 to DEFAULT, PROTECTED, HIDDEN or INTERNAL\n"));
   2352  1.12  christos   fprintf (file, _("\
   2353  1.12  christos   -z sectionheader            Generate section header (default)\n"));
   2354  1.12  christos   fprintf (file, _("\
   2355  1.12  christos   -z nosectionheader          Do not generate section header\n"));
   2356   1.5  christos }
   2357   1.5  christos 
   2358   1.5  christos static void
   2359   1.5  christos elf_plt_unwind_list_options (FILE *file)
   2360   1.5  christos {
   2361   1.5  christos   fprintf (file, _("\
   2362   1.9  christos   --ld-generated-unwind-info  Generate exception handling info for PLT\n"));
   2363   1.9  christos   fprintf (file, _("\
   2364   1.5  christos   --no-ld-generated-unwind-info\n\
   2365   1.5  christos                               Don't generate exception handling info for PLT\n"));
   2366   1.5  christos }
   2367   1.5  christos 
   2368   1.5  christos static void
   2369  1.14  christos elf_sframe_list_options (FILE *file)
   2370  1.14  christos {
   2371  1.14  christos   fprintf (file, _("\
   2372  1.14  christos   --discard-sframe            Don't generate SFrame stack trace info in output\n"));
   2373  1.14  christos }
   2374  1.14  christos 
   2375  1.14  christos static void
   2376  1.14  christos ld_list_options (FILE *file, bool elf, bool shlib, bool plt_unwind,
   2377  1.14  christos 		 bool sframe_info)
   2378   1.5  christos {
   2379   1.5  christos   if (!elf)
   2380   1.5  christos     return;
   2381   1.5  christos   printf (_("ELF emulations:\n"));
   2382   1.5  christos   if (plt_unwind)
   2383   1.5  christos     elf_plt_unwind_list_options (file);
   2384  1.14  christos   if (sframe_info)
   2385  1.14  christos     elf_sframe_list_options (file);
   2386   1.5  christos   elf_static_list_options (file);
   2387   1.5  christos   if (shlib)
   2388   1.5  christos     elf_shlib_list_options (file);
   2389   1.5  christos }
   2390   1.5  christos 
   2391   1.1     skrll 
   2392   1.1     skrll /* Print help messages for the options.  */
   2394   1.1     skrll 
   2395   1.1     skrll static void
   2396   1.1     skrll help (void)
   2397   1.1     skrll {
   2398   1.1     skrll   unsigned i;
   2399   1.1     skrll   const char **targets, **pp;
   2400   1.1     skrll   int len;
   2401   1.1     skrll 
   2402   1.1     skrll   printf (_("Usage: %s [options] file...\n"), program_name);
   2403   1.1     skrll 
   2404   1.1     skrll   printf (_("Options:\n"));
   2405   1.1     skrll   for (i = 0; i < OPTION_COUNT; i++)
   2406   1.1     skrll     {
   2407   1.1     skrll       if (ld_options[i].doc != NULL)
   2408  1.11  christos 	{
   2409   1.1     skrll 	  bool comma;
   2410   1.1     skrll 	  unsigned j;
   2411   1.1     skrll 
   2412   1.1     skrll 	  printf ("  ");
   2413  1.11  christos 
   2414   1.1     skrll 	  comma = false;
   2415   1.1     skrll 	  len = 2;
   2416   1.1     skrll 
   2417   1.1     skrll 	  j = i;
   2418   1.1     skrll 	  do
   2419   1.1     skrll 	    {
   2420   1.1     skrll 	      if (ld_options[j].shortopt != '\0'
   2421   1.1     skrll 		  && ld_options[j].control != NO_HELP)
   2422   1.1     skrll 		{
   2423   1.1     skrll 		  printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
   2424   1.1     skrll 		  len += (comma ? 2 : 0) + 2;
   2425   1.1     skrll 		  if (ld_options[j].arg != NULL)
   2426   1.1     skrll 		    {
   2427   1.1     skrll 		      if (ld_options[j].opt.has_arg != optional_argument)
   2428   1.1     skrll 			{
   2429   1.1     skrll 			  printf (" ");
   2430   1.1     skrll 			  ++len;
   2431   1.1     skrll 			}
   2432   1.1     skrll 		      printf ("%s", _(ld_options[j].arg));
   2433   1.1     skrll 		      len += strlen (_(ld_options[j].arg));
   2434  1.11  christos 		    }
   2435   1.1     skrll 		  comma = true;
   2436   1.1     skrll 		}
   2437   1.1     skrll 	      ++j;
   2438   1.1     skrll 	    }
   2439   1.1     skrll 	  while (j < OPTION_COUNT && ld_options[j].doc == NULL);
   2440   1.1     skrll 
   2441   1.1     skrll 	  j = i;
   2442   1.1     skrll 	  do
   2443   1.1     skrll 	    {
   2444   1.1     skrll 	      if (ld_options[j].opt.name != NULL
   2445   1.1     skrll 		  && ld_options[j].control != NO_HELP)
   2446   1.1     skrll 		{
   2447   1.1     skrll 		  int two_dashes =
   2448   1.1     skrll 		    (ld_options[j].control == TWO_DASHES
   2449   1.1     skrll 		     || ld_options[j].control == EXACTLY_TWO_DASHES);
   2450   1.1     skrll 
   2451   1.1     skrll 		  printf ("%s-%s%s",
   2452   1.1     skrll 			  comma ? ", " : "",
   2453   1.1     skrll 			  two_dashes ? "-" : "",
   2454   1.1     skrll 			  ld_options[j].opt.name);
   2455   1.1     skrll 		  len += ((comma ? 2 : 0)
   2456   1.1     skrll 			  + 1
   2457   1.1     skrll 			  + (two_dashes ? 1 : 0)
   2458   1.1     skrll 			  + strlen (ld_options[j].opt.name));
   2459   1.1     skrll 		  if (ld_options[j].arg != NULL)
   2460   1.1     skrll 		    {
   2461   1.1     skrll 		      printf (" %s", _(ld_options[j].arg));
   2462   1.1     skrll 		      len += 1 + strlen (_(ld_options[j].arg));
   2463  1.11  christos 		    }
   2464   1.1     skrll 		  comma = true;
   2465   1.1     skrll 		}
   2466   1.1     skrll 	      ++j;
   2467   1.1     skrll 	    }
   2468   1.1     skrll 	  while (j < OPTION_COUNT && ld_options[j].doc == NULL);
   2469   1.1     skrll 
   2470   1.1     skrll 	  if (len >= 30)
   2471   1.1     skrll 	    {
   2472   1.1     skrll 	      printf ("\n");
   2473   1.1     skrll 	      len = 0;
   2474   1.1     skrll 	    }
   2475   1.1     skrll 
   2476   1.1     skrll 	  for (; len < 30; len++)
   2477   1.1     skrll 	    putchar (' ');
   2478  1.14  christos 
   2479  1.14  christos 	  printf ("%s", _(ld_options[i].doc));
   2480  1.14  christos 	  if ((ld_options[i].opt.val == OPTION_PLUGIN
   2481  1.14  christos 	       || ld_options[i].opt.val == OPTION_PLUGIN_OPT)
   2482  1.14  christos 	      && !bfd_plugin_enabled ())
   2483  1.14  christos 	    puts (_(" (ignored)"));
   2484  1.14  christos 	  else
   2485   1.1     skrll 	    putchar ('\n');
   2486   1.1     skrll 	}
   2487   1.1     skrll     }
   2488   1.1     skrll   printf (_("  @FILE"));
   2489   1.1     skrll   for (len = strlen ("  @FILE"); len < 30; len++)
   2490   1.1     skrll     putchar (' ');
   2491   1.1     skrll   printf (_("Read options from FILE\n"));
   2492   1.1     skrll 
   2493   1.1     skrll   /* Note: Various tools (such as libtool) depend upon the
   2494   1.1     skrll      format of the listings below - do not change them.  */
   2495   1.1     skrll   /* xgettext:c-format */
   2496   1.1     skrll   printf (_("%s: supported targets:"), program_name);
   2497   1.1     skrll   targets = bfd_target_list ();
   2498   1.1     skrll   for (pp = targets; *pp != NULL; pp++)
   2499   1.1     skrll     printf (" %s", *pp);
   2500   1.1     skrll   free (targets);
   2501   1.1     skrll   printf ("\n");
   2502   1.1     skrll 
   2503   1.1     skrll   /* xgettext:c-format */
   2504   1.1     skrll   printf (_("%s: supported emulations: "), program_name);
   2505   1.1     skrll   ldemul_list_emulations (stdout);
   2506   1.1     skrll   printf ("\n");
   2507   1.1     skrll 
   2508   1.1     skrll   /* xgettext:c-format */
   2509   1.5  christos   printf (_("%s: emulation specific options:\n"), program_name);
   2510  1.14  christos   ld_list_options (stdout, ELF_LIST_OPTIONS, ELF_SHLIB_LIST_OPTIONS,
   2511  1.14  christos 		   ELF_PLT_UNWIND_LIST_OPTIONS,
   2512   1.1     skrll 		   ELF_SFRAME_LIST_OPTIONS);
   2513   1.1     skrll   ldemul_list_emulation_options (stdout);
   2514   1.1     skrll   printf ("\n");
   2515   1.1     skrll 
   2516   1.1     skrll   if (REPORT_BUGS_TO[0])
   2517   1.1     skrll     printf (_("Report bugs to %s\n"), REPORT_BUGS_TO);
   2518                 }
   2519