| 1 | /* Parse options for the GNU linker. | 
|---|
| 2 | Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, | 
|---|
| 3 | 2001 | 
|---|
| 4 | Free Software Foundation, Inc. | 
|---|
| 5 |  | 
|---|
| 6 | This file is part of GLD, the Gnu Linker. | 
|---|
| 7 |  | 
|---|
| 8 | GLD is free software; you can redistribute it and/or modify | 
|---|
| 9 | it under the terms of the GNU General Public License as published by | 
|---|
| 10 | the Free Software Foundation; either version 2, or (at your option) | 
|---|
| 11 | any later version. | 
|---|
| 12 |  | 
|---|
| 13 | GLD is distributed in the hope that it will be useful, | 
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 16 | GNU General Public License for more details. | 
|---|
| 17 |  | 
|---|
| 18 | You should have received a copy of the GNU General Public License | 
|---|
| 19 | along with GLD; see the file COPYING.  If not, write to the Free | 
|---|
| 20 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | 
|---|
| 21 | 02111-1307, USA.  */ | 
|---|
| 22 |  | 
|---|
| 23 | #include "bfd.h" | 
|---|
| 24 | #include "sysdep.h" | 
|---|
| 25 | #include "libiberty.h" | 
|---|
| 26 | #include <stdio.h> | 
|---|
| 27 | #include <string.h> | 
|---|
| 28 | #include <ctype.h> | 
|---|
| 29 | #include "getopt.h" | 
|---|
| 30 | #include "bfdlink.h" | 
|---|
| 31 | #include "ld.h" | 
|---|
| 32 | #include "ldmain.h" | 
|---|
| 33 | #include "ldmisc.h" | 
|---|
| 34 | #include "ldexp.h" | 
|---|
| 35 | #include "ldlang.h" | 
|---|
| 36 | #include "ldgram.h" | 
|---|
| 37 | #include "ldlex.h" | 
|---|
| 38 | #include "ldfile.h" | 
|---|
| 39 | #include "ldver.h" | 
|---|
| 40 | #include "ldemul.h" | 
|---|
| 41 | #include "demangle.h" | 
|---|
| 42 |  | 
|---|
| 43 | #ifndef PATH_SEPARATOR | 
|---|
| 44 | #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__)) | 
|---|
| 45 | #define PATH_SEPARATOR ';' | 
|---|
| 46 | #else | 
|---|
| 47 | #define PATH_SEPARATOR ':' | 
|---|
| 48 | #endif | 
|---|
| 49 | #endif | 
|---|
| 50 |  | 
|---|
| 51 | /* Somewhere above, sys/stat.h got included . . . .  */ | 
|---|
| 52 | #if !defined(S_ISDIR) && defined(S_IFDIR) | 
|---|
| 53 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) | 
|---|
| 54 | #endif | 
|---|
| 55 |  | 
|---|
| 56 | /* Omit args to avoid the possibility of clashing with a system header | 
|---|
| 57 | that might disagree about consts.  */ | 
|---|
| 58 | unsigned long strtoul (); | 
|---|
| 59 |  | 
|---|
| 60 | static int is_num PARAMS ((const char *, int, int, int)); | 
|---|
| 61 | static void set_default_dirlist PARAMS ((char *dirlist_ptr)); | 
|---|
| 62 | static void set_section_start PARAMS ((char *sect, char *valstr)); | 
|---|
| 63 | static void help PARAMS ((void)); | 
|---|
| 64 |  | 
|---|
| 65 | /* Non-zero if we are processing a --defsym from the command line.  */ | 
|---|
| 66 | int parsing_defsym = 0; | 
|---|
| 67 |  | 
|---|
| 68 | /* Codes used for the long options with no short synonyms.  150 isn't | 
|---|
| 69 | special; it's just an arbitrary non-ASCII char value.  */ | 
|---|
| 70 |  | 
|---|
| 71 | #define OPTION_ASSERT                   150 | 
|---|
| 72 | #define OPTION_CALL_SHARED              (OPTION_ASSERT + 1) | 
|---|
| 73 | #define OPTION_CREF                     (OPTION_CALL_SHARED + 1) | 
|---|
| 74 | #define OPTION_DEFSYM                   (OPTION_CREF + 1) | 
|---|
| 75 | #define OPTION_DEMANGLE                 (OPTION_DEFSYM + 1) | 
|---|
| 76 | #define OPTION_DYNAMIC_LINKER           (OPTION_DEMANGLE + 1) | 
|---|
| 77 | #define OPTION_EB                       (OPTION_DYNAMIC_LINKER + 1) | 
|---|
| 78 | #define OPTION_EL                       (OPTION_EB + 1) | 
|---|
| 79 | #define OPTION_EMBEDDED_RELOCS          (OPTION_EL + 1) | 
|---|
| 80 | #define OPTION_EXPORT_DYNAMIC           (OPTION_EMBEDDED_RELOCS + 1) | 
|---|
| 81 | #define OPTION_HELP                     (OPTION_EXPORT_DYNAMIC + 1) | 
|---|
| 82 | #define OPTION_IGNORE                   (OPTION_HELP + 1) | 
|---|
| 83 | #define OPTION_MAP                      (OPTION_IGNORE + 1) | 
|---|
| 84 | #define OPTION_NO_DEMANGLE              (OPTION_MAP + 1) | 
|---|
| 85 | #define OPTION_NO_KEEP_MEMORY           (OPTION_NO_DEMANGLE + 1) | 
|---|
| 86 | #define OPTION_NO_WARN_MISMATCH         (OPTION_NO_KEEP_MEMORY + 1) | 
|---|
| 87 | #define OPTION_NOINHIBIT_EXEC           (OPTION_NO_WARN_MISMATCH + 1) | 
|---|
| 88 | #define OPTION_NON_SHARED               (OPTION_NOINHIBIT_EXEC + 1) | 
|---|
| 89 | #define OPTION_NO_WHOLE_ARCHIVE         (OPTION_NON_SHARED + 1) | 
|---|
| 90 | #define OPTION_OFORMAT                  (OPTION_NO_WHOLE_ARCHIVE + 1) | 
|---|
| 91 | #define OPTION_RELAX                    (OPTION_OFORMAT + 1) | 
|---|
| 92 | #define OPTION_RETAIN_SYMBOLS_FILE      (OPTION_RELAX + 1) | 
|---|
| 93 | #define OPTION_RPATH                    (OPTION_RETAIN_SYMBOLS_FILE + 1) | 
|---|
| 94 | #define OPTION_RPATH_LINK               (OPTION_RPATH + 1) | 
|---|
| 95 | #define OPTION_SHARED                   (OPTION_RPATH_LINK + 1) | 
|---|
| 96 | #define OPTION_SONAME                   (OPTION_SHARED + 1) | 
|---|
| 97 | #define OPTION_SORT_COMMON              (OPTION_SONAME + 1) | 
|---|
| 98 | #define OPTION_STATS                    (OPTION_SORT_COMMON + 1) | 
|---|
| 99 | #define OPTION_SYMBOLIC                 (OPTION_STATS + 1) | 
|---|
| 100 | #define OPTION_TASK_LINK                (OPTION_SYMBOLIC + 1) | 
|---|
| 101 | #define OPTION_TBSS                     (OPTION_TASK_LINK + 1) | 
|---|
| 102 | #define OPTION_TDATA                    (OPTION_TBSS + 1) | 
|---|
| 103 | #define OPTION_TTEXT                    (OPTION_TDATA + 1) | 
|---|
| 104 | #define OPTION_TRADITIONAL_FORMAT       (OPTION_TTEXT + 1) | 
|---|
| 105 | #define OPTION_UR                       (OPTION_TRADITIONAL_FORMAT + 1) | 
|---|
| 106 | #define OPTION_VERBOSE                  (OPTION_UR + 1) | 
|---|
| 107 | #define OPTION_VERSION                  (OPTION_VERBOSE + 1) | 
|---|
| 108 | #define OPTION_VERSION_SCRIPT           (OPTION_VERSION + 1) | 
|---|
| 109 | #define OPTION_VERSION_EXPORTS_SECTION  (OPTION_VERSION_SCRIPT + 1) | 
|---|
| 110 | #define OPTION_WARN_COMMON              (OPTION_VERSION_EXPORTS_SECTION + 1) | 
|---|
| 111 | #define OPTION_WARN_CONSTRUCTORS        (OPTION_WARN_COMMON + 1) | 
|---|
| 112 | #define OPTION_WARN_MULTIPLE_GP         (OPTION_WARN_CONSTRUCTORS + 1) | 
|---|
| 113 | #define OPTION_WARN_ONCE                (OPTION_WARN_MULTIPLE_GP + 1) | 
|---|
| 114 | #define OPTION_WARN_SECTION_ALIGN       (OPTION_WARN_ONCE + 1) | 
|---|
| 115 | #define OPTION_SPLIT_BY_RELOC           (OPTION_WARN_SECTION_ALIGN + 1) | 
|---|
| 116 | #define OPTION_SPLIT_BY_FILE            (OPTION_SPLIT_BY_RELOC + 1) | 
|---|
| 117 | #define OPTION_WHOLE_ARCHIVE            (OPTION_SPLIT_BY_FILE + 1) | 
|---|
| 118 | #define OPTION_WRAP                     (OPTION_WHOLE_ARCHIVE + 1) | 
|---|
| 119 | #define OPTION_FORCE_EXE_SUFFIX         (OPTION_WRAP + 1) | 
|---|
| 120 | #define OPTION_GC_SECTIONS              (OPTION_FORCE_EXE_SUFFIX + 1) | 
|---|
| 121 | #define OPTION_NO_GC_SECTIONS           (OPTION_GC_SECTIONS + 1) | 
|---|
| 122 | #define OPTION_CHECK_SECTIONS           (OPTION_NO_GC_SECTIONS + 1) | 
|---|
| 123 | #define OPTION_NO_CHECK_SECTIONS        (OPTION_CHECK_SECTIONS + 1) | 
|---|
| 124 | #define OPTION_MPC860C0                 (OPTION_NO_CHECK_SECTIONS + 1) | 
|---|
| 125 | #define OPTION_NO_UNDEFINED             (OPTION_MPC860C0 + 1) | 
|---|
| 126 | #define OPTION_INIT                     (OPTION_NO_UNDEFINED + 1) | 
|---|
| 127 | #define OPTION_FINI                     (OPTION_INIT + 1) | 
|---|
| 128 | #define OPTION_SECTION_START            (OPTION_FINI + 1) | 
|---|
| 129 | #define OPTION_UNIQUE                   (OPTION_SECTION_START + 1) | 
|---|
| 130 | #define OPTION_TARGET_HELP              (OPTION_UNIQUE + 1) | 
|---|
| 131 | #define OPTION_ALLOW_SHLIB_UNDEFINED    (OPTION_TARGET_HELP + 1) | 
|---|
| 132 |  | 
|---|
| 133 | /* The long options.  This structure is used for both the option | 
|---|
| 134 | parsing and the help text.  */ | 
|---|
| 135 |  | 
|---|
| 136 | struct ld_option | 
|---|
| 137 | { | 
|---|
| 138 | /* The long option information.  */ | 
|---|
| 139 | struct option opt; | 
|---|
| 140 | /* The short option with the same meaning ('\0' if none).  */ | 
|---|
| 141 | char shortopt; | 
|---|
| 142 | /* The name of the argument (NULL if none).  */ | 
|---|
| 143 | const char *arg; | 
|---|
| 144 | /* The documentation string.  If this is NULL, this is a synonym for | 
|---|
| 145 | the previous option.  */ | 
|---|
| 146 | const char *doc; | 
|---|
| 147 | enum { | 
|---|
| 148 | /* Use one dash before long option name.  */ | 
|---|
| 149 | ONE_DASH, | 
|---|
| 150 | /* Use two dashes before long option name.  */ | 
|---|
| 151 | TWO_DASHES, | 
|---|
| 152 | /* Only accept two dashes before the long option name. | 
|---|
| 153 | This is an overloading of the use of this enum, since originally it | 
|---|
| 154 | was only intended to tell the --help display function how to display | 
|---|
| 155 | the long option name.  This feature was added in order to resolve | 
|---|
| 156 | the confusion about the -omagic command line switch.  Is it setting | 
|---|
| 157 | the output file name to "magic" or is it setting the NMAGIC flag on | 
|---|
| 158 | the output ?  It has been decided that it is setting the output file | 
|---|
| 159 | name, and that if you want to set the NMAGIC flag you should use -N | 
|---|
| 160 | or --omagic.  */ | 
|---|
| 161 | EXACTLY_TWO_DASHES, | 
|---|
| 162 | /* Don't mention this option in --help output.  */ | 
|---|
| 163 | NO_HELP | 
|---|
| 164 | } control; | 
|---|
| 165 | }; | 
|---|
| 166 |  | 
|---|
| 167 | static const struct ld_option ld_options[] = | 
|---|
| 168 | { | 
|---|
| 169 | { {NULL, required_argument, NULL, '\0'}, | 
|---|
| 170 | 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"), | 
|---|
| 171 | ONE_DASH }, | 
|---|
| 172 | { {"architecture", required_argument, NULL, 'A'}, | 
|---|
| 173 | 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES }, | 
|---|
| 174 | { {"format", required_argument, NULL, 'b'}, | 
|---|
| 175 | 'b', N_("TARGET"), N_("Specify target for following input files"), TWO_DASHES }, | 
|---|
| 176 | { {"mri-script", required_argument, NULL, 'c'}, | 
|---|
| 177 | 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES }, | 
|---|
| 178 | { {"dc", no_argument, NULL, 'd'}, | 
|---|
| 179 | 'd', NULL, N_("Force common symbols to be defined"), ONE_DASH }, | 
|---|
| 180 | { {"dp", no_argument, NULL, 'd'}, | 
|---|
| 181 | '\0', NULL, NULL, ONE_DASH }, | 
|---|
| 182 | { {"entry", required_argument, NULL, 'e'}, | 
|---|
| 183 | 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES }, | 
|---|
| 184 | { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC}, | 
|---|
| 185 | 'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES }, | 
|---|
| 186 | { {"EB", no_argument, NULL, OPTION_EB}, | 
|---|
| 187 | '\0', NULL, N_("Link big-endian objects"), ONE_DASH }, | 
|---|
| 188 | { {"EL", no_argument, NULL, OPTION_EL}, | 
|---|
| 189 | '\0', NULL, N_("Link little-endian objects"), ONE_DASH }, | 
|---|
| 190 | { {"auxiliary", required_argument, NULL, 'f'}, | 
|---|
| 191 | 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"), | 
|---|
| 192 | TWO_DASHES }, | 
|---|
| 193 | { {"filter", required_argument, NULL, 'F'}, | 
|---|
| 194 | 'F', N_("SHLIB"), N_("Filter for shared object symbol table"), TWO_DASHES }, | 
|---|
| 195 | { {NULL, no_argument, NULL, '\0'}, | 
|---|
| 196 | 'g', NULL, N_("Ignored"), ONE_DASH }, | 
|---|
| 197 | { {"gpsize", required_argument, NULL, 'G'}, | 
|---|
| 198 | 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"), | 
|---|
| 199 | TWO_DASHES }, | 
|---|
| 200 | { {"soname", required_argument, NULL, OPTION_SONAME}, | 
|---|
| 201 | 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH }, | 
|---|
| 202 | { {"library", required_argument, NULL, 'l'}, | 
|---|
| 203 | 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES }, | 
|---|
| 204 | { {"library-path", required_argument, NULL, 'L'}, | 
|---|
| 205 | 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"), TWO_DASHES }, | 
|---|
| 206 | { {NULL, required_argument, NULL, '\0'}, | 
|---|
| 207 | 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH }, | 
|---|
| 208 | { {"print-map", no_argument, NULL, 'M'}, | 
|---|
| 209 | 'M', NULL, N_("Print map file on standard output"), TWO_DASHES }, | 
|---|
| 210 | { {"nmagic", no_argument, NULL, 'n'}, | 
|---|
| 211 | 'n', NULL, N_("Do not page align data"), TWO_DASHES }, | 
|---|
| 212 | { {"omagic", no_argument, NULL, 'N'}, | 
|---|
| 213 | 'N', NULL, N_("Do not page align data, do not make text readonly"), | 
|---|
| 214 | EXACTLY_TWO_DASHES }, | 
|---|
| 215 | { {"output", required_argument, NULL, 'o'}, | 
|---|
| 216 | 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES }, | 
|---|
| 217 | { {NULL, required_argument, NULL, '\0'}, | 
|---|
| 218 | 'O', NULL, N_("Optimize output file"), ONE_DASH }, | 
|---|
| 219 | { {"Qy", no_argument, NULL, OPTION_IGNORE}, | 
|---|
| 220 | '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH }, | 
|---|
| 221 | { {"emit-relocs", no_argument, NULL, 'q'}, | 
|---|
| 222 | 'q', NULL, "Generate relocations in final output", TWO_DASHES }, | 
|---|
| 223 | { {"relocateable", no_argument, NULL, 'r'}, | 
|---|
| 224 | 'r', NULL, N_("Generate relocateable output"), TWO_DASHES }, | 
|---|
| 225 | { {NULL, no_argument, NULL, '\0'}, | 
|---|
| 226 | 'i', NULL, NULL, ONE_DASH }, | 
|---|
| 227 | { {"just-symbols", required_argument, NULL, 'R'}, | 
|---|
| 228 | 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"), | 
|---|
| 229 | TWO_DASHES }, | 
|---|
| 230 | { {"strip-all", no_argument, NULL, 's'}, | 
|---|
| 231 | 's', NULL, N_("Strip all symbols"), TWO_DASHES }, | 
|---|
| 232 | { {"strip-debug", no_argument, NULL, 'S'}, | 
|---|
| 233 | 'S', NULL, N_("Strip debugging symbols"), TWO_DASHES }, | 
|---|
| 234 | { {"trace", no_argument, NULL, 't'}, | 
|---|
| 235 | 't', NULL, N_("Trace file opens"), TWO_DASHES }, | 
|---|
| 236 | { {"script", required_argument, NULL, 'T'}, | 
|---|
| 237 | 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES }, | 
|---|
| 238 | { {"undefined", required_argument, NULL, 'u'}, | 
|---|
| 239 | 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), TWO_DASHES }, | 
|---|
| 240 | { {"unique", optional_argument, NULL, OPTION_UNIQUE}, | 
|---|
| 241 | '\0', N_("[=SECTION]"), N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES }, | 
|---|
| 242 | { {"Ur", no_argument, NULL, OPTION_UR}, | 
|---|
| 243 | '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH }, | 
|---|
| 244 | { {"version", no_argument, NULL, OPTION_VERSION}, | 
|---|
| 245 | 'v', NULL, N_("Print version information"), TWO_DASHES }, | 
|---|
| 246 | { {NULL, no_argument, NULL, '\0'}, | 
|---|
| 247 | 'V', NULL, N_("Print version and emulation information"), ONE_DASH }, | 
|---|
| 248 | { {"discard-all", no_argument, NULL, 'x'}, | 
|---|
| 249 | 'x', NULL, N_("Discard all local symbols"), TWO_DASHES }, | 
|---|
| 250 | { {"discard-locals", no_argument, NULL, 'X'}, | 
|---|
| 251 | 'X', NULL, N_("Discard temporary local symbols"), TWO_DASHES }, | 
|---|
| 252 | { {"trace-symbol", required_argument, NULL, 'y'}, | 
|---|
| 253 | 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES }, | 
|---|
| 254 | { {NULL, required_argument, NULL, '\0'}, | 
|---|
| 255 | 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), ONE_DASH }, | 
|---|
| 256 | { {"start-group", no_argument, NULL, '('}, | 
|---|
| 257 | '(', NULL, N_("Start a group"), TWO_DASHES }, | 
|---|
| 258 | { {"end-group", no_argument, NULL, ')'}, | 
|---|
| 259 | ')', NULL, N_("End a group"), TWO_DASHES }, | 
|---|
| 260 | { {"assert", required_argument, NULL, OPTION_ASSERT}, | 
|---|
| 261 | '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH }, | 
|---|
| 262 | { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED}, | 
|---|
| 263 | '\0', NULL, N_("Link against shared libraries"), ONE_DASH }, | 
|---|
| 264 | { {"dy", no_argument, NULL, OPTION_CALL_SHARED}, | 
|---|
| 265 | '\0', NULL, NULL, ONE_DASH }, | 
|---|
| 266 | { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED}, | 
|---|
| 267 | '\0', NULL, NULL, ONE_DASH }, | 
|---|
| 268 | { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED}, | 
|---|
| 269 | '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH }, | 
|---|
| 270 | { {"dn", no_argument, NULL, OPTION_NON_SHARED}, | 
|---|
| 271 | '\0', NULL, NULL, ONE_DASH }, | 
|---|
| 272 | { {"non_shared", no_argument, NULL, OPTION_NON_SHARED}, | 
|---|
| 273 | '\0', NULL, NULL, ONE_DASH }, | 
|---|
| 274 | { {"static", no_argument, NULL, OPTION_NON_SHARED}, | 
|---|
| 275 | '\0', NULL, NULL, ONE_DASH }, | 
|---|
| 276 | { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC}, | 
|---|
| 277 | '\0', NULL, N_("Bind global references locally"), ONE_DASH }, | 
|---|
| 278 | { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS}, | 
|---|
| 279 | '\0', NULL, N_("Check section addresses for overlaps (default)"), TWO_DASHES }, | 
|---|
| 280 | { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS}, | 
|---|
| 281 | '\0', NULL, N_("Do not check section addresses for overlaps"), | 
|---|
| 282 | TWO_DASHES }, | 
|---|
| 283 | { {"cref", no_argument, NULL, OPTION_CREF}, | 
|---|
| 284 | '\0', NULL, N_("Output cross reference table"), TWO_DASHES }, | 
|---|
| 285 | { {"defsym", required_argument, NULL, OPTION_DEFSYM}, | 
|---|
| 286 | '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES }, | 
|---|
| 287 | { {"demangle", optional_argument, NULL, OPTION_DEMANGLE}, | 
|---|
| 288 | '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), TWO_DASHES }, | 
|---|
| 289 | { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER}, | 
|---|
| 290 | '\0', N_("PROGRAM"), N_("Set the dynamic linker to use"), TWO_DASHES }, | 
|---|
| 291 | { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS}, | 
|---|
| 292 | '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES}, | 
|---|
| 293 | { {"fini", required_argument, NULL, OPTION_FINI}, | 
|---|
| 294 | '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH }, | 
|---|
| 295 | { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX}, | 
|---|
| 296 | '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES}, | 
|---|
| 297 | { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS}, | 
|---|
| 298 | '\0', NULL, N_("Remove unused sections (on some targets)"), | 
|---|
| 299 | TWO_DASHES }, | 
|---|
| 300 | { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS}, | 
|---|
| 301 | '\0', NULL, N_("Don't remove unused sections (default)"), | 
|---|
| 302 | TWO_DASHES }, | 
|---|
| 303 | { {"help", no_argument, NULL, OPTION_HELP}, | 
|---|
| 304 | '\0', NULL, N_("Print option help"), TWO_DASHES }, | 
|---|
| 305 | { {"init", required_argument, NULL, OPTION_INIT}, | 
|---|
| 306 | '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH }, | 
|---|
| 307 | { {"Map", required_argument, NULL, OPTION_MAP}, | 
|---|
| 308 | '\0', N_("FILE"), N_("Write a map file"), ONE_DASH }, | 
|---|
| 309 | { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE }, | 
|---|
| 310 | '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES }, | 
|---|
| 311 | { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY}, | 
|---|
| 312 | '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES }, | 
|---|
| 313 | { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED}, | 
|---|
| 314 | '\0', NULL, N_("Allow no undefined symbols"), TWO_DASHES }, | 
|---|
| 315 | { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED}, | 
|---|
| 316 | '\0', NULL, N_("Allow undefined symbols in shared objects"), TWO_DASHES }, | 
|---|
| 317 | { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH}, | 
|---|
| 318 | '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES}, | 
|---|
| 319 | { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE}, | 
|---|
| 320 | '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES }, | 
|---|
| 321 | { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC}, | 
|---|
| 322 | '\0', NULL, N_("Create an output file even if errors occur"), TWO_DASHES }, | 
|---|
| 323 | { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC}, | 
|---|
| 324 | '\0', NULL, NULL, NO_HELP }, | 
|---|
| 325 | { {"oformat", required_argument, NULL, OPTION_OFORMAT}, | 
|---|
| 326 | '\0', N_("TARGET"), N_("Specify target of output file"), EXACTLY_TWO_DASHES }, | 
|---|
| 327 | { {"qmagic", no_argument, NULL, OPTION_IGNORE}, | 
|---|
| 328 | '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH }, | 
|---|
| 329 | { {"relax", no_argument, NULL, OPTION_RELAX}, | 
|---|
| 330 | '\0', NULL, N_("Relax branches on certain targets"), TWO_DASHES }, | 
|---|
| 331 | { {"retain-symbols-file", required_argument, NULL, | 
|---|
| 332 | OPTION_RETAIN_SYMBOLS_FILE}, | 
|---|
| 333 | '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES }, | 
|---|
| 334 | { {"rpath", required_argument, NULL, OPTION_RPATH}, | 
|---|
| 335 | '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH }, | 
|---|
| 336 | { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK}, | 
|---|
| 337 | '\0', N_("PATH"), N_("Set link time shared library search path"), ONE_DASH }, | 
|---|
| 338 | { {"shared", no_argument, NULL, OPTION_SHARED}, | 
|---|
| 339 | '\0', NULL, N_("Create a shared library"), ONE_DASH }, | 
|---|
| 340 | { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD.  */ | 
|---|
| 341 | '\0', NULL, NULL, ONE_DASH }, | 
|---|
| 342 | { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON}, | 
|---|
| 343 | '\0', NULL, N_("Sort common symbols by size"), TWO_DASHES }, | 
|---|
| 344 | { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON}, | 
|---|
| 345 | '\0', NULL, NULL, NO_HELP }, | 
|---|
| 346 | { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE}, | 
|---|
| 347 | '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"), TWO_DASHES }, | 
|---|
| 348 | { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC}, | 
|---|
| 349 | '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"), TWO_DASHES }, | 
|---|
| 350 | { {"stats", no_argument, NULL, OPTION_STATS}, | 
|---|
| 351 | '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES }, | 
|---|
| 352 | { {"target-help", no_argument, NULL, OPTION_TARGET_HELP}, | 
|---|
| 353 | '\0', NULL, N_("Display target specific options"), TWO_DASHES }, | 
|---|
| 354 | { {"task-link", required_argument, NULL, OPTION_TASK_LINK}, | 
|---|
| 355 | '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES }, | 
|---|
| 356 | { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT}, | 
|---|
| 357 | '\0', NULL, N_("Use same format as native linker"), TWO_DASHES }, | 
|---|
| 358 | { {"section-start", required_argument, NULL, OPTION_SECTION_START}, | 
|---|
| 359 | '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"), TWO_DASHES }, | 
|---|
| 360 | { {"Tbss", required_argument, NULL, OPTION_TBSS}, | 
|---|
| 361 | '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH }, | 
|---|
| 362 | { {"Tdata", required_argument, NULL, OPTION_TDATA}, | 
|---|
| 363 | '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH }, | 
|---|
| 364 | { {"Ttext", required_argument, NULL, OPTION_TTEXT}, | 
|---|
| 365 | '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH }, | 
|---|
| 366 | { {"verbose", no_argument, NULL, OPTION_VERBOSE}, | 
|---|
| 367 | '\0', NULL, N_("Output lots of information during link"), TWO_DASHES }, | 
|---|
| 368 | { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux.  */ | 
|---|
| 369 | '\0', NULL, NULL, NO_HELP }, | 
|---|
| 370 | { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT }, | 
|---|
| 371 | '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES }, | 
|---|
| 372 | { {"version-exports-section", required_argument, NULL, | 
|---|
| 373 | OPTION_VERSION_EXPORTS_SECTION }, | 
|---|
| 374 | '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n\t\t\t\tSYMBOL as the version."), | 
|---|
| 375 | TWO_DASHES }, | 
|---|
| 376 | { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON}, | 
|---|
| 377 | '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES }, | 
|---|
| 378 | { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS}, | 
|---|
| 379 | '\0', NULL, N_("Warn if global constructors/destructors are seen"), | 
|---|
| 380 | TWO_DASHES }, | 
|---|
| 381 | { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP}, | 
|---|
| 382 | '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES }, | 
|---|
| 383 | { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE}, | 
|---|
| 384 | '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES }, | 
|---|
| 385 | { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN}, | 
|---|
| 386 | '\0', NULL, N_("Warn if start of section changes due to alignment"), | 
|---|
| 387 | TWO_DASHES }, | 
|---|
| 388 | { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE}, | 
|---|
| 389 | '\0', NULL, N_("Include all objects from following archives"), TWO_DASHES }, | 
|---|
| 390 | { {"wrap", required_argument, NULL, OPTION_WRAP}, | 
|---|
| 391 | '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES }, | 
|---|
| 392 | { {"mpc860c0", optional_argument, NULL, OPTION_MPC860C0}, | 
|---|
| 393 | '\0', N_("[=WORDS]"), N_("Modify problematic branches in last WORDS (1-10,\n\t\t\t\tdefault 5) words of a page"), TWO_DASHES } | 
|---|
| 394 | }; | 
|---|
| 395 |  | 
|---|
| 396 | #define OPTION_COUNT ARRAY_SIZE (ld_options) | 
|---|
| 397 |  | 
|---|
| 398 | /* Test STRING for containing a string of digits that form a number | 
|---|
| 399 | between MIN and MAX.  The return value is the number or ERR.  */ | 
|---|
| 400 |  | 
|---|
| 401 | static int | 
|---|
| 402 | is_num (string, min, max, err) | 
|---|
| 403 | const char *string; | 
|---|
| 404 | int min; | 
|---|
| 405 | int max; | 
|---|
| 406 | int err; | 
|---|
| 407 | { | 
|---|
| 408 | int result = 0; | 
|---|
| 409 |  | 
|---|
| 410 | for (; *string; ++string) | 
|---|
| 411 | { | 
|---|
| 412 | if (! isdigit (*string)) | 
|---|
| 413 | { | 
|---|
| 414 | result = err; | 
|---|
| 415 | break; | 
|---|
| 416 | } | 
|---|
| 417 | result = result * 10 + (*string - '0'); | 
|---|
| 418 | } | 
|---|
| 419 | if (result < min || result > max) | 
|---|
| 420 | result = err; | 
|---|
| 421 |  | 
|---|
| 422 | return result; | 
|---|
| 423 | } | 
|---|
| 424 |  | 
|---|
| 425 | void | 
|---|
| 426 | parse_args (argc, argv) | 
|---|
| 427 | unsigned argc; | 
|---|
| 428 | char **argv; | 
|---|
| 429 | { | 
|---|
| 430 | unsigned i; | 
|---|
| 431 | int is, il, irl; | 
|---|
| 432 | int ingroup = 0; | 
|---|
| 433 | char *default_dirlist = NULL; | 
|---|
| 434 | char shortopts[OPTION_COUNT * 3 + 2]; | 
|---|
| 435 | struct option longopts[OPTION_COUNT + 1]; | 
|---|
| 436 | struct option really_longopts[OPTION_COUNT + 1]; | 
|---|
| 437 | int last_optind; | 
|---|
| 438 |  | 
|---|
| 439 | /* Starting the short option string with '-' is for programs that | 
|---|
| 440 | expect options and other ARGV-elements in any order and that care about | 
|---|
| 441 | the ordering of the two.  We describe each non-option ARGV-element | 
|---|
| 442 | as if it were the argument of an option with character code 1.  */ | 
|---|
| 443 | shortopts[0] = '-'; | 
|---|
| 444 | is = 1; | 
|---|
| 445 | il = 0; | 
|---|
| 446 | irl = 0; | 
|---|
| 447 | for (i = 0; i < OPTION_COUNT; i++) | 
|---|
| 448 | { | 
|---|
| 449 | if (ld_options[i].shortopt != '\0') | 
|---|
| 450 | { | 
|---|
| 451 | shortopts[is] = ld_options[i].shortopt; | 
|---|
| 452 | ++is; | 
|---|
| 453 | if (ld_options[i].opt.has_arg == required_argument | 
|---|
| 454 | || ld_options[i].opt.has_arg == optional_argument) | 
|---|
| 455 | { | 
|---|
| 456 | shortopts[is] = ':'; | 
|---|
| 457 | ++is; | 
|---|
| 458 | if (ld_options[i].opt.has_arg == optional_argument) | 
|---|
| 459 | { | 
|---|
| 460 | shortopts[is] = ':'; | 
|---|
| 461 | ++is; | 
|---|
| 462 | } | 
|---|
| 463 | } | 
|---|
| 464 | } | 
|---|
| 465 | if (ld_options[i].opt.name != NULL) | 
|---|
| 466 | { | 
|---|
| 467 | if (ld_options[i].control == EXACTLY_TWO_DASHES) | 
|---|
| 468 | { | 
|---|
| 469 | really_longopts[irl] = ld_options[i].opt; | 
|---|
| 470 | ++irl; | 
|---|
| 471 | } | 
|---|
| 472 | else | 
|---|
| 473 | { | 
|---|
| 474 | longopts[il] = ld_options[i].opt; | 
|---|
| 475 | ++il; | 
|---|
| 476 | } | 
|---|
| 477 | } | 
|---|
| 478 | } | 
|---|
| 479 | shortopts[is] = '\0'; | 
|---|
| 480 | longopts[il].name = NULL; | 
|---|
| 481 | really_longopts[irl].name = NULL; | 
|---|
| 482 |  | 
|---|
| 483 | /* The -G option is ambiguous on different platforms.  Sometimes it | 
|---|
| 484 | specifies the largest data size to put into the small data | 
|---|
| 485 | section.  Sometimes it is equivalent to --shared.  Unfortunately, | 
|---|
| 486 | the first form takes an argument, while the second does not. | 
|---|
| 487 |  | 
|---|
| 488 | We need to permit the --shared form because on some platforms, | 
|---|
| 489 | such as Solaris, gcc -shared will pass -G to the linker. | 
|---|
| 490 |  | 
|---|
| 491 | To permit either usage, we look through the argument list.  If we | 
|---|
| 492 | find -G not followed by a number, we change it into --shared. | 
|---|
| 493 | This will work for most normal cases.  */ | 
|---|
| 494 | for (i = 1; i < argc; i++) | 
|---|
| 495 | if (strcmp (argv[i], "-G") == 0 | 
|---|
| 496 | && (i + 1 >= argc | 
|---|
| 497 | || ! isdigit ((unsigned char) argv[i + 1][0]))) | 
|---|
| 498 | argv[i] = (char *) "--shared"; | 
|---|
| 499 |  | 
|---|
| 500 | /* Because we permit long options to start with a single dash, and | 
|---|
| 501 | we have a --library option, and the -l option is conventionally | 
|---|
| 502 | used with an immediately following argument, we can have bad | 
|---|
| 503 | results if somebody tries to use -l with a library whose name | 
|---|
| 504 | happens to start with "ibrary", as in -li.  We avoid problems by | 
|---|
| 505 | simply turning -l into --library.  This means that users will | 
|---|
| 506 | have to use two dashes in order to use --library, which is OK | 
|---|
| 507 | since that's how it is documented. | 
|---|
| 508 |  | 
|---|
| 509 | FIXME: It's possible that this problem can arise for other short | 
|---|
| 510 | options as well, although the user does always have the recourse | 
|---|
| 511 | of adding a space between the option and the argument.  */ | 
|---|
| 512 | for (i = 1; i < argc; i++) | 
|---|
| 513 | { | 
|---|
| 514 | if (argv[i][0] == '-' | 
|---|
| 515 | && argv[i][1] == 'l' | 
|---|
| 516 | && argv[i][2] != '\0') | 
|---|
| 517 | { | 
|---|
| 518 | char *n; | 
|---|
| 519 |  | 
|---|
| 520 | n = (char *) xmalloc (strlen (argv[i]) + 20); | 
|---|
| 521 | sprintf (n, "--library=%s", argv[i] + 2); | 
|---|
| 522 | argv[i] = n; | 
|---|
| 523 | } | 
|---|
| 524 | } | 
|---|
| 525 |  | 
|---|
| 526 | last_optind = -1; | 
|---|
| 527 | while (1) | 
|---|
| 528 | { | 
|---|
| 529 | int longind; | 
|---|
| 530 | int optc; | 
|---|
| 531 |  | 
|---|
| 532 | /* Using last_optind lets us avoid calling ldemul_parse_args | 
|---|
| 533 | multiple times on a single option, which would lead to | 
|---|
| 534 | confusion in the internal static variables maintained by | 
|---|
| 535 | getopt.  This could otherwise happen for an argument like | 
|---|
| 536 | -nx, in which the -n is parsed as a single option, and we | 
|---|
| 537 | loop around to pick up the -x.  */ | 
|---|
| 538 | if (optind != last_optind) | 
|---|
| 539 | { | 
|---|
| 540 | if (ldemul_parse_args (argc, argv)) | 
|---|
| 541 | continue; | 
|---|
| 542 | last_optind = optind; | 
|---|
| 543 | } | 
|---|
| 544 |  | 
|---|
| 545 | /* getopt_long_only is like getopt_long, but '-' as well as '--' | 
|---|
| 546 | can indicate a long option.  */ | 
|---|
| 547 | opterr = 0; | 
|---|
| 548 | optc = getopt_long_only (argc, argv, shortopts, longopts, &longind); | 
|---|
| 549 | if (optc == '?') | 
|---|
| 550 | { | 
|---|
| 551 | --optind; | 
|---|
| 552 | optc = getopt_long (argc, argv, shortopts, really_longopts, &longind); | 
|---|
| 553 | } | 
|---|
| 554 |  | 
|---|
| 555 | if (optc == -1) | 
|---|
| 556 | break; | 
|---|
| 557 |  | 
|---|
| 558 | switch (optc) | 
|---|
| 559 | { | 
|---|
| 560 | case '?': | 
|---|
| 561 | fprintf (stderr, _("%s: unrecognized option '%s'\n"), | 
|---|
| 562 | program_name, argv[optind - 1]); | 
|---|
| 563 | default: | 
|---|
| 564 | fprintf (stderr, | 
|---|
| 565 | _("%s: use the --help option for usage information\n"), | 
|---|
| 566 | program_name); | 
|---|
| 567 | xexit (1); | 
|---|
| 568 | case 1:                 /* File name.  */ | 
|---|
| 569 | lang_add_input_file (optarg, lang_input_file_is_file_enum, | 
|---|
| 570 | (char *) NULL); | 
|---|
| 571 | break; | 
|---|
| 572 |  | 
|---|
| 573 | case OPTION_IGNORE: | 
|---|
| 574 | break; | 
|---|
| 575 | case 'a': | 
|---|
| 576 | /* For HP/UX compatibility.  Actually -a shared should mean | 
|---|
| 577 | ``use only shared libraries'' but, then, we don't | 
|---|
| 578 | currently support shared libraries on HP/UX anyhow.  */ | 
|---|
| 579 | if (strcmp (optarg, "archive") == 0) | 
|---|
| 580 | config.dynamic_link = false; | 
|---|
| 581 | else if (strcmp (optarg, "shared") == 0 | 
|---|
| 582 | || strcmp (optarg, "default") == 0) | 
|---|
| 583 | config.dynamic_link = true; | 
|---|
| 584 | else | 
|---|
| 585 | einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg); | 
|---|
| 586 | break; | 
|---|
| 587 | case OPTION_ASSERT: | 
|---|
| 588 | /* FIXME: We just ignore these, but we should handle them.  */ | 
|---|
| 589 | if (strcmp (optarg, "definitions") == 0) | 
|---|
| 590 | ; | 
|---|
| 591 | else if (strcmp (optarg, "nodefinitions") == 0) | 
|---|
| 592 | ; | 
|---|
| 593 | else if (strcmp (optarg, "nosymbolic") == 0) | 
|---|
| 594 | ; | 
|---|
| 595 | else if (strcmp (optarg, "pure-text") == 0) | 
|---|
| 596 | ; | 
|---|
| 597 | else | 
|---|
| 598 | einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg); | 
|---|
| 599 | break; | 
|---|
| 600 | case 'A': | 
|---|
| 601 | ldfile_add_arch (optarg); | 
|---|
| 602 | break; | 
|---|
| 603 | case 'b': | 
|---|
| 604 | lang_add_target (optarg); | 
|---|
| 605 | break; | 
|---|
| 606 | case 'c': | 
|---|
| 607 | ldfile_open_command_file (optarg); | 
|---|
| 608 | parser_input = input_mri_script; | 
|---|
| 609 | yyparse (); | 
|---|
| 610 | break; | 
|---|
| 611 | case OPTION_CALL_SHARED: | 
|---|
| 612 | config.dynamic_link = true; | 
|---|
| 613 | break; | 
|---|
| 614 | case OPTION_NON_SHARED: | 
|---|
| 615 | config.dynamic_link = false; | 
|---|
| 616 | break; | 
|---|
| 617 | case OPTION_CREF: | 
|---|
| 618 | command_line.cref = true; | 
|---|
| 619 | link_info.notice_all = true; | 
|---|
| 620 | break; | 
|---|
| 621 | case 'd': | 
|---|
| 622 | command_line.force_common_definition = true; | 
|---|
| 623 | break; | 
|---|
| 624 | case OPTION_DEFSYM: | 
|---|
| 625 | lex_string = optarg; | 
|---|
| 626 | lex_redirect (optarg); | 
|---|
| 627 | parser_input = input_defsym; | 
|---|
| 628 | parsing_defsym = 1; | 
|---|
| 629 | yyparse (); | 
|---|
| 630 | parsing_defsym = 0; | 
|---|
| 631 | lex_string = NULL; | 
|---|
| 632 | break; | 
|---|
| 633 | case OPTION_DEMANGLE: | 
|---|
| 634 | demangling = true; | 
|---|
| 635 | if (optarg != NULL) | 
|---|
| 636 | { | 
|---|
| 637 | enum demangling_styles style; | 
|---|
| 638 |  | 
|---|
| 639 | style = cplus_demangle_name_to_style (optarg); | 
|---|
| 640 | if (style == unknown_demangling) | 
|---|
| 641 | einfo (_("%F%P: unknown demangling style `%s'"), | 
|---|
| 642 | optarg); | 
|---|
| 643 |  | 
|---|
| 644 | cplus_demangle_set_style (style); | 
|---|
| 645 | } | 
|---|
| 646 | break; | 
|---|
| 647 | case OPTION_DYNAMIC_LINKER: | 
|---|
| 648 | command_line.interpreter = optarg; | 
|---|
| 649 | break; | 
|---|
| 650 | case OPTION_EB: | 
|---|
| 651 | command_line.endian = ENDIAN_BIG; | 
|---|
| 652 | break; | 
|---|
| 653 | case OPTION_EL: | 
|---|
| 654 | command_line.endian = ENDIAN_LITTLE; | 
|---|
| 655 | break; | 
|---|
| 656 | case OPTION_EMBEDDED_RELOCS: | 
|---|
| 657 | command_line.embedded_relocs = true; | 
|---|
| 658 | break; | 
|---|
| 659 | case OPTION_EXPORT_DYNAMIC: | 
|---|
| 660 | case 'E': /* HP/UX compatibility.  */ | 
|---|
| 661 | command_line.export_dynamic = true; | 
|---|
| 662 | break; | 
|---|
| 663 | case 'e': | 
|---|
| 664 | lang_add_entry (optarg, true); | 
|---|
| 665 | break; | 
|---|
| 666 | case 'f': | 
|---|
| 667 | if (command_line.auxiliary_filters == NULL) | 
|---|
| 668 | { | 
|---|
| 669 | command_line.auxiliary_filters = | 
|---|
| 670 | (char **) xmalloc (2 * sizeof (char *)); | 
|---|
| 671 | command_line.auxiliary_filters[0] = optarg; | 
|---|
| 672 | command_line.auxiliary_filters[1] = NULL; | 
|---|
| 673 | } | 
|---|
| 674 | else | 
|---|
| 675 | { | 
|---|
| 676 | int c; | 
|---|
| 677 | char **p; | 
|---|
| 678 |  | 
|---|
| 679 | c = 0; | 
|---|
| 680 | for (p = command_line.auxiliary_filters; *p != NULL; p++) | 
|---|
| 681 | ++c; | 
|---|
| 682 | command_line.auxiliary_filters = | 
|---|
| 683 | (char **) xrealloc (command_line.auxiliary_filters, | 
|---|
| 684 | (c + 2) * sizeof (char *)); | 
|---|
| 685 | command_line.auxiliary_filters[c] = optarg; | 
|---|
| 686 | command_line.auxiliary_filters[c + 1] = NULL; | 
|---|
| 687 | } | 
|---|
| 688 | break; | 
|---|
| 689 | case 'F': | 
|---|
| 690 | command_line.filter_shlib = optarg; | 
|---|
| 691 | break; | 
|---|
| 692 | case OPTION_FORCE_EXE_SUFFIX: | 
|---|
| 693 | command_line.force_exe_suffix = true; | 
|---|
| 694 | break; | 
|---|
| 695 | case 'G': | 
|---|
| 696 | { | 
|---|
| 697 | char *end; | 
|---|
| 698 | g_switch_value = strtoul (optarg, &end, 0); | 
|---|
| 699 | if (*end) | 
|---|
| 700 | einfo (_("%P%F: invalid number `%s'\n"), optarg); | 
|---|
| 701 | } | 
|---|
| 702 | break; | 
|---|
| 703 | case 'g': | 
|---|
| 704 | /* Ignore.  */ | 
|---|
| 705 | break; | 
|---|
| 706 | case OPTION_GC_SECTIONS: | 
|---|
| 707 | command_line.gc_sections = true; | 
|---|
| 708 | break; | 
|---|
| 709 | case OPTION_HELP: | 
|---|
| 710 | help (); | 
|---|
| 711 | xexit (0); | 
|---|
| 712 | break; | 
|---|
| 713 | case 'L': | 
|---|
| 714 | ldfile_add_library_path (optarg, true); | 
|---|
| 715 | break; | 
|---|
| 716 | case 'l': | 
|---|
| 717 | lang_add_input_file (optarg, lang_input_file_is_l_enum, | 
|---|
| 718 | (char *) NULL); | 
|---|
| 719 | break; | 
|---|
| 720 | case 'M': | 
|---|
| 721 | config.map_filename = "-"; | 
|---|
| 722 | break; | 
|---|
| 723 | case 'm': | 
|---|
| 724 | /* Ignore.  Was handled in a pre-parse.   */ | 
|---|
| 725 | break; | 
|---|
| 726 | case OPTION_MAP: | 
|---|
| 727 | config.map_filename = optarg; | 
|---|
| 728 | break; | 
|---|
| 729 | case 'N': | 
|---|
| 730 | config.text_read_only = false; | 
|---|
| 731 | config.magic_demand_paged = false; | 
|---|
| 732 | config.dynamic_link = false; | 
|---|
| 733 | break; | 
|---|
| 734 | case 'n': | 
|---|
| 735 | config.magic_demand_paged = false; | 
|---|
| 736 | config.dynamic_link = false; | 
|---|
| 737 | break; | 
|---|
| 738 | case OPTION_NO_DEMANGLE: | 
|---|
| 739 | demangling = false; | 
|---|
| 740 | break; | 
|---|
| 741 | case OPTION_NO_GC_SECTIONS: | 
|---|
| 742 | command_line.gc_sections = false; | 
|---|
| 743 | break; | 
|---|
| 744 | case OPTION_NO_KEEP_MEMORY: | 
|---|
| 745 | link_info.keep_memory = false; | 
|---|
| 746 | break; | 
|---|
| 747 | case OPTION_NO_UNDEFINED: | 
|---|
| 748 | link_info.no_undefined = true; | 
|---|
| 749 | break; | 
|---|
| 750 | case OPTION_ALLOW_SHLIB_UNDEFINED: | 
|---|
| 751 | link_info.allow_shlib_undefined = true; | 
|---|
| 752 | break; | 
|---|
| 753 | case OPTION_NO_WARN_MISMATCH: | 
|---|
| 754 | command_line.warn_mismatch = false; | 
|---|
| 755 | break; | 
|---|
| 756 | case OPTION_NOINHIBIT_EXEC: | 
|---|
| 757 | force_make_executable = true; | 
|---|
| 758 | break; | 
|---|
| 759 | case OPTION_NO_WHOLE_ARCHIVE: | 
|---|
| 760 | whole_archive = false; | 
|---|
| 761 | break; | 
|---|
| 762 | case 'O': | 
|---|
| 763 | /* FIXME "-O<non-digits> <value>" used to set the address of | 
|---|
| 764 | section <non-digits>.  Was this for compatibility with | 
|---|
| 765 | something, or can we create a new option to do that | 
|---|
| 766 | (with a syntax similar to -defsym)? | 
|---|
| 767 | getopt can't handle two args to an option without kludges.  */ | 
|---|
| 768 |  | 
|---|
| 769 | /* Enable optimizations of output files.  */ | 
|---|
| 770 | link_info.optimize = strtoul (optarg, NULL, 0) ? true : false; | 
|---|
| 771 | break; | 
|---|
| 772 | case 'o': | 
|---|
| 773 | lang_add_output (optarg, 0); | 
|---|
| 774 | break; | 
|---|
| 775 | case OPTION_OFORMAT: | 
|---|
| 776 | lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0); | 
|---|
| 777 | break; | 
|---|
| 778 | case 'q': | 
|---|
| 779 | link_info.emitrelocations = true; | 
|---|
| 780 | break; | 
|---|
| 781 | case 'i': | 
|---|
| 782 | case 'r': | 
|---|
| 783 | link_info.relocateable = true; | 
|---|
| 784 | config.build_constructors = false; | 
|---|
| 785 | config.magic_demand_paged = false; | 
|---|
| 786 | config.text_read_only = false; | 
|---|
| 787 | config.dynamic_link = false; | 
|---|
| 788 | break; | 
|---|
| 789 | case 'R': | 
|---|
| 790 | /* The GNU linker traditionally uses -R to mean to include | 
|---|
| 791 | only the symbols from a file.  The Solaris linker uses -R | 
|---|
| 792 | to set the path used by the runtime linker to find | 
|---|
| 793 | libraries.  This is the GNU linker -rpath argument.  We | 
|---|
| 794 | try to support both simultaneously by checking the file | 
|---|
| 795 | named.  If it is a directory, rather than a regular file, | 
|---|
| 796 | we assume -rpath was meant.  */ | 
|---|
| 797 | { | 
|---|
| 798 | struct stat s; | 
|---|
| 799 |  | 
|---|
| 800 | if (stat (optarg, &s) >= 0 | 
|---|
| 801 | && ! S_ISDIR (s.st_mode)) | 
|---|
| 802 | { | 
|---|
| 803 | lang_add_input_file (optarg, | 
|---|
| 804 | lang_input_file_is_symbols_only_enum, | 
|---|
| 805 | (char *) NULL); | 
|---|
| 806 | break; | 
|---|
| 807 | } | 
|---|
| 808 | } | 
|---|
| 809 | /* Fall through.  */ | 
|---|
| 810 | case OPTION_RPATH: | 
|---|
| 811 | if (command_line.rpath == NULL) | 
|---|
| 812 | command_line.rpath = xstrdup (optarg); | 
|---|
| 813 | else | 
|---|
| 814 | { | 
|---|
| 815 | size_t rpath_len = strlen (command_line.rpath); | 
|---|
| 816 | size_t optarg_len = strlen (optarg); | 
|---|
| 817 | char *buf; | 
|---|
| 818 | char *cp = command_line.rpath; | 
|---|
| 819 |  | 
|---|
| 820 | /* First see whether OPTARG is already in the path.  */ | 
|---|
| 821 | do | 
|---|
| 822 | { | 
|---|
| 823 | size_t idx = 0; | 
|---|
| 824 | while (optarg[idx] != '\0' && optarg[idx] == cp[idx]) | 
|---|
| 825 | ++idx; | 
|---|
| 826 | if (optarg[idx] == '\0' | 
|---|
| 827 | && (cp[idx] == '\0' || cp[idx] == ':')) | 
|---|
| 828 | /* We found it.  */ | 
|---|
| 829 | break; | 
|---|
| 830 |  | 
|---|
| 831 | /* Not yet found.  */ | 
|---|
| 832 | cp = strchr (cp, ':'); | 
|---|
| 833 | if (cp != NULL) | 
|---|
| 834 | ++cp; | 
|---|
| 835 | } | 
|---|
| 836 | while (cp != NULL); | 
|---|
| 837 |  | 
|---|
| 838 | if (cp == NULL) | 
|---|
| 839 | { | 
|---|
| 840 | buf = xmalloc (rpath_len + optarg_len + 2); | 
|---|
| 841 | sprintf (buf, "%s:%s", command_line.rpath, optarg); | 
|---|
| 842 | free (command_line.rpath); | 
|---|
| 843 | command_line.rpath = buf; | 
|---|
| 844 | } | 
|---|
| 845 | } | 
|---|
| 846 | break; | 
|---|
| 847 | case OPTION_RPATH_LINK: | 
|---|
| 848 | if (command_line.rpath_link == NULL) | 
|---|
| 849 | command_line.rpath_link = xstrdup (optarg); | 
|---|
| 850 | else | 
|---|
| 851 | { | 
|---|
| 852 | char *buf; | 
|---|
| 853 |  | 
|---|
| 854 | buf = xmalloc (strlen (command_line.rpath_link) | 
|---|
| 855 | + strlen (optarg) | 
|---|
| 856 | + 2); | 
|---|
| 857 | sprintf (buf, "%s:%s", command_line.rpath_link, optarg); | 
|---|
| 858 | free (command_line.rpath_link); | 
|---|
| 859 | command_line.rpath_link = buf; | 
|---|
| 860 | } | 
|---|
| 861 | break; | 
|---|
| 862 | case OPTION_RELAX: | 
|---|
| 863 | command_line.relax = true; | 
|---|
| 864 | break; | 
|---|
| 865 | case OPTION_RETAIN_SYMBOLS_FILE: | 
|---|
| 866 | add_keepsyms_file (optarg); | 
|---|
| 867 | break; | 
|---|
| 868 | case 'S': | 
|---|
| 869 | link_info.strip = strip_debugger; | 
|---|
| 870 | break; | 
|---|
| 871 | case 's': | 
|---|
| 872 | link_info.strip = strip_all; | 
|---|
| 873 | break; | 
|---|
| 874 | case OPTION_SHARED: | 
|---|
| 875 | if (config.has_shared) | 
|---|
| 876 | link_info.shared = true; | 
|---|
| 877 | else | 
|---|
| 878 | einfo (_("%P%F: -shared not supported\n")); | 
|---|
| 879 | break; | 
|---|
| 880 | case 'h':               /* Used on Solaris.  */ | 
|---|
| 881 | case OPTION_SONAME: | 
|---|
| 882 | command_line.soname = optarg; | 
|---|
| 883 | break; | 
|---|
| 884 | case OPTION_SORT_COMMON: | 
|---|
| 885 | config.sort_common = true; | 
|---|
| 886 | break; | 
|---|
| 887 | case OPTION_STATS: | 
|---|
| 888 | config.stats = true; | 
|---|
| 889 | break; | 
|---|
| 890 | case OPTION_SYMBOLIC: | 
|---|
| 891 | link_info.symbolic = true; | 
|---|
| 892 | break; | 
|---|
| 893 | case 't': | 
|---|
| 894 | trace_files = true; | 
|---|
| 895 | break; | 
|---|
| 896 | case 'T': | 
|---|
| 897 | ldfile_open_command_file (optarg); | 
|---|
| 898 | parser_input = input_script; | 
|---|
| 899 | yyparse (); | 
|---|
| 900 | break; | 
|---|
| 901 | case OPTION_SECTION_START: | 
|---|
| 902 | { | 
|---|
| 903 | char *optarg2; | 
|---|
| 904 | char *sec_name; | 
|---|
| 905 | int len; | 
|---|
| 906 |  | 
|---|
| 907 | /* Check for <something>=<somthing>...  */ | 
|---|
| 908 | optarg2 = strchr (optarg, '='); | 
|---|
| 909 | if (optarg2 == NULL) | 
|---|
| 910 | { | 
|---|
| 911 | fprintf (stderr, | 
|---|
| 912 | _("%s: Invalid argument to option \"--section-start\"\n"), | 
|---|
| 913 | program_name); | 
|---|
| 914 | xexit (1); | 
|---|
| 915 | } | 
|---|
| 916 |  | 
|---|
| 917 | optarg2++; | 
|---|
| 918 |  | 
|---|
| 919 | /* So far so good.  Are all the args present?  */ | 
|---|
| 920 | if ((*optarg == '\0') || (*optarg2 == '\0')) | 
|---|
| 921 | { | 
|---|
| 922 | fprintf (stderr, | 
|---|
| 923 | _("%s: Missing argument(s) to option \"--section-start\"\n"), | 
|---|
| 924 | program_name); | 
|---|
| 925 | xexit (1); | 
|---|
| 926 | } | 
|---|
| 927 |  | 
|---|
| 928 | /* We must copy the section name as set_section_start | 
|---|
| 929 | doesn't do it for us.  */ | 
|---|
| 930 | len = optarg2 - optarg; | 
|---|
| 931 | sec_name = xmalloc (len); | 
|---|
| 932 | memcpy (sec_name, optarg, len - 1); | 
|---|
| 933 | sec_name[len - 1] = 0; | 
|---|
| 934 |  | 
|---|
| 935 | /* Then set it...  */ | 
|---|
| 936 | set_section_start (sec_name, optarg2); | 
|---|
| 937 | } | 
|---|
| 938 | break; | 
|---|
| 939 | case OPTION_TARGET_HELP: | 
|---|
| 940 | /* Mention any target specific options.  */ | 
|---|
| 941 | ldemul_list_emulation_options (stdout); | 
|---|
| 942 | exit (0); | 
|---|
| 943 | case OPTION_TBSS: | 
|---|
| 944 | set_section_start (".bss", optarg); | 
|---|
| 945 | break; | 
|---|
| 946 | case OPTION_TDATA: | 
|---|
| 947 | set_section_start (".data", optarg); | 
|---|
| 948 | break; | 
|---|
| 949 | case OPTION_TTEXT: | 
|---|
| 950 | set_section_start (".text", optarg); | 
|---|
| 951 | break; | 
|---|
| 952 | case OPTION_TRADITIONAL_FORMAT: | 
|---|
| 953 | link_info.traditional_format = true; | 
|---|
| 954 | break; | 
|---|
| 955 | case OPTION_TASK_LINK: | 
|---|
| 956 | link_info.task_link = true; | 
|---|
| 957 | /* Fall through - do an implied -r option.  */ | 
|---|
| 958 | case OPTION_UR: | 
|---|
| 959 | link_info.relocateable = true; | 
|---|
| 960 | config.build_constructors = true; | 
|---|
| 961 | config.magic_demand_paged = false; | 
|---|
| 962 | config.text_read_only = false; | 
|---|
| 963 | config.dynamic_link = false; | 
|---|
| 964 | break; | 
|---|
| 965 | case 'u': | 
|---|
| 966 | ldlang_add_undef (optarg); | 
|---|
| 967 | break; | 
|---|
| 968 | case OPTION_UNIQUE: | 
|---|
| 969 | if (optarg != NULL) | 
|---|
| 970 | lang_add_unique (optarg); | 
|---|
| 971 | else | 
|---|
| 972 | config.unique_orphan_sections = true; | 
|---|
| 973 | break; | 
|---|
| 974 | case OPTION_VERBOSE: | 
|---|
| 975 | ldversion (1); | 
|---|
| 976 | version_printed = true; | 
|---|
| 977 | trace_file_tries = true; | 
|---|
| 978 | break; | 
|---|
| 979 | case 'v': | 
|---|
| 980 | ldversion (0); | 
|---|
| 981 | version_printed = true; | 
|---|
| 982 | break; | 
|---|
| 983 | case 'V': | 
|---|
| 984 | ldversion (1); | 
|---|
| 985 | version_printed = true; | 
|---|
| 986 | break; | 
|---|
| 987 | case OPTION_VERSION: | 
|---|
| 988 | /* This output is intended to follow the GNU standards document.  */ | 
|---|
| 989 | printf ("GNU ld %s\n", ld_program_version); | 
|---|
| 990 | printf (_("Copyright 2001 Free Software Foundation, Inc.\n")); | 
|---|
| 991 | printf (_("\ | 
|---|
| 992 | This program is free software; you may redistribute it under the terms of\n\ | 
|---|
| 993 | the GNU General Public License.  This program has absolutely no warranty.\n")); | 
|---|
| 994 | { | 
|---|
| 995 | ld_emulation_xfer_type **ptr = ld_emulations; | 
|---|
| 996 |  | 
|---|
| 997 | printf (_("  Supported emulations:\n")); | 
|---|
| 998 | while (*ptr) | 
|---|
| 999 | { | 
|---|
| 1000 | printf ("   %s\n", (*ptr)->emulation_name); | 
|---|
| 1001 | ptr++; | 
|---|
| 1002 | } | 
|---|
| 1003 | } | 
|---|
| 1004 | xexit (0); | 
|---|
| 1005 | break; | 
|---|
| 1006 | case OPTION_VERSION_SCRIPT: | 
|---|
| 1007 | /* This option indicates a small script that only specifies | 
|---|
| 1008 | version information.  Read it, but don't assume that | 
|---|
| 1009 | we've seen a linker script.  */ | 
|---|
| 1010 | { | 
|---|
| 1011 | boolean hold_had_script; | 
|---|
| 1012 |  | 
|---|
| 1013 | hold_had_script = had_script; | 
|---|
| 1014 | ldfile_open_command_file (optarg); | 
|---|
| 1015 | had_script = hold_had_script; | 
|---|
| 1016 | parser_input = input_version_script; | 
|---|
| 1017 | yyparse (); | 
|---|
| 1018 | } | 
|---|
| 1019 | break; | 
|---|
| 1020 | case OPTION_VERSION_EXPORTS_SECTION: | 
|---|
| 1021 | /* This option records a version symbol to be applied to the | 
|---|
| 1022 | symbols listed for export to be found in the object files | 
|---|
| 1023 | .exports sections.  */ | 
|---|
| 1024 | command_line.version_exports_section = optarg; | 
|---|
| 1025 | break; | 
|---|
| 1026 | case OPTION_WARN_COMMON: | 
|---|
| 1027 | config.warn_common = true; | 
|---|
| 1028 | break; | 
|---|
| 1029 | case OPTION_WARN_CONSTRUCTORS: | 
|---|
| 1030 | config.warn_constructors = true; | 
|---|
| 1031 | break; | 
|---|
| 1032 | case OPTION_WARN_MULTIPLE_GP: | 
|---|
| 1033 | config.warn_multiple_gp = true; | 
|---|
| 1034 | break; | 
|---|
| 1035 | case OPTION_WARN_ONCE: | 
|---|
| 1036 | config.warn_once = true; | 
|---|
| 1037 | break; | 
|---|
| 1038 | case OPTION_WARN_SECTION_ALIGN: | 
|---|
| 1039 | config.warn_section_align = true; | 
|---|
| 1040 | break; | 
|---|
| 1041 | case OPTION_WHOLE_ARCHIVE: | 
|---|
| 1042 | whole_archive = true; | 
|---|
| 1043 | break; | 
|---|
| 1044 | case OPTION_WRAP: | 
|---|
| 1045 | add_wrap (optarg); | 
|---|
| 1046 | break; | 
|---|
| 1047 | case 'X': | 
|---|
| 1048 | link_info.discard = discard_l; | 
|---|
| 1049 | break; | 
|---|
| 1050 | case 'x': | 
|---|
| 1051 | link_info.discard = discard_all; | 
|---|
| 1052 | break; | 
|---|
| 1053 | case 'Y': | 
|---|
| 1054 | if (strncmp (optarg, "P,", 2) == 0) | 
|---|
| 1055 | optarg += 2; | 
|---|
| 1056 | default_dirlist = xstrdup (optarg); | 
|---|
| 1057 | break; | 
|---|
| 1058 | case 'y': | 
|---|
| 1059 | add_ysym (optarg); | 
|---|
| 1060 | break; | 
|---|
| 1061 | case OPTION_SPLIT_BY_RELOC: | 
|---|
| 1062 | if (optarg != NULL) | 
|---|
| 1063 | config.split_by_reloc = strtoul (optarg, NULL, 0); | 
|---|
| 1064 | else | 
|---|
| 1065 | config.split_by_reloc = 32768; | 
|---|
| 1066 | break; | 
|---|
| 1067 | case OPTION_SPLIT_BY_FILE: | 
|---|
| 1068 | if (optarg != NULL) | 
|---|
| 1069 | config.split_by_file = bfd_scan_vma (optarg, NULL, 0); | 
|---|
| 1070 | else | 
|---|
| 1071 | config.split_by_file = 1; | 
|---|
| 1072 | break; | 
|---|
| 1073 | case OPTION_CHECK_SECTIONS: | 
|---|
| 1074 | command_line.check_section_addresses = true; | 
|---|
| 1075 | break; | 
|---|
| 1076 | case OPTION_NO_CHECK_SECTIONS: | 
|---|
| 1077 | command_line.check_section_addresses = false; | 
|---|
| 1078 | break; | 
|---|
| 1079 | case '(': | 
|---|
| 1080 | if (ingroup) | 
|---|
| 1081 | { | 
|---|
| 1082 | fprintf (stderr, | 
|---|
| 1083 | _("%s: may not nest groups (--help for usage)\n"), | 
|---|
| 1084 | program_name); | 
|---|
| 1085 | xexit (1); | 
|---|
| 1086 | } | 
|---|
| 1087 | lang_enter_group (); | 
|---|
| 1088 | ingroup = 1; | 
|---|
| 1089 | break; | 
|---|
| 1090 | case ')': | 
|---|
| 1091 | if (! ingroup) | 
|---|
| 1092 | { | 
|---|
| 1093 | fprintf (stderr, | 
|---|
| 1094 | _("%s: group ended before it began (--help for usage)\n"), | 
|---|
| 1095 | program_name); | 
|---|
| 1096 | xexit (1); | 
|---|
| 1097 | } | 
|---|
| 1098 | lang_leave_group (); | 
|---|
| 1099 | ingroup = 0; | 
|---|
| 1100 | break; | 
|---|
| 1101 | case OPTION_MPC860C0: | 
|---|
| 1102 | link_info.mpc860c0 = 20;      /* default value (in bytes) */ | 
|---|
| 1103 | if (optarg) | 
|---|
| 1104 | { | 
|---|
| 1105 | unsigned words; | 
|---|
| 1106 |  | 
|---|
| 1107 | words = is_num (optarg, 1, 10, 0); | 
|---|
| 1108 | if (words == 0) | 
|---|
| 1109 | { | 
|---|
| 1110 | fprintf (stderr, | 
|---|
| 1111 | _("%s: Invalid argument to option \"mpc860c0\"\n"), | 
|---|
| 1112 | program_name); | 
|---|
| 1113 | xexit (1); | 
|---|
| 1114 | } | 
|---|
| 1115 | link_info.mpc860c0 = words * 4;   /* convert words to bytes */ | 
|---|
| 1116 | } | 
|---|
| 1117 | command_line.relax = true; | 
|---|
| 1118 | break; | 
|---|
| 1119 |  | 
|---|
| 1120 | case OPTION_INIT: | 
|---|
| 1121 | link_info.init_function = optarg; | 
|---|
| 1122 | break; | 
|---|
| 1123 |  | 
|---|
| 1124 | case OPTION_FINI: | 
|---|
| 1125 | link_info.fini_function = optarg; | 
|---|
| 1126 | break; | 
|---|
| 1127 | } | 
|---|
| 1128 | } | 
|---|
| 1129 |  | 
|---|
| 1130 | if (ingroup) | 
|---|
| 1131 | lang_leave_group (); | 
|---|
| 1132 |  | 
|---|
| 1133 | if (default_dirlist != NULL) | 
|---|
| 1134 | set_default_dirlist (default_dirlist); | 
|---|
| 1135 |  | 
|---|
| 1136 | } | 
|---|
| 1137 |  | 
|---|
| 1138 | /* Add the (colon-separated) elements of DIRLIST_PTR to the | 
|---|
| 1139 | library search path.  */ | 
|---|
| 1140 |  | 
|---|
| 1141 | static void | 
|---|
| 1142 | set_default_dirlist (dirlist_ptr) | 
|---|
| 1143 | char *dirlist_ptr; | 
|---|
| 1144 | { | 
|---|
| 1145 | char *p; | 
|---|
| 1146 |  | 
|---|
| 1147 | while (1) | 
|---|
| 1148 | { | 
|---|
| 1149 | p = strchr (dirlist_ptr, PATH_SEPARATOR); | 
|---|
| 1150 | if (p != NULL) | 
|---|
| 1151 | *p = '\0'; | 
|---|
| 1152 | if (*dirlist_ptr != '\0') | 
|---|
| 1153 | ldfile_add_library_path (dirlist_ptr, true); | 
|---|
| 1154 | if (p == NULL) | 
|---|
| 1155 | break; | 
|---|
| 1156 | dirlist_ptr = p + 1; | 
|---|
| 1157 | } | 
|---|
| 1158 | } | 
|---|
| 1159 |  | 
|---|
| 1160 | static void | 
|---|
| 1161 | set_section_start (sect, valstr) | 
|---|
| 1162 | char *sect, *valstr; | 
|---|
| 1163 | { | 
|---|
| 1164 | const char *end; | 
|---|
| 1165 | bfd_vma val = bfd_scan_vma (valstr, &end, 16); | 
|---|
| 1166 | if (*end) | 
|---|
| 1167 | einfo (_("%P%F: invalid hex number `%s'\n"), valstr); | 
|---|
| 1168 | lang_section_start (sect, exp_intop (val)); | 
|---|
| 1169 | } | 
|---|
| 1170 |  | 
|---|
| 1171 |  | 
|---|
| 1172 | /* Print help messages for the options.  */ | 
|---|
| 1173 |  | 
|---|
| 1174 | static void | 
|---|
| 1175 | help () | 
|---|
| 1176 | { | 
|---|
| 1177 | unsigned i; | 
|---|
| 1178 | const char **targets, **pp; | 
|---|
| 1179 |  | 
|---|
| 1180 | printf (_("Usage: %s [options] file...\n"), program_name); | 
|---|
| 1181 |  | 
|---|
| 1182 | printf (_("Options:\n")); | 
|---|
| 1183 | for (i = 0; i < OPTION_COUNT; i++) | 
|---|
| 1184 | { | 
|---|
| 1185 | if (ld_options[i].doc != NULL) | 
|---|
| 1186 | { | 
|---|
| 1187 | boolean comma; | 
|---|
| 1188 | int len; | 
|---|
| 1189 | unsigned j; | 
|---|
| 1190 |  | 
|---|
| 1191 | printf ("  "); | 
|---|
| 1192 |  | 
|---|
| 1193 | comma = false; | 
|---|
| 1194 | len = 2; | 
|---|
| 1195 |  | 
|---|
| 1196 | j = i; | 
|---|
| 1197 | do | 
|---|
| 1198 | { | 
|---|
| 1199 | if (ld_options[j].shortopt != '\0' | 
|---|
| 1200 | && ld_options[j].control != NO_HELP) | 
|---|
| 1201 | { | 
|---|
| 1202 | printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt); | 
|---|
| 1203 | len += (comma ? 2 : 0) + 2; | 
|---|
| 1204 | if (ld_options[j].arg != NULL) | 
|---|
| 1205 | { | 
|---|
| 1206 | if (ld_options[j].opt.has_arg != optional_argument) | 
|---|
| 1207 | { | 
|---|
| 1208 | printf (" "); | 
|---|
| 1209 | ++len; | 
|---|
| 1210 | } | 
|---|
| 1211 | printf ("%s", _(ld_options[j].arg)); | 
|---|
| 1212 | len += strlen (_(ld_options[j].arg)); | 
|---|
| 1213 | } | 
|---|
| 1214 | comma = true; | 
|---|
| 1215 | } | 
|---|
| 1216 | ++j; | 
|---|
| 1217 | } | 
|---|
| 1218 | while (j < OPTION_COUNT && ld_options[j].doc == NULL); | 
|---|
| 1219 |  | 
|---|
| 1220 | j = i; | 
|---|
| 1221 | do | 
|---|
| 1222 | { | 
|---|
| 1223 | if (ld_options[j].opt.name != NULL | 
|---|
| 1224 | && ld_options[j].control != NO_HELP) | 
|---|
| 1225 | { | 
|---|
| 1226 | int two_dashes = | 
|---|
| 1227 | (ld_options[j].control == TWO_DASHES | 
|---|
| 1228 | || ld_options[j].control == EXACTLY_TWO_DASHES); | 
|---|
| 1229 |  | 
|---|
| 1230 | printf ("%s-%s%s", | 
|---|
| 1231 | comma ? ", " : "", | 
|---|
| 1232 | two_dashes ? "-" : "", | 
|---|
| 1233 | ld_options[j].opt.name); | 
|---|
| 1234 | len += ((comma ? 2 : 0) | 
|---|
| 1235 | + 1 | 
|---|
| 1236 | + (two_dashes ? 1 : 0) | 
|---|
| 1237 | + strlen (ld_options[j].opt.name)); | 
|---|
| 1238 | if (ld_options[j].arg != NULL) | 
|---|
| 1239 | { | 
|---|
| 1240 | printf (" %s", _(ld_options[j].arg)); | 
|---|
| 1241 | len += 1 + strlen (_(ld_options[j].arg)); | 
|---|
| 1242 | } | 
|---|
| 1243 | comma = true; | 
|---|
| 1244 | } | 
|---|
| 1245 | ++j; | 
|---|
| 1246 | } | 
|---|
| 1247 | while (j < OPTION_COUNT && ld_options[j].doc == NULL); | 
|---|
| 1248 |  | 
|---|
| 1249 | if (len >= 30) | 
|---|
| 1250 | { | 
|---|
| 1251 | printf ("\n"); | 
|---|
| 1252 | len = 0; | 
|---|
| 1253 | } | 
|---|
| 1254 |  | 
|---|
| 1255 | for (; len < 30; len++) | 
|---|
| 1256 | putchar (' '); | 
|---|
| 1257 |  | 
|---|
| 1258 | printf ("%s\n", _(ld_options[i].doc)); | 
|---|
| 1259 | } | 
|---|
| 1260 | } | 
|---|
| 1261 |  | 
|---|
| 1262 | /* Note: Various tools (such as libtool) depend upon the | 
|---|
| 1263 | format of the listings below - do not change them.  */ | 
|---|
| 1264 | /* xgettext:c-format */ | 
|---|
| 1265 | printf (_("%s: supported targets:"), program_name); | 
|---|
| 1266 | targets = bfd_target_list (); | 
|---|
| 1267 | for (pp = targets; *pp != NULL; pp++) | 
|---|
| 1268 | printf (" %s", *pp); | 
|---|
| 1269 | free (targets); | 
|---|
| 1270 | printf ("\n"); | 
|---|
| 1271 |  | 
|---|
| 1272 | /* xgettext:c-format */ | 
|---|
| 1273 | printf (_("%s: supported emulations: "), program_name); | 
|---|
| 1274 | ldemul_list_emulations (stdout); | 
|---|
| 1275 | printf ("\n"); | 
|---|
| 1276 |  | 
|---|
| 1277 | /* xgettext:c-format */ | 
|---|
| 1278 | printf (_("%s: emulation specific options:\n"), program_name); | 
|---|
| 1279 | ldemul_list_emulation_options (stdout); | 
|---|
| 1280 | printf ("\n"); | 
|---|
| 1281 |  | 
|---|
| 1282 | printf (_("Report bugs to %s\n"), REPORT_BUGS_TO); | 
|---|
| 1283 | } | 
|---|