1 /* Parse options for the GNU linker. 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 3 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 4 Free Software Foundation, Inc. 5 6 This file is part of the GNU Binutils. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 21 MA 02110-1301, USA. */ 22 23 #include "sysdep.h" 24 #include "bfd.h" 25 #include "bfdver.h" 26 #include "libiberty.h" 27 #include <stdio.h> 28 #include <string.h> 29 #include "safe-ctype.h" 30 #include "getopt.h" 31 #include "bfdlink.h" 32 #include "ld.h" 33 #include "ldmain.h" 34 #include "ldmisc.h" 35 #include "ldexp.h" 36 #include "ldlang.h" 37 #include <ldgram.h> 38 #include "ldlex.h" 39 #include "ldfile.h" 40 #include "ldver.h" 41 #include "ldemul.h" 42 #include "demangle.h" 43 #ifdef ENABLE_PLUGINS 44 #include "plugin.h" 45 #endif /* ENABLE_PLUGINS */ 46 47 #ifndef PATH_SEPARATOR 48 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__)) 49 #define PATH_SEPARATOR ';' 50 #else 51 #define PATH_SEPARATOR ':' 52 #endif 53 #endif 54 55 /* Somewhere above, sys/stat.h got included . . . . */ 56 #if !defined(S_ISDIR) && defined(S_IFDIR) 57 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 58 #endif 59 60 static void set_default_dirlist (char *); 61 static void set_section_start (char *, char *); 62 static void set_segment_start (const char *, char *); 63 static void help (void); 64 65 /* The long options. This structure is used for both the option 66 parsing and the help text. */ 67 68 enum control_enum { 69 /* Use one dash before long option name. */ 70 ONE_DASH, 71 /* Use two dashes before long option name. */ 72 TWO_DASHES, 73 /* Only accept two dashes before the long option name. 74 This is an overloading of the use of this enum, since originally it 75 was only intended to tell the --help display function how to display 76 the long option name. This feature was added in order to resolve 77 the confusion about the -omagic command line switch. Is it setting 78 the output file name to "magic" or is it setting the NMAGIC flag on 79 the output ? It has been decided that it is setting the output file 80 name, and that if you want to set the NMAGIC flag you should use -N 81 or --omagic. */ 82 EXACTLY_TWO_DASHES, 83 /* Don't mention this option in --help output. */ 84 NO_HELP 85 }; 86 87 struct ld_option 88 { 89 /* The long option information. */ 90 struct option opt; 91 /* The short option with the same meaning ('\0' if none). */ 92 char shortopt; 93 /* The name of the argument (NULL if none). */ 94 const char *arg; 95 /* The documentation string. If this is NULL, this is a synonym for 96 the previous option. */ 97 const char *doc; 98 enum control_enum control; 99 }; 100 101 static const struct ld_option ld_options[] = 102 { 103 { {NULL, required_argument, NULL, '\0'}, 104 'a', N_("KEYWORD"), N_("Shared library control for HP/UX compatibility"), 105 ONE_DASH }, 106 { {"architecture", required_argument, NULL, 'A'}, 107 'A', N_("ARCH"), N_("Set architecture") , TWO_DASHES }, 108 { {"format", required_argument, NULL, 'b'}, 109 'b', N_("TARGET"), N_("Specify target for following input files"), 110 TWO_DASHES }, 111 { {"mri-script", required_argument, NULL, 'c'}, 112 'c', N_("FILE"), N_("Read MRI format linker script"), TWO_DASHES }, 113 { {"dc", no_argument, NULL, 'd'}, 114 'd', NULL, N_("Force common symbols to be defined"), ONE_DASH }, 115 { {"dp", no_argument, NULL, 'd'}, 116 '\0', NULL, NULL, ONE_DASH }, 117 { {"entry", required_argument, NULL, 'e'}, 118 'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES }, 119 { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC}, 120 'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES }, 121 { {"no-export-dynamic", no_argument, NULL, OPTION_NO_EXPORT_DYNAMIC}, 122 '\0', NULL, N_("Undo the effect of --export-dynamic"), TWO_DASHES }, 123 { {"EB", no_argument, NULL, OPTION_EB}, 124 '\0', NULL, N_("Link big-endian objects"), ONE_DASH }, 125 { {"EL", no_argument, NULL, OPTION_EL}, 126 '\0', NULL, N_("Link little-endian objects"), ONE_DASH }, 127 { {"auxiliary", required_argument, NULL, 'f'}, 128 'f', N_("SHLIB"), N_("Auxiliary filter for shared object symbol table"), 129 TWO_DASHES }, 130 { {"filter", required_argument, NULL, 'F'}, 131 'F', N_("SHLIB"), N_("Filter for shared object symbol table"), 132 TWO_DASHES }, 133 { {NULL, no_argument, NULL, '\0'}, 134 'g', NULL, N_("Ignored"), ONE_DASH }, 135 { {"gpsize", required_argument, NULL, 'G'}, 136 'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"), 137 TWO_DASHES }, 138 { {"soname", required_argument, NULL, OPTION_SONAME}, 139 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH }, 140 { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER}, 141 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"), 142 TWO_DASHES }, 143 { {"library", required_argument, NULL, 'l'}, 144 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES }, 145 { {"library-path", required_argument, NULL, 'L'}, 146 'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"), 147 TWO_DASHES }, 148 { {"sysroot=<DIRECTORY>", required_argument, NULL, OPTION_SYSROOT}, 149 '\0', NULL, N_("Override the default sysroot location"), TWO_DASHES }, 150 { {NULL, required_argument, NULL, '\0'}, 151 'm', N_("EMULATION"), N_("Set emulation"), ONE_DASH }, 152 { {"print-map", no_argument, NULL, 'M'}, 153 'M', NULL, N_("Print map file on standard output"), TWO_DASHES }, 154 { {"nmagic", no_argument, NULL, 'n'}, 155 'n', NULL, N_("Do not page align data"), TWO_DASHES }, 156 { {"omagic", no_argument, NULL, 'N'}, 157 'N', NULL, N_("Do not page align data, do not make text readonly"), 158 EXACTLY_TWO_DASHES }, 159 { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC}, 160 '\0', NULL, N_("Page align data, make text readonly"), 161 EXACTLY_TWO_DASHES }, 162 { {"output", required_argument, NULL, 'o'}, 163 'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES }, 164 { {NULL, required_argument, NULL, '\0'}, 165 'O', NULL, N_("Optimize output file"), ONE_DASH }, 166 #ifdef ENABLE_PLUGINS 167 { {"plugin", required_argument, NULL, OPTION_PLUGIN}, 168 '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH }, 169 { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT}, 170 '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH }, 171 { {"flto", optional_argument, NULL, OPTION_IGNORE}, 172 '\0', NULL, N_("Ignored for GCC LTO option compatibility"), 173 ONE_DASH }, 174 { {"flto-partition=", required_argument, NULL, OPTION_IGNORE}, 175 '\0', NULL, N_("Ignored for GCC LTO option compatibility"), 176 ONE_DASH }, 177 #endif /* ENABLE_PLUGINS */ 178 { {"Qy", no_argument, NULL, OPTION_IGNORE}, 179 '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH }, 180 { {"emit-relocs", no_argument, NULL, 'q'}, 181 'q', NULL, "Generate relocations in final output", TWO_DASHES }, 182 { {"relocatable", no_argument, NULL, 'r'}, 183 'r', NULL, N_("Generate relocatable output"), TWO_DASHES }, 184 { {NULL, no_argument, NULL, '\0'}, 185 'i', NULL, NULL, ONE_DASH }, 186 { {"just-symbols", required_argument, NULL, 'R'}, 187 'R', N_("FILE"), N_("Just link symbols (if directory, same as --rpath)"), 188 TWO_DASHES }, 189 { {"strip-all", no_argument, NULL, 's'}, 190 's', NULL, N_("Strip all symbols"), TWO_DASHES }, 191 { {"strip-debug", no_argument, NULL, 'S'}, 192 'S', NULL, N_("Strip debugging symbols"), TWO_DASHES }, 193 { {"strip-discarded", no_argument, NULL, OPTION_STRIP_DISCARDED}, 194 '\0', NULL, N_("Strip symbols in discarded sections"), TWO_DASHES }, 195 { {"no-strip-discarded", no_argument, NULL, OPTION_NO_STRIP_DISCARDED}, 196 '\0', NULL, N_("Do not strip symbols in discarded sections"), TWO_DASHES }, 197 { {"trace", no_argument, NULL, 't'}, 198 't', NULL, N_("Trace file opens"), TWO_DASHES }, 199 { {"script", required_argument, NULL, 'T'}, 200 'T', N_("FILE"), N_("Read linker script"), TWO_DASHES }, 201 { {"default-script", required_argument, NULL, OPTION_DEFAULT_SCRIPT}, 202 '\0', N_("FILE"), N_("Read default linker script"), TWO_DASHES }, 203 { {"dT", required_argument, NULL, OPTION_DEFAULT_SCRIPT}, 204 '\0', NULL, NULL, ONE_DASH }, 205 { {"undefined", required_argument, NULL, 'u'}, 206 'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"), 207 TWO_DASHES }, 208 { {"unique", optional_argument, NULL, OPTION_UNIQUE}, 209 '\0', N_("[=SECTION]"), 210 N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES }, 211 { {"Ur", no_argument, NULL, OPTION_UR}, 212 '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH }, 213 { {"version", no_argument, NULL, OPTION_VERSION}, 214 'v', NULL, N_("Print version information"), TWO_DASHES }, 215 { {NULL, no_argument, NULL, '\0'}, 216 'V', NULL, N_("Print version and emulation information"), ONE_DASH }, 217 { {"discard-all", no_argument, NULL, 'x'}, 218 'x', NULL, N_("Discard all local symbols"), TWO_DASHES }, 219 { {"discard-locals", no_argument, NULL, 'X'}, 220 'X', NULL, N_("Discard temporary local symbols (default)"), TWO_DASHES }, 221 { {"discard-none", no_argument, NULL, OPTION_DISCARD_NONE}, 222 '\0', NULL, N_("Don't discard any local symbols"), TWO_DASHES }, 223 { {"trace-symbol", required_argument, NULL, 'y'}, 224 'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES }, 225 { {NULL, required_argument, NULL, '\0'}, 226 'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), 227 ONE_DASH }, 228 { {"start-group", no_argument, NULL, '('}, 229 '(', NULL, N_("Start a group"), TWO_DASHES }, 230 { {"end-group", no_argument, NULL, ')'}, 231 ')', NULL, N_("End a group"), TWO_DASHES }, 232 { {"accept-unknown-input-arch", no_argument, NULL, 233 OPTION_ACCEPT_UNKNOWN_INPUT_ARCH}, 234 '\0', NULL, 235 N_("Accept input files whose architecture cannot be determined"), 236 TWO_DASHES }, 237 { {"no-accept-unknown-input-arch", no_argument, NULL, 238 OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH}, 239 '\0', NULL, N_("Reject input files whose architecture is unknown"), 240 TWO_DASHES }, 241 242 /* The next two options are deprecated because of their similarity to 243 --as-needed and --no-as-needed. They have been replaced by 244 --copy-dt-needed-entries and --no-copy-dt-needed-entries. */ 245 { {"add-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC}, 246 '\0', NULL, NULL, NO_HELP }, 247 { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC}, 248 '\0', NULL, NULL, NO_HELP }, 249 250 { {"as-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_REGULAR}, 251 '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"), 252 TWO_DASHES }, 253 { {"no-as-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR}, 254 '\0', NULL, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n" 255 " the command line"), 256 TWO_DASHES }, 257 { {"assert", required_argument, NULL, OPTION_ASSERT}, 258 '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH }, 259 { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED}, 260 '\0', NULL, N_("Link against shared libraries"), ONE_DASH }, 261 { {"dy", no_argument, NULL, OPTION_CALL_SHARED}, 262 '\0', NULL, NULL, ONE_DASH }, 263 { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED}, 264 '\0', NULL, NULL, ONE_DASH }, 265 { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED}, 266 '\0', NULL, N_("Do not link against shared libraries"), ONE_DASH }, 267 { {"dn", no_argument, NULL, OPTION_NON_SHARED}, 268 '\0', NULL, NULL, ONE_DASH }, 269 { {"non_shared", no_argument, NULL, OPTION_NON_SHARED}, 270 '\0', NULL, NULL, ONE_DASH }, 271 { {"static", no_argument, NULL, OPTION_NON_SHARED}, 272 '\0', NULL, NULL, ONE_DASH }, 273 { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC}, 274 '\0', NULL, N_("Bind global references locally"), ONE_DASH }, 275 { {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS}, 276 '\0', NULL, N_("Bind global function references locally"), ONE_DASH }, 277 { {"check-sections", no_argument, NULL, OPTION_CHECK_SECTIONS}, 278 '\0', NULL, N_("Check section addresses for overlaps (default)"), 279 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 { {"copy-dt-needed-entries", no_argument, NULL, 284 OPTION_ADD_DT_NEEDED_FOR_DYNAMIC}, 285 '\0', NULL, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"), 286 TWO_DASHES }, 287 { {"no-copy-dt-needed-entries", no_argument, NULL, 288 OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC}, 289 '\0', NULL, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"), 290 TWO_DASHES }, 291 292 { {"cref", no_argument, NULL, OPTION_CREF}, 293 '\0', NULL, N_("Output cross reference table"), TWO_DASHES }, 294 { {"defsym", required_argument, NULL, OPTION_DEFSYM}, 295 '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES }, 296 { {"demangle", optional_argument, NULL, OPTION_DEMANGLE}, 297 '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), 298 TWO_DASHES }, 299 { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS}, 300 '\0', NULL, N_("Generate embedded relocs"), TWO_DASHES}, 301 { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}, 302 '\0', NULL, N_("Treat warnings as errors"), 303 TWO_DASHES }, 304 { {"no-fatal-warnings", no_argument, NULL, OPTION_NO_WARN_FATAL}, 305 '\0', NULL, N_("Do not treat warnings as errors (default)"), 306 TWO_DASHES }, 307 { {"fini", required_argument, NULL, OPTION_FINI}, 308 '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH }, 309 { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX}, 310 '\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES}, 311 { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS}, 312 '\0', NULL, N_("Remove unused sections (on some targets)"), 313 TWO_DASHES }, 314 { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS}, 315 '\0', NULL, N_("Don't remove unused sections (default)"), 316 TWO_DASHES }, 317 { {"print-gc-sections", no_argument, NULL, OPTION_PRINT_GC_SECTIONS}, 318 '\0', NULL, N_("List removed unused sections on stderr"), 319 TWO_DASHES }, 320 { {"no-print-gc-sections", no_argument, NULL, OPTION_NO_PRINT_GC_SECTIONS}, 321 '\0', NULL, N_("Do not list removed unused sections"), 322 TWO_DASHES }, 323 { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE}, 324 '\0', NULL, N_("Set default hash table size close to <NUMBER>"), 325 TWO_DASHES }, 326 { {"help", no_argument, NULL, OPTION_HELP}, 327 '\0', NULL, N_("Print option help"), TWO_DASHES }, 328 { {"init", required_argument, NULL, OPTION_INIT}, 329 '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH }, 330 { {"Map", required_argument, NULL, OPTION_MAP}, 331 '\0', N_("FILE"), N_("Write a map file"), ONE_DASH }, 332 { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON}, 333 '\0', NULL, N_("Do not define Common storage"), TWO_DASHES }, 334 { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE }, 335 '\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES }, 336 { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY}, 337 '\0', NULL, N_("Use less memory and more disk I/O"), TWO_DASHES }, 338 { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED}, 339 '\0', NULL, N_("Do not allow unresolved references in object files"), 340 TWO_DASHES }, 341 { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED}, 342 '\0', NULL, N_("Allow unresolved references in shared libraries"), 343 TWO_DASHES }, 344 { {"no-allow-shlib-undefined", no_argument, NULL, 345 OPTION_NO_ALLOW_SHLIB_UNDEFINED}, 346 '\0', NULL, N_("Do not allow unresolved references in shared libs"), 347 TWO_DASHES }, 348 { {"allow-multiple-definition", no_argument, NULL, 349 OPTION_ALLOW_MULTIPLE_DEFINITION}, 350 '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES }, 351 { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION}, 352 '\0', NULL, N_("Disallow undefined version"), TWO_DASHES }, 353 { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER}, 354 '\0', NULL, N_("Create default symbol version"), TWO_DASHES }, 355 { {"default-imported-symver", no_argument, NULL, 356 OPTION_DEFAULT_IMPORTED_SYMVER}, 357 '\0', NULL, N_("Create default symbol version for imported symbols"), 358 TWO_DASHES }, 359 { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH}, 360 '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES}, 361 { {"no-warn-search-mismatch", no_argument, NULL, 362 OPTION_NO_WARN_SEARCH_MISMATCH}, 363 '\0', NULL, N_("Don't warn on finding an incompatible library"), 364 TWO_DASHES}, 365 { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE}, 366 '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES }, 367 { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC}, 368 '\0', NULL, N_("Create an output file even if errors occur"), 369 TWO_DASHES }, 370 { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC}, 371 '\0', NULL, NULL, NO_HELP }, 372 { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB}, 373 '\0', NULL, N_("Only use library directories specified on\n" 374 " the command line"), 375 ONE_DASH }, 376 { {"oformat", required_argument, NULL, OPTION_OFORMAT}, 377 '\0', N_("TARGET"), N_("Specify target of output file"), 378 EXACTLY_TWO_DASHES }, 379 { {"print-output-format", no_argument, NULL, OPTION_PRINT_OUTPUT_FORMAT}, 380 '\0', NULL, N_("Print default output format"), TWO_DASHES }, 381 { {"qmagic", no_argument, NULL, OPTION_IGNORE}, 382 '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH }, 383 { {"reduce-memory-overheads", no_argument, NULL, 384 OPTION_REDUCE_MEMORY_OVERHEADS}, 385 '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"), 386 TWO_DASHES }, 387 { {"relax", no_argument, NULL, OPTION_RELAX}, 388 '\0', NULL, N_("Reduce code size by using target specific optimizations"), TWO_DASHES }, 389 { {"no-relax", no_argument, NULL, OPTION_NO_RELAX}, 390 '\0', NULL, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES }, 391 { {"retain-symbols-file", required_argument, NULL, 392 OPTION_RETAIN_SYMBOLS_FILE}, 393 '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES }, 394 { {"rpath", required_argument, NULL, OPTION_RPATH}, 395 '\0', N_("PATH"), N_("Set runtime shared library search path"), ONE_DASH }, 396 { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK}, 397 '\0', N_("PATH"), N_("Set link time shared library search path"), 398 ONE_DASH }, 399 { {"shared", no_argument, NULL, OPTION_SHARED}, 400 '\0', NULL, N_("Create a shared library"), ONE_DASH }, 401 { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD, NetBSD. */ 402 '\0', NULL, NULL, ONE_DASH }, 403 { {"pie", no_argument, NULL, OPTION_PIE}, 404 '\0', NULL, N_("Create a position independent executable"), ONE_DASH }, 405 { {"pic-executable", no_argument, NULL, OPTION_PIE}, 406 '\0', NULL, NULL, TWO_DASHES }, 407 { {"sort-common", optional_argument, NULL, OPTION_SORT_COMMON}, 408 '\0', N_("[=ascending|descending]"), 409 N_("Sort common symbols by alignment [in specified order]"), 410 TWO_DASHES }, 411 { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON}, 412 '\0', NULL, NULL, NO_HELP }, 413 { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION}, 414 '\0', N_("name|alignment"), 415 N_("Sort sections by name or maximum alignment"), TWO_DASHES }, 416 { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS}, 417 '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"), 418 TWO_DASHES }, 419 { {"split-by-file", optional_argument, NULL, OPTION_SPLIT_BY_FILE}, 420 '\0', N_("[=SIZE]"), N_("Split output sections every SIZE octets"), 421 TWO_DASHES }, 422 { {"split-by-reloc", optional_argument, NULL, OPTION_SPLIT_BY_RELOC}, 423 '\0', N_("[=COUNT]"), N_("Split output sections every COUNT relocs"), 424 TWO_DASHES }, 425 { {"stats", no_argument, NULL, OPTION_STATS}, 426 '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES }, 427 { {"target-help", no_argument, NULL, OPTION_TARGET_HELP}, 428 '\0', NULL, N_("Display target specific options"), TWO_DASHES }, 429 { {"task-link", required_argument, NULL, OPTION_TASK_LINK}, 430 '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES }, 431 { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT}, 432 '\0', NULL, N_("Use same format as native linker"), TWO_DASHES }, 433 { {"section-start", required_argument, NULL, OPTION_SECTION_START}, 434 '\0', N_("SECTION=ADDRESS"), N_("Set address of named section"), 435 TWO_DASHES }, 436 { {"Tbss", required_argument, NULL, OPTION_TBSS}, 437 '\0', N_("ADDRESS"), N_("Set address of .bss section"), ONE_DASH }, 438 { {"Tdata", required_argument, NULL, OPTION_TDATA}, 439 '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH }, 440 { {"Ttext", required_argument, NULL, OPTION_TTEXT}, 441 '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH }, 442 { {"Ttext-segment", required_argument, NULL, OPTION_TTEXT_SEGMENT}, 443 '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH }, 444 { {"Trodata-segment", required_argument, NULL, OPTION_TRODATA_SEGMENT}, 445 '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH }, 446 { {"unresolved-symbols=<method>", required_argument, NULL, 447 OPTION_UNRESOLVED_SYMBOLS}, 448 '\0', NULL, N_("How to handle unresolved symbols. <method> is:\n" 449 " ignore-all, report-all, ignore-in-object-files,\n" 450 " ignore-in-shared-libs"), 451 TWO_DASHES }, 452 { {"verbose", optional_argument, NULL, OPTION_VERBOSE}, 453 '\0', N_("[=NUMBER]"), 454 N_("Output lots of information during link"), TWO_DASHES }, 455 { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */ 456 '\0', NULL, NULL, NO_HELP }, 457 { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT }, 458 '\0', N_("FILE"), N_("Read version information script"), TWO_DASHES }, 459 { {"version-exports-section", required_argument, NULL, 460 OPTION_VERSION_EXPORTS_SECTION }, 461 '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n" 462 " SYMBOL as the version."), 463 TWO_DASHES }, 464 { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA}, 465 '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES }, 466 { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW}, 467 '\0', NULL, N_("Use C++ operator new/delete dynamic list"), TWO_DASHES }, 468 { {"dynamic-list-cpp-typeinfo", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_TYPEINFO}, 469 '\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES }, 470 { {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST}, 471 '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES }, 472 { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON}, 473 '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES }, 474 { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS}, 475 '\0', NULL, N_("Warn if global constructors/destructors are seen"), 476 TWO_DASHES }, 477 { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP}, 478 '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES }, 479 { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE}, 480 '\0', NULL, N_("Warn only once per undefined symbol"), TWO_DASHES }, 481 { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN}, 482 '\0', NULL, N_("Warn if start of section changes due to alignment"), 483 TWO_DASHES }, 484 { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_SHARED_TEXTREL}, 485 '\0', NULL, N_("Warn if shared object has DT_TEXTREL"), 486 TWO_DASHES }, 487 { {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM}, 488 '\0', NULL, N_("Warn if an object has alternate ELF machine code"), 489 TWO_DASHES }, 490 { {"warn-unresolved-symbols", no_argument, NULL, 491 OPTION_WARN_UNRESOLVED_SYMBOLS}, 492 '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES }, 493 { {"error-unresolved-symbols", no_argument, NULL, 494 OPTION_ERROR_UNRESOLVED_SYMBOLS}, 495 '\0', NULL, N_("Report unresolved symbols as errors"), TWO_DASHES }, 496 { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE}, 497 '\0', NULL, N_("Include all objects from following archives"), 498 TWO_DASHES }, 499 { {"Bforcearchive", no_argument, NULL, OPTION_WHOLE_ARCHIVE}, 500 '\0', NULL, NULL, TWO_DASHES }, /* NetBSD. */ 501 { {"wrap", required_argument, NULL, OPTION_WRAP}, 502 '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES }, 503 { {"ignore-unresolved-symbol", required_argument, NULL, 504 OPTION_IGNORE_UNRESOLVED_SYMBOL}, 505 '\0', N_("SYMBOL"), 506 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES }, 507 }; 508 509 #define OPTION_COUNT ARRAY_SIZE (ld_options) 510 511 void 512 parse_args (unsigned argc, char **argv) 513 { 514 unsigned i; 515 int is, il, irl; 516 int ingroup = 0; 517 char *default_dirlist = NULL; 518 char *shortopts; 519 struct option *longopts; 520 struct option *really_longopts; 521 int last_optind; 522 enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR; 523 524 shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2); 525 longopts = (struct option *) 526 xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1)); 527 really_longopts = (struct option *) 528 malloc (sizeof (*really_longopts) * (OPTION_COUNT + 1)); 529 530 /* Starting the short option string with '-' is for programs that 531 expect options and other ARGV-elements in any order and that care about 532 the ordering of the two. We describe each non-option ARGV-element 533 as if it were the argument of an option with character code 1. */ 534 shortopts[0] = '-'; 535 is = 1; 536 il = 0; 537 irl = 0; 538 for (i = 0; i < OPTION_COUNT; i++) 539 { 540 if (ld_options[i].shortopt != '\0') 541 { 542 shortopts[is] = ld_options[i].shortopt; 543 ++is; 544 if (ld_options[i].opt.has_arg == required_argument 545 || ld_options[i].opt.has_arg == optional_argument) 546 { 547 shortopts[is] = ':'; 548 ++is; 549 if (ld_options[i].opt.has_arg == optional_argument) 550 { 551 shortopts[is] = ':'; 552 ++is; 553 } 554 } 555 } 556 if (ld_options[i].opt.name != NULL) 557 { 558 if (ld_options[i].control == EXACTLY_TWO_DASHES) 559 { 560 really_longopts[irl] = ld_options[i].opt; 561 ++irl; 562 } 563 else 564 { 565 longopts[il] = ld_options[i].opt; 566 ++il; 567 } 568 } 569 } 570 shortopts[is] = '\0'; 571 longopts[il].name = NULL; 572 really_longopts[irl].name = NULL; 573 574 ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts); 575 576 /* The -G option is ambiguous on different platforms. Sometimes it 577 specifies the largest data size to put into the small data 578 section. Sometimes it is equivalent to --shared. Unfortunately, 579 the first form takes an argument, while the second does not. 580 581 We need to permit the --shared form because on some platforms, 582 such as Solaris, gcc -shared will pass -G to the linker. 583 584 To permit either usage, we look through the argument list. If we 585 find -G not followed by a number, we change it into --shared. 586 This will work for most normal cases. */ 587 for (i = 1; i < argc; i++) 588 if (strcmp (argv[i], "-G") == 0 589 && (i + 1 >= argc 590 || ! ISDIGIT (argv[i + 1][0]))) 591 argv[i] = (char *) "--shared"; 592 593 /* Because we permit long options to start with a single dash, and 594 we have a --library option, and the -l option is conventionally 595 used with an immediately following argument, we can have bad 596 results if somebody tries to use -l with a library whose name 597 happens to start with "ibrary", as in -li. We avoid problems by 598 simply turning -l into --library. This means that users will 599 have to use two dashes in order to use --library, which is OK 600 since that's how it is documented. 601 602 FIXME: It's possible that this problem can arise for other short 603 options as well, although the user does always have the recourse 604 of adding a space between the option and the argument. */ 605 for (i = 1; i < argc; i++) 606 { 607 if (argv[i][0] == '-' 608 && argv[i][1] == 'l' 609 && argv[i][2] != '\0') 610 { 611 char *n; 612 613 n = (char *) xmalloc (strlen (argv[i]) + 20); 614 sprintf (n, "--library=%s", argv[i] + 2); 615 argv[i] = n; 616 } 617 } 618 619 last_optind = -1; 620 while (1) 621 { 622 int longind; 623 int optc; 624 static unsigned int defsym_count; 625 626 /* Using last_optind lets us avoid calling ldemul_parse_args 627 multiple times on a single option, which would lead to 628 confusion in the internal static variables maintained by 629 getopt. This could otherwise happen for an argument like 630 -nx, in which the -n is parsed as a single option, and we 631 loop around to pick up the -x. */ 632 if (optind != last_optind) 633 if (ldemul_parse_args (argc, argv)) 634 continue; 635 636 /* getopt_long_only is like getopt_long, but '-' as well as '--' 637 can indicate a long option. */ 638 opterr = 0; 639 last_optind = optind; 640 optc = getopt_long_only (argc, argv, shortopts, longopts, &longind); 641 if (optc == '?') 642 { 643 optind = last_optind; 644 optc = getopt_long (argc, argv, "-", really_longopts, &longind); 645 } 646 647 if (ldemul_handle_option (optc)) 648 continue; 649 650 if (optc == -1) 651 break; 652 653 switch (optc) 654 { 655 case '?': 656 einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]); 657 /* Fall through. */ 658 659 default: 660 einfo (_("%P%F: use the --help option for usage information\n")); 661 662 case 1: /* File name. */ 663 lang_add_input_file (optarg, lang_input_file_is_file_enum, NULL); 664 break; 665 666 case OPTION_IGNORE: 667 break; 668 case 'a': 669 /* For HP/UX compatibility. Actually -a shared should mean 670 ``use only shared libraries'' but, then, we don't 671 currently support shared libraries on HP/UX anyhow. */ 672 if (strcmp (optarg, "archive") == 0) 673 input_flags.dynamic = FALSE; 674 else if (strcmp (optarg, "shared") == 0 675 || strcmp (optarg, "default") == 0) 676 input_flags.dynamic = TRUE; 677 else 678 einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg); 679 break; 680 case OPTION_ASSERT: 681 /* FIXME: We just ignore these, but we should handle them. */ 682 if (strcmp (optarg, "definitions") == 0) 683 ; 684 else if (strcmp (optarg, "nodefinitions") == 0) 685 ; 686 else if (strcmp (optarg, "nosymbolic") == 0) 687 ; 688 else if (strcmp (optarg, "pure-text") == 0) 689 ; 690 else 691 einfo (_("%P%F: unrecognized -assert option `%s'\n"), optarg); 692 break; 693 case 'A': 694 ldfile_add_arch (optarg); 695 break; 696 case 'b': 697 lang_add_target (optarg); 698 break; 699 case 'c': 700 ldfile_open_command_file (optarg); 701 parser_input = input_mri_script; 702 yyparse (); 703 break; 704 case OPTION_CALL_SHARED: 705 input_flags.dynamic = TRUE; 706 break; 707 case OPTION_NON_SHARED: 708 input_flags.dynamic = FALSE; 709 break; 710 case OPTION_CREF: 711 command_line.cref = TRUE; 712 link_info.notice_all = TRUE; 713 break; 714 case 'd': 715 command_line.force_common_definition = TRUE; 716 break; 717 case OPTION_DEFSYM: 718 lex_string = optarg; 719 lex_redirect (optarg, "--defsym", ++defsym_count); 720 parser_input = input_defsym; 721 yyparse (); 722 lex_string = NULL; 723 break; 724 case OPTION_DEMANGLE: 725 demangling = TRUE; 726 if (optarg != NULL) 727 { 728 enum demangling_styles style; 729 730 style = cplus_demangle_name_to_style (optarg); 731 if (style == unknown_demangling) 732 einfo (_("%F%P: unknown demangling style `%s'\n"), 733 optarg); 734 735 cplus_demangle_set_style (style); 736 } 737 break; 738 case 'I': /* Used on Solaris. */ 739 case OPTION_DYNAMIC_LINKER: 740 command_line.interpreter = optarg; 741 break; 742 case OPTION_SYSROOT: 743 /* Already handled in ldmain.c. */ 744 break; 745 case OPTION_EB: 746 command_line.endian = ENDIAN_BIG; 747 break; 748 case OPTION_EL: 749 command_line.endian = ENDIAN_LITTLE; 750 break; 751 case OPTION_EMBEDDED_RELOCS: 752 command_line.embedded_relocs = TRUE; 753 break; 754 case OPTION_EXPORT_DYNAMIC: 755 case 'E': /* HP/UX compatibility. */ 756 link_info.export_dynamic = TRUE; 757 break; 758 case OPTION_NO_EXPORT_DYNAMIC: 759 link_info.export_dynamic = FALSE; 760 break; 761 case 'e': 762 lang_add_entry (optarg, TRUE); 763 break; 764 case 'f': 765 if (command_line.auxiliary_filters == NULL) 766 { 767 command_line.auxiliary_filters = (char **) 768 xmalloc (2 * sizeof (char *)); 769 command_line.auxiliary_filters[0] = optarg; 770 command_line.auxiliary_filters[1] = NULL; 771 } 772 else 773 { 774 int c; 775 char **p; 776 777 c = 0; 778 for (p = command_line.auxiliary_filters; *p != NULL; p++) 779 ++c; 780 command_line.auxiliary_filters = (char **) 781 xrealloc (command_line.auxiliary_filters, 782 (c + 2) * sizeof (char *)); 783 command_line.auxiliary_filters[c] = optarg; 784 command_line.auxiliary_filters[c + 1] = NULL; 785 } 786 break; 787 case 'F': 788 command_line.filter_shlib = optarg; 789 break; 790 case OPTION_FORCE_EXE_SUFFIX: 791 command_line.force_exe_suffix = TRUE; 792 break; 793 case 'G': 794 { 795 char *end; 796 g_switch_value = strtoul (optarg, &end, 0); 797 if (*end) 798 einfo (_("%P%F: invalid number `%s'\n"), optarg); 799 } 800 break; 801 case 'g': 802 /* Ignore. */ 803 break; 804 case OPTION_GC_SECTIONS: 805 link_info.gc_sections = TRUE; 806 break; 807 case OPTION_PRINT_GC_SECTIONS: 808 link_info.print_gc_sections = TRUE; 809 break; 810 case OPTION_HELP: 811 help (); 812 xexit (0); 813 break; 814 case 'L': 815 ldfile_add_library_path (optarg, TRUE); 816 break; 817 case 'l': 818 lang_add_input_file (optarg, lang_input_file_is_l_enum, NULL); 819 break; 820 case 'M': 821 config.map_filename = "-"; 822 break; 823 case 'm': 824 /* Ignore. Was handled in a pre-parse. */ 825 break; 826 case OPTION_MAP: 827 config.map_filename = optarg; 828 break; 829 case 'N': 830 config.text_read_only = FALSE; 831 config.magic_demand_paged = FALSE; 832 input_flags.dynamic = FALSE; 833 break; 834 case OPTION_NO_OMAGIC: 835 config.text_read_only = TRUE; 836 config.magic_demand_paged = TRUE; 837 /* NB/ Does not set input_flags.dynamic to TRUE. 838 Use --call-shared or -Bdynamic for this. */ 839 break; 840 case 'n': 841 config.magic_demand_paged = FALSE; 842 input_flags.dynamic = FALSE; 843 break; 844 case OPTION_NO_DEFINE_COMMON: 845 command_line.inhibit_common_definition = TRUE; 846 break; 847 case OPTION_NO_DEMANGLE: 848 demangling = FALSE; 849 break; 850 case OPTION_NO_GC_SECTIONS: 851 link_info.gc_sections = FALSE; 852 break; 853 case OPTION_NO_PRINT_GC_SECTIONS: 854 link_info.print_gc_sections = FALSE; 855 break; 856 case OPTION_NO_KEEP_MEMORY: 857 link_info.keep_memory = FALSE; 858 break; 859 case OPTION_NO_UNDEFINED: 860 link_info.unresolved_syms_in_objects 861 = how_to_report_unresolved_symbols; 862 break; 863 case OPTION_ALLOW_SHLIB_UNDEFINED: 864 link_info.unresolved_syms_in_shared_libs = RM_IGNORE; 865 break; 866 case OPTION_NO_ALLOW_SHLIB_UNDEFINED: 867 link_info.unresolved_syms_in_shared_libs 868 = how_to_report_unresolved_symbols; 869 break; 870 case OPTION_UNRESOLVED_SYMBOLS: 871 if (strcmp (optarg, "ignore-all") == 0) 872 { 873 link_info.unresolved_syms_in_objects = RM_IGNORE; 874 link_info.unresolved_syms_in_shared_libs = RM_IGNORE; 875 } 876 else if (strcmp (optarg, "report-all") == 0) 877 { 878 link_info.unresolved_syms_in_objects 879 = how_to_report_unresolved_symbols; 880 link_info.unresolved_syms_in_shared_libs 881 = how_to_report_unresolved_symbols; 882 } 883 else if (strcmp (optarg, "ignore-in-object-files") == 0) 884 { 885 link_info.unresolved_syms_in_objects = RM_IGNORE; 886 link_info.unresolved_syms_in_shared_libs 887 = how_to_report_unresolved_symbols; 888 } 889 else if (strcmp (optarg, "ignore-in-shared-libs") == 0) 890 { 891 link_info.unresolved_syms_in_objects 892 = how_to_report_unresolved_symbols; 893 link_info.unresolved_syms_in_shared_libs = RM_IGNORE; 894 } 895 else 896 einfo (_("%P%F: bad --unresolved-symbols option: %s\n"), optarg); 897 break; 898 case OPTION_WARN_UNRESOLVED_SYMBOLS: 899 how_to_report_unresolved_symbols = RM_GENERATE_WARNING; 900 if (link_info.unresolved_syms_in_objects == RM_GENERATE_ERROR) 901 link_info.unresolved_syms_in_objects = RM_GENERATE_WARNING; 902 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_ERROR) 903 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_WARNING; 904 break; 905 906 case OPTION_ERROR_UNRESOLVED_SYMBOLS: 907 how_to_report_unresolved_symbols = RM_GENERATE_ERROR; 908 if (link_info.unresolved_syms_in_objects == RM_GENERATE_WARNING) 909 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR; 910 if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_WARNING) 911 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR; 912 break; 913 case OPTION_ALLOW_MULTIPLE_DEFINITION: 914 link_info.allow_multiple_definition = TRUE; 915 break; 916 case OPTION_NO_UNDEFINED_VERSION: 917 link_info.allow_undefined_version = FALSE; 918 break; 919 case OPTION_DEFAULT_SYMVER: 920 link_info.create_default_symver = TRUE; 921 break; 922 case OPTION_DEFAULT_IMPORTED_SYMVER: 923 link_info.default_imported_symver = TRUE; 924 break; 925 case OPTION_NO_WARN_MISMATCH: 926 command_line.warn_mismatch = FALSE; 927 break; 928 case OPTION_NO_WARN_SEARCH_MISMATCH: 929 command_line.warn_search_mismatch = FALSE; 930 break; 931 case OPTION_NOINHIBIT_EXEC: 932 force_make_executable = TRUE; 933 break; 934 case OPTION_NOSTDLIB: 935 config.only_cmd_line_lib_dirs = TRUE; 936 break; 937 case OPTION_NO_WHOLE_ARCHIVE: 938 input_flags.whole_archive = FALSE; 939 break; 940 case 'O': 941 /* FIXME "-O<non-digits> <value>" used to set the address of 942 section <non-digits>. Was this for compatibility with 943 something, or can we create a new option to do that 944 (with a syntax similar to -defsym)? 945 getopt can't handle two args to an option without kludges. */ 946 947 /* Enable optimizations of output files. */ 948 link_info.optimize = strtoul (optarg, NULL, 0) ? TRUE : FALSE; 949 break; 950 case 'o': 951 lang_add_output (optarg, 0); 952 break; 953 case OPTION_OFORMAT: 954 lang_add_output_format (optarg, NULL, NULL, 0); 955 break; 956 case OPTION_PRINT_OUTPUT_FORMAT: 957 command_line.print_output_format = TRUE; 958 break; 959 #ifdef ENABLE_PLUGINS 960 case OPTION_PLUGIN: 961 plugin_opt_plugin (optarg); 962 break; 963 case OPTION_PLUGIN_OPT: 964 if (plugin_opt_plugin_arg (optarg)) 965 einfo(_("%P%F: bad -plugin-opt option\n")); 966 break; 967 #endif /* ENABLE_PLUGINS */ 968 case 'q': 969 link_info.emitrelocations = TRUE; 970 break; 971 case 'i': 972 case 'r': 973 if (optind == last_optind) 974 /* This can happen if the user put "-rpath,a" on the command 975 line. (Or something similar. The comma is important). 976 Getopt becomes confused and thinks that this is a -r option 977 but it cannot parse the text after the -r so it refuses to 978 increment the optind counter. Detect this case and issue 979 an error message here. We cannot just make this a warning, 980 increment optind, and continue because getopt is too confused 981 and will seg-fault the next time around. */ 982 einfo(_("%P%F: bad -rpath option\n")); 983 984 link_info.relocatable = TRUE; 985 config.build_constructors = FALSE; 986 config.magic_demand_paged = FALSE; 987 config.text_read_only = FALSE; 988 input_flags.dynamic = FALSE; 989 break; 990 case 'R': 991 /* The GNU linker traditionally uses -R to mean to include 992 only the symbols from a file. The Solaris linker uses -R 993 to set the path used by the runtime linker to find 994 libraries. This is the GNU linker -rpath argument. We 995 try to support both simultaneously by checking the file 996 named. If it is a directory, rather than a regular file, 997 we assume -rpath was meant. */ 998 { 999 struct stat s; 1000 1001 if (stat (optarg, &s) >= 0 1002 && ! S_ISDIR (s.st_mode)) 1003 { 1004 lang_add_input_file (optarg, 1005 lang_input_file_is_symbols_only_enum, 1006 NULL); 1007 break; 1008 } 1009 } 1010 /* Fall through. */ 1011 case OPTION_RPATH: 1012 if (command_line.rpath == NULL) 1013 command_line.rpath = xstrdup (optarg); 1014 else 1015 { 1016 size_t rpath_len = strlen (command_line.rpath); 1017 size_t optarg_len = strlen (optarg); 1018 char *buf; 1019 char *cp = command_line.rpath; 1020 1021 /* First see whether OPTARG is already in the path. */ 1022 do 1023 { 1024 if (strncmp (optarg, cp, optarg_len) == 0 1025 && (cp[optarg_len] == 0 1026 || cp[optarg_len] == config.rpath_separator)) 1027 /* We found it. */ 1028 break; 1029 1030 /* Not yet found. */ 1031 cp = strchr (cp, config.rpath_separator); 1032 if (cp != NULL) 1033 ++cp; 1034 } 1035 while (cp != NULL); 1036 1037 if (cp == NULL) 1038 { 1039 buf = (char *) xmalloc (rpath_len + optarg_len + 2); 1040 sprintf (buf, "%s%c%s", command_line.rpath, 1041 config.rpath_separator, optarg); 1042 free (command_line.rpath); 1043 command_line.rpath = buf; 1044 } 1045 } 1046 break; 1047 case OPTION_RPATH_LINK: 1048 if (command_line.rpath_link == NULL) 1049 command_line.rpath_link = xstrdup (optarg); 1050 else 1051 { 1052 char *buf; 1053 1054 buf = (char *) xmalloc (strlen (command_line.rpath_link) 1055 + strlen (optarg) 1056 + 2); 1057 sprintf (buf, "%s%c%s", command_line.rpath_link, 1058 config.rpath_separator, optarg); 1059 free (command_line.rpath_link); 1060 command_line.rpath_link = buf; 1061 } 1062 break; 1063 case OPTION_NO_RELAX: 1064 DISABLE_RELAXATION; 1065 break; 1066 case OPTION_RELAX: 1067 ENABLE_RELAXATION; 1068 break; 1069 case OPTION_RETAIN_SYMBOLS_FILE: 1070 add_keepsyms_file (optarg); 1071 break; 1072 case 'S': 1073 link_info.strip = strip_debugger; 1074 break; 1075 case 's': 1076 link_info.strip = strip_all; 1077 break; 1078 case OPTION_STRIP_DISCARDED: 1079 link_info.strip_discarded = TRUE; 1080 break; 1081 case OPTION_NO_STRIP_DISCARDED: 1082 link_info.strip_discarded = FALSE; 1083 break; 1084 case OPTION_SHARED: 1085 if (config.has_shared) 1086 { 1087 link_info.shared = TRUE; 1088 /* When creating a shared library, the default 1089 behaviour is to ignore any unresolved references. */ 1090 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET) 1091 link_info.unresolved_syms_in_objects = RM_IGNORE; 1092 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET) 1093 link_info.unresolved_syms_in_shared_libs = RM_IGNORE; 1094 } 1095 else 1096 einfo (_("%P%F: -shared not supported\n")); 1097 break; 1098 case OPTION_PIE: 1099 if (config.has_shared) 1100 { 1101 link_info.shared = TRUE; 1102 link_info.pie = TRUE; 1103 } 1104 else 1105 einfo (_("%P%F: -pie not supported\n")); 1106 break; 1107 case 'h': /* Used on Solaris. */ 1108 case OPTION_SONAME: 1109 command_line.soname = optarg; 1110 break; 1111 case OPTION_SORT_COMMON: 1112 if (optarg == NULL 1113 || strcmp (optarg, N_("descending")) == 0) 1114 config.sort_common = sort_descending; 1115 else if (strcmp (optarg, N_("ascending")) == 0) 1116 config.sort_common = sort_ascending; 1117 else 1118 einfo (_("%P%F: invalid common section sorting option: %s\n"), 1119 optarg); 1120 break; 1121 case OPTION_SORT_SECTION: 1122 if (strcmp (optarg, N_("name")) == 0) 1123 sort_section = by_name; 1124 else if (strcmp (optarg, N_("alignment")) == 0) 1125 sort_section = by_alignment; 1126 else 1127 einfo (_("%P%F: invalid section sorting option: %s\n"), 1128 optarg); 1129 break; 1130 case OPTION_STATS: 1131 config.stats = TRUE; 1132 break; 1133 case OPTION_SYMBOLIC: 1134 command_line.symbolic = symbolic; 1135 break; 1136 case OPTION_SYMBOLIC_FUNCTIONS: 1137 command_line.symbolic = symbolic_functions; 1138 break; 1139 case 't': 1140 trace_files = TRUE; 1141 break; 1142 case 'T': 1143 previous_script_handle = saved_script_handle; 1144 ldfile_open_command_file (optarg); 1145 parser_input = input_script; 1146 yyparse (); 1147 previous_script_handle = NULL; 1148 break; 1149 case OPTION_DEFAULT_SCRIPT: 1150 command_line.default_script = optarg; 1151 break; 1152 case OPTION_SECTION_START: 1153 { 1154 char *optarg2; 1155 char *sec_name; 1156 int len; 1157 1158 /* Check for <something>=<somthing>... */ 1159 optarg2 = strchr (optarg, '='); 1160 if (optarg2 == NULL) 1161 einfo (_("%P%F: invalid argument to option" 1162 " \"--section-start\"\n")); 1163 1164 optarg2++; 1165 1166 /* So far so good. Are all the args present? */ 1167 if ((*optarg == '\0') || (*optarg2 == '\0')) 1168 einfo (_("%P%F: missing argument(s) to option" 1169 " \"--section-start\"\n")); 1170 1171 /* We must copy the section name as set_section_start 1172 doesn't do it for us. */ 1173 len = optarg2 - optarg; 1174 sec_name = (char *) xmalloc (len); 1175 memcpy (sec_name, optarg, len - 1); 1176 sec_name[len - 1] = 0; 1177 1178 /* Then set it... */ 1179 set_section_start (sec_name, optarg2); 1180 } 1181 break; 1182 case OPTION_TARGET_HELP: 1183 /* Mention any target specific options. */ 1184 ldemul_list_emulation_options (stdout); 1185 exit (0); 1186 case OPTION_TBSS: 1187 set_segment_start (".bss", optarg); 1188 break; 1189 case OPTION_TDATA: 1190 set_segment_start (".data", optarg); 1191 break; 1192 case OPTION_TTEXT: 1193 set_segment_start (".text", optarg); 1194 break; 1195 case OPTION_TTEXT_SEGMENT: 1196 set_segment_start (".text-segment", optarg); 1197 break; 1198 case OPTION_TRODATA_SEGMENT: 1199 set_segment_start (".rodata-segment", optarg); 1200 break; 1201 case OPTION_TRADITIONAL_FORMAT: 1202 link_info.traditional_format = TRUE; 1203 break; 1204 case OPTION_TASK_LINK: 1205 link_info.task_link = TRUE; 1206 /* Fall through - do an implied -r option. */ 1207 case OPTION_UR: 1208 link_info.relocatable = TRUE; 1209 config.build_constructors = TRUE; 1210 config.magic_demand_paged = FALSE; 1211 config.text_read_only = FALSE; 1212 input_flags.dynamic = FALSE; 1213 break; 1214 case 'u': 1215 ldlang_add_undef (optarg, TRUE); 1216 break; 1217 case OPTION_UNIQUE: 1218 if (optarg != NULL) 1219 lang_add_unique (optarg); 1220 else 1221 config.unique_orphan_sections = TRUE; 1222 break; 1223 case OPTION_VERBOSE: 1224 ldversion (1); 1225 version_printed = TRUE; 1226 verbose = TRUE; 1227 overflow_cutoff_limit = -2; 1228 if (optarg != NULL) 1229 { 1230 char *end; 1231 int level ATTRIBUTE_UNUSED = strtoul (optarg, &end, 0); 1232 if (*end) 1233 einfo (_("%P%F: invalid number `%s'\n"), optarg); 1234 #ifdef ENABLE_PLUGINS 1235 report_plugin_symbols = level > 1; 1236 #endif /* ENABLE_PLUGINS */ 1237 } 1238 break; 1239 case 'v': 1240 ldversion (0); 1241 version_printed = TRUE; 1242 break; 1243 case 'V': 1244 ldversion (1); 1245 version_printed = TRUE; 1246 break; 1247 case OPTION_VERSION: 1248 ldversion (2); 1249 xexit (0); 1250 break; 1251 case OPTION_VERSION_SCRIPT: 1252 /* This option indicates a small script that only specifies 1253 version information. Read it, but don't assume that 1254 we've seen a linker script. */ 1255 { 1256 FILE *hold_script_handle; 1257 1258 hold_script_handle = saved_script_handle; 1259 ldfile_open_command_file (optarg); 1260 saved_script_handle = hold_script_handle; 1261 parser_input = input_version_script; 1262 yyparse (); 1263 } 1264 break; 1265 case OPTION_VERSION_EXPORTS_SECTION: 1266 /* This option records a version symbol to be applied to the 1267 symbols listed for export to be found in the object files 1268 .exports sections. */ 1269 command_line.version_exports_section = optarg; 1270 break; 1271 case OPTION_DYNAMIC_LIST_DATA: 1272 command_line.dynamic_list = dynamic_list_data; 1273 if (command_line.symbolic == symbolic) 1274 command_line.symbolic = symbolic_unset; 1275 break; 1276 case OPTION_DYNAMIC_LIST_CPP_TYPEINFO: 1277 lang_append_dynamic_list_cpp_typeinfo (); 1278 if (command_line.dynamic_list != dynamic_list_data) 1279 command_line.dynamic_list = dynamic_list; 1280 if (command_line.symbolic == symbolic) 1281 command_line.symbolic = symbolic_unset; 1282 break; 1283 case OPTION_DYNAMIC_LIST_CPP_NEW: 1284 lang_append_dynamic_list_cpp_new (); 1285 if (command_line.dynamic_list != dynamic_list_data) 1286 command_line.dynamic_list = dynamic_list; 1287 if (command_line.symbolic == symbolic) 1288 command_line.symbolic = symbolic_unset; 1289 break; 1290 case OPTION_DYNAMIC_LIST: 1291 /* This option indicates a small script that only specifies 1292 a dynamic list. Read it, but don't assume that we've 1293 seen a linker script. */ 1294 { 1295 FILE *hold_script_handle; 1296 1297 hold_script_handle = saved_script_handle; 1298 ldfile_open_command_file (optarg); 1299 saved_script_handle = hold_script_handle; 1300 parser_input = input_dynamic_list; 1301 yyparse (); 1302 } 1303 if (command_line.dynamic_list != dynamic_list_data) 1304 command_line.dynamic_list = dynamic_list; 1305 if (command_line.symbolic == symbolic) 1306 command_line.symbolic = symbolic_unset; 1307 break; 1308 case OPTION_WARN_COMMON: 1309 config.warn_common = TRUE; 1310 break; 1311 case OPTION_WARN_CONSTRUCTORS: 1312 config.warn_constructors = TRUE; 1313 break; 1314 case OPTION_WARN_FATAL: 1315 config.fatal_warnings = TRUE; 1316 break; 1317 case OPTION_NO_WARN_FATAL: 1318 config.fatal_warnings = FALSE; 1319 break; 1320 case OPTION_WARN_MULTIPLE_GP: 1321 config.warn_multiple_gp = TRUE; 1322 break; 1323 case OPTION_WARN_ONCE: 1324 config.warn_once = TRUE; 1325 break; 1326 case OPTION_WARN_SECTION_ALIGN: 1327 config.warn_section_align = TRUE; 1328 break; 1329 case OPTION_WARN_SHARED_TEXTREL: 1330 link_info.warn_shared_textrel = TRUE; 1331 break; 1332 case OPTION_WARN_ALTERNATE_EM: 1333 link_info.warn_alternate_em = TRUE; 1334 break; 1335 case OPTION_WHOLE_ARCHIVE: 1336 input_flags.whole_archive = TRUE; 1337 break; 1338 case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC: 1339 input_flags.add_DT_NEEDED_for_dynamic = TRUE; 1340 break; 1341 case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC: 1342 input_flags.add_DT_NEEDED_for_dynamic = FALSE; 1343 break; 1344 case OPTION_ADD_DT_NEEDED_FOR_REGULAR: 1345 input_flags.add_DT_NEEDED_for_regular = TRUE; 1346 break; 1347 case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR: 1348 input_flags.add_DT_NEEDED_for_regular = FALSE; 1349 break; 1350 case OPTION_WRAP: 1351 add_wrap (optarg); 1352 break; 1353 case OPTION_IGNORE_UNRESOLVED_SYMBOL: 1354 add_ignoresym (optarg); 1355 break; 1356 case OPTION_DISCARD_NONE: 1357 link_info.discard = discard_none; 1358 break; 1359 case 'X': 1360 link_info.discard = discard_l; 1361 break; 1362 case 'x': 1363 link_info.discard = discard_all; 1364 break; 1365 case 'Y': 1366 if (CONST_STRNEQ (optarg, "P,")) 1367 optarg += 2; 1368 if (default_dirlist != NULL) 1369 free (default_dirlist); 1370 default_dirlist = xstrdup (optarg); 1371 break; 1372 case 'y': 1373 add_ysym (optarg); 1374 break; 1375 case OPTION_SPARE_DYNAMIC_TAGS: 1376 link_info.spare_dynamic_tags = strtoul (optarg, NULL, 0); 1377 break; 1378 case OPTION_SPLIT_BY_RELOC: 1379 if (optarg != NULL) 1380 config.split_by_reloc = strtoul (optarg, NULL, 0); 1381 else 1382 config.split_by_reloc = 32768; 1383 break; 1384 case OPTION_SPLIT_BY_FILE: 1385 if (optarg != NULL) 1386 config.split_by_file = bfd_scan_vma (optarg, NULL, 0); 1387 else 1388 config.split_by_file = 1; 1389 break; 1390 case OPTION_CHECK_SECTIONS: 1391 command_line.check_section_addresses = 1; 1392 break; 1393 case OPTION_NO_CHECK_SECTIONS: 1394 command_line.check_section_addresses = 0; 1395 break; 1396 case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH: 1397 command_line.accept_unknown_input_arch = TRUE; 1398 break; 1399 case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH: 1400 command_line.accept_unknown_input_arch = FALSE; 1401 break; 1402 case '(': 1403 lang_enter_group (); 1404 ingroup++; 1405 break; 1406 case ')': 1407 if (! ingroup) 1408 einfo (_("%P%F: group ended before it began (--help for usage)\n")); 1409 1410 lang_leave_group (); 1411 ingroup--; 1412 break; 1413 1414 case OPTION_INIT: 1415 link_info.init_function = optarg; 1416 break; 1417 1418 case OPTION_FINI: 1419 link_info.fini_function = optarg; 1420 break; 1421 1422 case OPTION_REDUCE_MEMORY_OVERHEADS: 1423 link_info.reduce_memory_overheads = TRUE; 1424 if (config.hash_table_size == 0) 1425 config.hash_table_size = 1021; 1426 break; 1427 1428 case OPTION_HASH_SIZE: 1429 { 1430 bfd_size_type new_size; 1431 1432 new_size = strtoul (optarg, NULL, 0); 1433 if (new_size) 1434 config.hash_table_size = new_size; 1435 else 1436 einfo (_("%P%X: --hash-size needs a numeric argument\n")); 1437 } 1438 break; 1439 } 1440 } 1441 1442 while (ingroup) 1443 { 1444 lang_leave_group (); 1445 ingroup--; 1446 } 1447 1448 if (default_dirlist != NULL) 1449 { 1450 set_default_dirlist (default_dirlist); 1451 free (default_dirlist); 1452 } 1453 1454 if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET) 1455 /* FIXME: Should we allow emulations a chance to set this ? */ 1456 link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols; 1457 1458 if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET) 1459 /* FIXME: Should we allow emulations a chance to set this ? */ 1460 link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols; 1461 1462 if (link_info.relocatable) 1463 { 1464 if (command_line.check_section_addresses < 0) 1465 command_line.check_section_addresses = 0; 1466 if (link_info.shared) 1467 einfo (_("%P%F: -r and -shared may not be used together\n")); 1468 } 1469 1470 /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data, 1471 --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and 1472 --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are 1473 for shared libraries. -Bsymbolic overrides all others and vice 1474 versa. */ 1475 switch (command_line.symbolic) 1476 { 1477 case symbolic_unset: 1478 break; 1479 case symbolic: 1480 /* -Bsymbolic is for shared library only. */ 1481 if (link_info.shared) 1482 { 1483 link_info.symbolic = TRUE; 1484 /* Should we free the unused memory? */ 1485 link_info.dynamic_list = NULL; 1486 command_line.dynamic_list = dynamic_list_unset; 1487 } 1488 break; 1489 case symbolic_functions: 1490 /* -Bsymbolic-functions is for shared library only. */ 1491 if (link_info.shared) 1492 command_line.dynamic_list = dynamic_list_data; 1493 break; 1494 } 1495 1496 switch (command_line.dynamic_list) 1497 { 1498 case dynamic_list_unset: 1499 break; 1500 case dynamic_list_data: 1501 link_info.dynamic_data = TRUE; 1502 case dynamic_list: 1503 link_info.dynamic = TRUE; 1504 break; 1505 } 1506 1507 if (! link_info.shared) 1508 { 1509 if (command_line.filter_shlib) 1510 einfo (_("%P%F: -F may not be used without -shared\n")); 1511 if (command_line.auxiliary_filters) 1512 einfo (_("%P%F: -f may not be used without -shared\n")); 1513 } 1514 1515 if (! link_info.shared || link_info.pie) 1516 link_info.executable = TRUE; 1517 1518 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I 1519 don't see how else this can be handled, since in this case we 1520 must preserve all externally visible symbols. */ 1521 if (link_info.relocatable && link_info.strip == strip_all) 1522 { 1523 link_info.strip = strip_debugger; 1524 if (link_info.discard == discard_sec_merge) 1525 link_info.discard = discard_all; 1526 } 1527 } 1528 1529 /* Add the (colon-separated) elements of DIRLIST_PTR to the 1530 library search path. */ 1531 1532 static void 1533 set_default_dirlist (char *dirlist_ptr) 1534 { 1535 char *p; 1536 1537 while (1) 1538 { 1539 p = strchr (dirlist_ptr, PATH_SEPARATOR); 1540 if (p != NULL) 1541 *p = '\0'; 1542 if (*dirlist_ptr != '\0') 1543 ldfile_add_library_path (dirlist_ptr, TRUE); 1544 if (p == NULL) 1545 break; 1546 dirlist_ptr = p + 1; 1547 } 1548 } 1549 1550 static void 1551 set_section_start (char *sect, char *valstr) 1552 { 1553 const char *end; 1554 bfd_vma val = bfd_scan_vma (valstr, &end, 16); 1555 if (*end) 1556 einfo (_("%P%F: invalid hex number `%s'\n"), valstr); 1557 lang_section_start (sect, exp_intop (val), NULL); 1558 } 1559 1560 static void 1561 set_segment_start (const char *section, char *valstr) 1562 { 1563 const char *name; 1564 const char *end; 1565 segment_type *seg; 1566 1567 bfd_vma val = bfd_scan_vma (valstr, &end, 16); 1568 if (*end) 1569 einfo (_("%P%F: invalid hex number `%s'\n"), valstr); 1570 /* If we already have an entry for this segment, update the existing 1571 value. */ 1572 name = section + 1; 1573 for (seg = segments; seg; seg = seg->next) 1574 if (strcmp (seg->name, name) == 0) 1575 { 1576 seg->value = val; 1577 return; 1578 } 1579 /* There was no existing value so we must create a new segment 1580 entry. */ 1581 seg = (segment_type *) stat_alloc (sizeof (*seg)); 1582 seg->name = name; 1583 seg->value = val; 1584 seg->used = FALSE; 1585 /* Add it to the linked list of segments. */ 1586 seg->next = segments; 1587 segments = seg; 1588 /* Historically, -Ttext and friends set the base address of a 1589 particular section. For backwards compatibility, we still do 1590 that. If a SEGMENT_START directive is seen, the section address 1591 assignment will be disabled. */ 1592 lang_section_start (section, exp_intop (val), seg); 1593 } 1594 1595 1596 /* Print help messages for the options. */ 1597 1598 static void 1599 help (void) 1600 { 1601 unsigned i; 1602 const char **targets, **pp; 1603 int len; 1604 1605 printf (_("Usage: %s [options] file...\n"), program_name); 1606 1607 printf (_("Options:\n")); 1608 for (i = 0; i < OPTION_COUNT; i++) 1609 { 1610 if (ld_options[i].doc != NULL) 1611 { 1612 bfd_boolean comma; 1613 unsigned j; 1614 1615 printf (" "); 1616 1617 comma = FALSE; 1618 len = 2; 1619 1620 j = i; 1621 do 1622 { 1623 if (ld_options[j].shortopt != '\0' 1624 && ld_options[j].control != NO_HELP) 1625 { 1626 printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt); 1627 len += (comma ? 2 : 0) + 2; 1628 if (ld_options[j].arg != NULL) 1629 { 1630 if (ld_options[j].opt.has_arg != optional_argument) 1631 { 1632 printf (" "); 1633 ++len; 1634 } 1635 printf ("%s", _(ld_options[j].arg)); 1636 len += strlen (_(ld_options[j].arg)); 1637 } 1638 comma = TRUE; 1639 } 1640 ++j; 1641 } 1642 while (j < OPTION_COUNT && ld_options[j].doc == NULL); 1643 1644 j = i; 1645 do 1646 { 1647 if (ld_options[j].opt.name != NULL 1648 && ld_options[j].control != NO_HELP) 1649 { 1650 int two_dashes = 1651 (ld_options[j].control == TWO_DASHES 1652 || ld_options[j].control == EXACTLY_TWO_DASHES); 1653 1654 printf ("%s-%s%s", 1655 comma ? ", " : "", 1656 two_dashes ? "-" : "", 1657 ld_options[j].opt.name); 1658 len += ((comma ? 2 : 0) 1659 + 1 1660 + (two_dashes ? 1 : 0) 1661 + strlen (ld_options[j].opt.name)); 1662 if (ld_options[j].arg != NULL) 1663 { 1664 printf (" %s", _(ld_options[j].arg)); 1665 len += 1 + strlen (_(ld_options[j].arg)); 1666 } 1667 comma = TRUE; 1668 } 1669 ++j; 1670 } 1671 while (j < OPTION_COUNT && ld_options[j].doc == NULL); 1672 1673 if (len >= 30) 1674 { 1675 printf ("\n"); 1676 len = 0; 1677 } 1678 1679 for (; len < 30; len++) 1680 putchar (' '); 1681 1682 printf ("%s\n", _(ld_options[i].doc)); 1683 } 1684 } 1685 printf (_(" @FILE")); 1686 for (len = strlen (" @FILE"); len < 30; len++) 1687 putchar (' '); 1688 printf (_("Read options from FILE\n")); 1689 1690 /* Note: Various tools (such as libtool) depend upon the 1691 format of the listings below - do not change them. */ 1692 /* xgettext:c-format */ 1693 printf (_("%s: supported targets:"), program_name); 1694 targets = bfd_target_list (); 1695 for (pp = targets; *pp != NULL; pp++) 1696 printf (" %s", *pp); 1697 free (targets); 1698 printf ("\n"); 1699 1700 /* xgettext:c-format */ 1701 printf (_("%s: supported emulations: "), program_name); 1702 ldemul_list_emulations (stdout); 1703 printf ("\n"); 1704 1705 /* xgettext:c-format */ 1706 printf (_("%s: emulation specific options:\n"), program_name); 1707 ldemul_list_emulation_options (stdout); 1708 printf ("\n"); 1709 1710 if (REPORT_BUGS_TO[0]) 1711 printf (_("Report bugs to %s\n"), REPORT_BUGS_TO); 1712 } 1713