Subversion Repositories Kolibri OS

Rev

Rev 5199 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5199 Rev 6324
Line 1... Line 1...
1
/* Parse options for the GNU linker.
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.
2
   Copyright (C) 1991-2015 Free Software Foundation, Inc.
Line 5... Line 3...
5
 
3
 
Line 6... Line 4...
6
   This file is part of the GNU Binutils.
4
   This file is part of the GNU Binutils.
7
 
5
 
Line 65... Line 63...
65
/* The long options.  This structure is used for both the option
63
/* The long options.  This structure is used for both the option
66
   parsing and the help text.  */
64
   parsing and the help text.  */
Line 67... Line 65...
67
 
65
 
68
enum control_enum {
66
enum control_enum {
69
  /* Use one dash before long option name.  */
67
  /* Use one dash before long option name.  */
70
  ONE_DASH,
68
  ONE_DASH = 1,
71
  /* Use two dashes before long option name.  */
69
  /* Use two dashes before long option name.  */
72
  TWO_DASHES,
70
  TWO_DASHES = 2,
73
  /* Only accept two dashes before the long option name.
71
  /* Only accept two dashes before the long option name.
74
     This is an overloading of the use of this enum, since originally it
72
     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
73
     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
74
     the long option name.  This feature was added in order to resolve
Line 138... Line 136...
138
  { {"soname", required_argument, NULL, OPTION_SONAME},
136
  { {"soname", required_argument, NULL, OPTION_SONAME},
139
    'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
137
    'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH },
140
  { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
138
  { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
141
    'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
139
    'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
142
    TWO_DASHES },
140
    TWO_DASHES },
-
 
141
  { {"no-dynamic-linker", no_argument, NULL, OPTION_NO_DYNAMIC_LINKER},
-
 
142
    '\0', NULL, N_("Produce an executable with no program interpreter header"),
-
 
143
    TWO_DASHES },
143
  { {"library", required_argument, NULL, 'l'},
144
  { {"library", required_argument, NULL, 'l'},
144
    'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
145
    'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
145
  { {"library-path", required_argument, NULL, 'L'},
146
  { {"library-path", required_argument, NULL, 'L'},
146
    'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
147
    'L', N_("DIRECTORY"), N_("Add DIRECTORY to library search path"),
147
    TWO_DASHES },
148
    TWO_DASHES },
Line 176... Line 177...
176
    ONE_DASH },
177
    ONE_DASH },
177
#endif /* ENABLE_PLUGINS */
178
#endif /* ENABLE_PLUGINS */
178
  { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE},
179
  { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE},
179
    '\0', NULL, N_("Ignored for GCC linker option compatibility"),
180
    '\0', NULL, N_("Ignored for GCC linker option compatibility"),
180
    ONE_DASH },
181
    ONE_DASH },
-
 
182
  { {"map-whole-files", optional_argument, NULL, OPTION_IGNORE},
-
 
183
    '\0', NULL, N_("Ignored for gold option compatibility"),
-
 
184
    TWO_DASHES },
-
 
185
  { {"no-map-whole-files", optional_argument, NULL, OPTION_IGNORE},
-
 
186
    '\0', NULL, N_("Ignored for gold option compatibility"),
-
 
187
    TWO_DASHES },
181
  { {"Qy", no_argument, NULL, OPTION_IGNORE},
188
  { {"Qy", no_argument, NULL, OPTION_IGNORE},
182
    '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
189
    '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
183
  { {"emit-relocs", no_argument, NULL, 'q'},
190
  { {"emit-relocs", no_argument, NULL, 'q'},
184
    'q', NULL, "Generate relocations in final output", TWO_DASHES },
191
    'q', NULL, "Generate relocations in final output", TWO_DASHES },
185
  { {"relocatable", no_argument, NULL, 'r'},
192
  { {"relocatable", no_argument, NULL, 'r'},
Line 206... Line 213...
206
  { {"dT", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
213
  { {"dT", required_argument, NULL, OPTION_DEFAULT_SCRIPT},
207
    '\0', NULL, NULL, ONE_DASH },
214
    '\0', NULL, NULL, ONE_DASH },
208
  { {"undefined", required_argument, NULL, 'u'},
215
  { {"undefined", required_argument, NULL, 'u'},
209
    'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
216
    'u', N_("SYMBOL"), N_("Start with undefined reference to SYMBOL"),
210
    TWO_DASHES },
217
    TWO_DASHES },
-
 
218
  { {"require-defined", required_argument, NULL, OPTION_REQUIRE_DEFINED_SYMBOL},
-
 
219
    '\0', N_("SYMBOL"), N_("Require SYMBOL be defined in the final output"),
-
 
220
    TWO_DASHES },
211
  { {"unique", optional_argument, NULL, OPTION_UNIQUE},
221
  { {"unique", optional_argument, NULL, OPTION_UNIQUE},
212
    '\0', N_("[=SECTION]"),
222
    '\0', N_("[=SECTION]"),
213
    N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
223
    N_("Don't merge input [SECTION | orphan] sections"), TWO_DASHES },
214
  { {"Ur", no_argument, NULL, OPTION_UR},
224
  { {"Ur", no_argument, NULL, OPTION_UR},
215
    '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
225
    '\0', NULL, N_("Build global constructor/destructor tables"), ONE_DASH },
Line 379... Line 389...
379
  { {"oformat", required_argument, NULL, OPTION_OFORMAT},
389
  { {"oformat", required_argument, NULL, OPTION_OFORMAT},
380
    '\0', N_("TARGET"), N_("Specify target of output file"),
390
    '\0', N_("TARGET"), N_("Specify target of output file"),
381
    EXACTLY_TWO_DASHES },
391
    EXACTLY_TWO_DASHES },
382
  { {"print-output-format", no_argument, NULL, OPTION_PRINT_OUTPUT_FORMAT},
392
  { {"print-output-format", no_argument, NULL, OPTION_PRINT_OUTPUT_FORMAT},
383
    '\0', NULL, N_("Print default output format"), TWO_DASHES },
393
    '\0', NULL, N_("Print default output format"), TWO_DASHES },
-
 
394
  { {"print-sysroot", no_argument, NULL, OPTION_PRINT_SYSROOT},
-
 
395
    '\0', NULL, N_("Print current sysroot"), TWO_DASHES },
384
  { {"qmagic", no_argument, NULL, OPTION_IGNORE},
396
  { {"qmagic", no_argument, NULL, OPTION_IGNORE},
385
    '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
397
    '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
386
  { {"reduce-memory-overheads", no_argument, NULL,
398
  { {"reduce-memory-overheads", no_argument, NULL,
387
     OPTION_REDUCE_MEMORY_OVERHEADS},
399
     OPTION_REDUCE_MEMORY_OVERHEADS},
388
    '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
400
    '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
Line 505... Line 517...
505
    '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
517
    '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
506
  { {"ignore-unresolved-symbol", required_argument, NULL,
518
  { {"ignore-unresolved-symbol", required_argument, NULL,
507
    OPTION_IGNORE_UNRESOLVED_SYMBOL},
519
    OPTION_IGNORE_UNRESOLVED_SYMBOL},
508
    '\0', N_("SYMBOL"),
520
    '\0', N_("SYMBOL"),
509
    N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
521
    N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
-
 
522
  { {"push-state", no_argument, NULL, OPTION_PUSH_STATE},
-
 
523
    '\0', NULL, N_("Push state of flags governing input file handling"),
-
 
524
    TWO_DASHES },
-
 
525
  { {"pop-state", no_argument, NULL, OPTION_POP_STATE},
-
 
526
    '\0', NULL, N_("Pop state of flags governing input file handling"),
-
 
527
    TWO_DASHES },
-
 
528
  { {"print-memory-usage", no_argument, NULL, OPTION_PRINT_MEMORY_USAGE},
-
 
529
    '\0', NULL, N_("Report target memory usage"), TWO_DASHES },
-
 
530
  { {"orphan-handling", required_argument, NULL, OPTION_ORPHAN_HANDLING},
-
 
531
    '\0', N_("=MODE"), N_("Control how orphan sections are handled."),
-
 
532
    TWO_DASHES },
510
};
533
};
Line 511... Line 534...
511
 
534
 
Line 512... Line 535...
512
#define OPTION_COUNT ARRAY_SIZE (ld_options)
535
#define OPTION_COUNT ARRAY_SIZE (ld_options)
Line 654... Line 677...
654
	break;
677
	break;
Line 655... Line 678...
655
 
678
 
656
      switch (optc)
679
      switch (optc)
657
	{
680
	{
-
 
681
	case '?':
-
 
682
	  {
-
 
683
	    /* If the last word on the command line is an option that
-
 
684
	       requires an argument, getopt will refuse to recognise it.
-
 
685
	       Try to catch such options here and issue a more helpful
-
 
686
	       error message than just "unrecognized option".  */
-
 
687
	    int opt;
-
 
688
 
-
 
689
	    for (opt = ARRAY_SIZE (ld_options); opt--;)
-
 
690
	      if (ld_options[opt].opt.has_arg == required_argument
-
 
691
		  /* FIXME: There are a few short options that do not
-
 
692
		     have long equivalents, but which require arguments.
-
 
693
		     We should handle them too.  */
-
 
694
		  && ld_options[opt].opt.name != NULL
-
 
695
		  && strcmp (argv[last_optind] + ld_options[opt].control, ld_options[opt].opt.name) == 0)
-
 
696
		{
-
 
697
		  einfo (_("%P: %s: missing argument\n"), argv[last_optind]);
-
 
698
		  break;
-
 
699
		}
-
 
700
 
658
	case '?':
701
	    if (opt == -1)
-
 
702
	  einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
659
	  einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
703
	  }
Line 660... Line 704...
660
	  /* Fall through.  */
704
	  /* Fall through.  */
661
 
705
 
Line 739... Line 783...
739
	    }
783
	    }
740
	  break;
784
	  break;
741
	case 'I':		/* Used on Solaris.  */
785
	case 'I':		/* Used on Solaris.  */
742
	case OPTION_DYNAMIC_LINKER:
786
	case OPTION_DYNAMIC_LINKER:
743
	  command_line.interpreter = optarg;
787
	  command_line.interpreter = optarg;
-
 
788
	  link_info.nointerp = 0;
-
 
789
	  break;
-
 
790
	case OPTION_NO_DYNAMIC_LINKER:
-
 
791
	  link_info.nointerp = 1;
744
	  break;
792
	  break;
745
	case OPTION_SYSROOT:
793
	case OPTION_SYSROOT:
746
	  /* Already handled in ldmain.c.  */
794
	  /* Already handled in ldmain.c.  */
747
	  break;
795
	  break;
748
	case OPTION_EB:
796
	case OPTION_EB:
Line 954... Line 1002...
954
	  lang_add_output (optarg, 0);
1002
	  lang_add_output (optarg, 0);
955
	  break;
1003
	  break;
956
	case OPTION_OFORMAT:
1004
	case OPTION_OFORMAT:
957
	  lang_add_output_format (optarg, NULL, NULL, 0);
1005
	  lang_add_output_format (optarg, NULL, NULL, 0);
958
	  break;
1006
	  break;
-
 
1007
	case OPTION_PRINT_SYSROOT:
-
 
1008
	  if (*ld_sysroot)
-
 
1009
	    puts (ld_sysroot);
-
 
1010
	  xexit (0);
-
 
1011
	  break;
959
	case OPTION_PRINT_OUTPUT_FORMAT:
1012
	case OPTION_PRINT_OUTPUT_FORMAT:
960
	  command_line.print_output_format = TRUE;
1013
	  command_line.print_output_format = TRUE;
961
	  break;
1014
	  break;
962
#ifdef ENABLE_PLUGINS
1015
#ifdef ENABLE_PLUGINS
963
	case OPTION_PLUGIN:
1016
	case OPTION_PLUGIN:
Line 980... Line 1033...
980
	       but it cannot parse the text after the -r so it refuses to
1033
	       but it cannot parse the text after the -r so it refuses to
981
	       increment the optind counter.  Detect this case and issue
1034
	       increment the optind counter.  Detect this case and issue
982
	       an error message here.  We cannot just make this a warning,
1035
	       an error message here.  We cannot just make this a warning,
983
	       increment optind, and continue because getopt is too confused
1036
	       increment optind, and continue because getopt is too confused
984
	       and will seg-fault the next time around.  */
1037
	       and will seg-fault the next time around.  */
-
 
1038
	    einfo(_("%P%F: unrecognised option: %s\n"), argv[optind]);
-
 
1039
 
-
 
1040
	  if (bfd_link_pic (&link_info))
985
	    einfo(_("%P%F: bad -rpath option\n"));
1041
	    einfo (_("%P%F: -r and %s may not be used together\n"),
-
 
1042
		     bfd_link_dll (&link_info) ? "-shared" : "-pie");
Line 986... Line 1043...
986
 
1043
 
987
	  link_info.relocatable = TRUE;
1044
	  link_info.type = type_relocatable;
988
	  config.build_constructors = FALSE;
1045
	  config.build_constructors = FALSE;
989
	  config.magic_demand_paged = FALSE;
1046
	  config.magic_demand_paged = FALSE;
990
	  config.text_read_only = FALSE;
1047
	  config.text_read_only = FALSE;
991
	  input_flags.dynamic = FALSE;
1048
	  input_flags.dynamic = FALSE;
Line 1085... Line 1142...
1085
	  link_info.strip_discarded = FALSE;
1142
	  link_info.strip_discarded = FALSE;
1086
	  break;
1143
	  break;
1087
	case OPTION_SHARED:
1144
	case OPTION_SHARED:
1088
	  if (config.has_shared)
1145
	  if (config.has_shared)
1089
	    {
1146
	    {
-
 
1147
	      if (bfd_link_relocatable (&link_info))
-
 
1148
		einfo (_("%P%F: -r and -shared may not be used together\n"));
-
 
1149
 
1090
	      link_info.shared = TRUE;
1150
	      link_info.type = type_dll;
1091
	      /* When creating a shared library, the default
1151
	      /* When creating a shared library, the default
1092
		 behaviour is to ignore any unresolved references.  */
1152
		 behaviour is to ignore any unresolved references.  */
1093
	      if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1153
	      if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
1094
		link_info.unresolved_syms_in_objects = RM_IGNORE;
1154
		link_info.unresolved_syms_in_objects = RM_IGNORE;
1095
	      if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1155
	      if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
Line 1099... Line 1159...
1099
	    einfo (_("%P%F: -shared not supported\n"));
1159
	    einfo (_("%P%F: -shared not supported\n"));
1100
	  break;
1160
	  break;
1101
	case OPTION_PIE:
1161
	case OPTION_PIE:
1102
	  if (config.has_shared)
1162
	  if (config.has_shared)
1103
	    {
1163
	    {
1104
	      link_info.shared = TRUE;
1164
	      if (bfd_link_relocatable (&link_info))
-
 
1165
		einfo (_("%P%F: -r and -pie may not be used together\n"));
-
 
1166
 
1105
	      link_info.pie = TRUE;
1167
	      link_info.type = type_pie;
1106
	    }
1168
	    }
1107
	  else
1169
	  else
1108
	    einfo (_("%P%F: -pie not supported\n"));
1170
	    einfo (_("%P%F: -pie not supported\n"));
1109
	  break;
1171
	  break;
1110
	case 'h':		/* Used on Solaris.  */
1172
	case 'h':		/* Used on Solaris.  */
1111
	case OPTION_SONAME:
1173
	case OPTION_SONAME:
-
 
1174
	  if (optarg[0] == '\0' && command_line.soname
-
 
1175
	      && command_line.soname[0])
-
 
1176
	    einfo (_("%P: SONAME must not be empty string; keeping previous one\n"));
-
 
1177
	  else
1112
	  command_line.soname = optarg;
1178
	  command_line.soname = optarg;
1113
	  break;
1179
	  break;
1114
	case OPTION_SORT_COMMON:
1180
	case OPTION_SORT_COMMON:
1115
	  if (optarg == NULL
1181
	  if (optarg == NULL
1116
	      || strcmp (optarg, N_("descending")) == 0)
1182
	      || strcmp (optarg, N_("descending")) == 0)
Line 1209... Line 1275...
1209
	  break;
1275
	  break;
1210
	case OPTION_TASK_LINK:
1276
	case OPTION_TASK_LINK:
1211
	  link_info.task_link = TRUE;
1277
	  link_info.task_link = TRUE;
1212
	  /* Fall through - do an implied -r option.  */
1278
	  /* Fall through - do an implied -r option.  */
1213
	case OPTION_UR:
1279
	case OPTION_UR:
-
 
1280
	  if (bfd_link_pic (&link_info))
-
 
1281
	    einfo (_("%P%F: -r and %s may not be used together\n"),
-
 
1282
		     bfd_link_dll (&link_info) ? "-shared" : "-pie");
-
 
1283
 
1214
	  link_info.relocatable = TRUE;
1284
	  link_info.type = type_relocatable;
1215
	  config.build_constructors = TRUE;
1285
	  config.build_constructors = TRUE;
1216
	  config.magic_demand_paged = FALSE;
1286
	  config.magic_demand_paged = FALSE;
1217
	  config.text_read_only = FALSE;
1287
	  config.text_read_only = FALSE;
1218
	  input_flags.dynamic = FALSE;
1288
	  input_flags.dynamic = FALSE;
1219
	  break;
1289
	  break;
1220
	case 'u':
1290
	case 'u':
1221
	  ldlang_add_undef (optarg, TRUE);
1291
	  ldlang_add_undef (optarg, TRUE);
1222
	  break;
1292
	  break;
-
 
1293
        case OPTION_REQUIRE_DEFINED_SYMBOL:
-
 
1294
          ldlang_add_require_defined (optarg);
-
 
1295
	  break;
1223
	case OPTION_UNIQUE:
1296
	case OPTION_UNIQUE:
1224
	  if (optarg != NULL)
1297
	  if (optarg != NULL)
1225
	    lang_add_unique (optarg);
1298
	    lang_add_unique (optarg);
1226
	  else
1299
	  else
1227
	    config.unique_orphan_sections = TRUE;
1300
	    config.unique_orphan_sections = TRUE;
Line 1440... Line 1513...
1440
              config.hash_table_size = new_size;
1513
              config.hash_table_size = new_size;
1441
            else
1514
            else
1442
              einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1515
              einfo (_("%P%X: --hash-size needs a numeric argument\n"));
1443
          }
1516
          }
1444
          break;
1517
          break;
-
 
1518
 
-
 
1519
	case OPTION_PUSH_STATE:
-
 
1520
	  input_flags.pushed = xmemdup (&input_flags,
-
 
1521
					sizeof (input_flags),
-
 
1522
					sizeof (input_flags));
-
 
1523
	  break;
-
 
1524
 
-
 
1525
	case OPTION_POP_STATE:
-
 
1526
	  if (input_flags.pushed == NULL)
-
 
1527
	    einfo (_("%P%F: no state pushed before popping\n"));
-
 
1528
	  else
-
 
1529
	    {
-
 
1530
	      struct lang_input_statement_flags *oldp = input_flags.pushed;
-
 
1531
	      memcpy (&input_flags, oldp, sizeof (input_flags));
-
 
1532
	      free (oldp);
1445
	}
1533
	    }
-
 
1534
	  break;
-
 
1535
 
-
 
1536
	case OPTION_PRINT_MEMORY_USAGE:
-
 
1537
	  command_line.print_memory_usage = TRUE;
-
 
1538
	  break;
-
 
1539
 
-
 
1540
	case OPTION_ORPHAN_HANDLING:
-
 
1541
	  if (strcasecmp (optarg, "place") == 0)
-
 
1542
	    config.orphan_handling = orphan_handling_place;
-
 
1543
	  else if (strcasecmp (optarg, "warn") == 0)
-
 
1544
	    config.orphan_handling = orphan_handling_warn;
-
 
1545
	  else if (strcasecmp (optarg, "error") == 0)
-
 
1546
	    config.orphan_handling = orphan_handling_error;
-
 
1547
	  else if (strcasecmp (optarg, "discard") == 0)
-
 
1548
	    config.orphan_handling = orphan_handling_discard;
-
 
1549
	  else
-
 
1550
	    einfo (_("%P%F: invalid argument to option"
-
 
1551
		     " \"--orphan-handling\"\n"));
-
 
1552
	  break;
-
 
1553
	}
-
 
1554
    }
-
 
1555
 
-
 
1556
  if (command_line.soname && command_line.soname[0] == '\0')
-
 
1557
    {
-
 
1558
      einfo (_("%P: SONAME must not be empty string; ignored\n"));
-
 
1559
      command_line.soname = NULL;
1446
    }
1560
    }
Line 1447... Line 1561...
1447
 
1561
 
1448
  while (ingroup)
1562
  while (ingroup)
1449
    {
1563
    {
Line 1463... Line 1577...
1463
 
1577
 
1464
  if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1578
  if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
1465
    /* FIXME: Should we allow emulations a chance to set this ?  */
1579
    /* FIXME: Should we allow emulations a chance to set this ?  */
Line 1466... Line 1580...
1466
    link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
1580
    link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
1467
 
-
 
1468
  if (link_info.relocatable)
1581
 
1469
    {
1582
  if (bfd_link_relocatable (&link_info)
1470
      if (command_line.check_section_addresses < 0)
-
 
1471
	command_line.check_section_addresses = 0;
-
 
1472
      if (link_info.shared)
-
 
Line 1473... Line 1583...
1473
	einfo (_("%P%F: -r and -shared may not be used together\n"));
1583
      && command_line.check_section_addresses < 0)
1474
    }
1584
	command_line.check_section_addresses = 0;
1475
 
1585
 
1476
  /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data,
1586
  /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data,
Line 1482... Line 1592...
1482
    {
1592
    {
1483
    case symbolic_unset:
1593
    case symbolic_unset:
1484
      break;
1594
      break;
1485
    case symbolic:
1595
    case symbolic:
1486
      /* -Bsymbolic is for shared library only.  */
1596
      /* -Bsymbolic is for shared library only.  */
1487
      if (link_info.shared)
1597
      if (bfd_link_dll (&link_info))
1488
	{
1598
	{
1489
	  link_info.symbolic = TRUE;
1599
	  link_info.symbolic = TRUE;
1490
	  /* Should we free the unused memory?  */
1600
	  /* Should we free the unused memory?  */
1491
	  link_info.dynamic_list = NULL;
1601
	  link_info.dynamic_list = NULL;
1492
	  command_line.dynamic_list = dynamic_list_unset;
1602
	  command_line.dynamic_list = dynamic_list_unset;
1493
	}
1603
	}
1494
      break;
1604
      break;
1495
    case symbolic_functions:
1605
    case symbolic_functions:
1496
      /* -Bsymbolic-functions is for shared library only.  */
1606
      /* -Bsymbolic-functions is for shared library only.  */
1497
      if (link_info.shared)
1607
      if (bfd_link_dll (&link_info))
1498
	command_line.dynamic_list = dynamic_list_data;
1608
	command_line.dynamic_list = dynamic_list_data;
1499
      break;
1609
      break;
1500
    }
1610
    }
Line 1501... Line 1611...
1501
 
1611
 
Line 1508... Line 1618...
1508
    case dynamic_list:
1618
    case dynamic_list:
1509
      link_info.dynamic = TRUE;
1619
      link_info.dynamic = TRUE;
1510
      break;
1620
      break;
1511
    }
1621
    }
Line 1512... Line 1622...
1512
 
1622
 
1513
  if (! link_info.shared)
1623
  if (!bfd_link_dll (&link_info))
1514
    {
1624
    {
1515
      if (command_line.filter_shlib)
1625
      if (command_line.filter_shlib)
1516
	einfo (_("%P%F: -F may not be used without -shared\n"));
1626
	einfo (_("%P%F: -F may not be used without -shared\n"));
1517
      if (command_line.auxiliary_filters)
1627
      if (command_line.auxiliary_filters)
1518
	einfo (_("%P%F: -f may not be used without -shared\n"));
1628
	einfo (_("%P%F: -f may not be used without -shared\n"));
Line 1519... Line -...
1519
    }
-
 
1520
 
-
 
1521
  if (! link_info.shared || link_info.pie)
-
 
1522
    link_info.executable = TRUE;
1629
    }
1523
 
1630
 
1524
  /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols).  I
1631
  /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols).  I
1525
     don't see how else this can be handled, since in this case we
1632
     don't see how else this can be handled, since in this case we
1526
     must preserve all externally visible symbols.  */
1633
     must preserve all externally visible symbols.  */
1527
  if (link_info.relocatable && link_info.strip == strip_all)
1634
  if (bfd_link_relocatable (&link_info) && link_info.strip == strip_all)
1528
    {
1635
    {
1529
      link_info.strip = strip_debugger;
1636
      link_info.strip = strip_debugger;
1530
      if (link_info.discard == discard_sec_merge)
1637
      if (link_info.discard == discard_sec_merge)
Line 1596... Line 1703...
1596
     that.  If a SEGMENT_START directive is seen, the section address
1703
     that.  If a SEGMENT_START directive is seen, the section address
1597
     assignment will be disabled.  */
1704
     assignment will be disabled.  */
1598
  lang_section_start (section, exp_intop (val), seg);
1705
  lang_section_start (section, exp_intop (val), seg);
1599
}
1706
}
Line -... Line 1707...
-
 
1707
 
-
 
1708
static void
-
 
1709
elf_shlib_list_options (FILE *file)
-
 
1710
{
-
 
1711
  fprintf (file, _("\
-
 
1712
  --audit=AUDITLIB            Specify a library to use for auditing\n"));
-
 
1713
  fprintf (file, _("\
-
 
1714
  -Bgroup                     Selects group name lookup rules for DSO\n"));
-
 
1715
  fprintf (file, _("\
-
 
1716
  --disable-new-dtags         Disable new dynamic tags\n"));
-
 
1717
  fprintf (file, _("\
-
 
1718
  --enable-new-dtags          Enable new dynamic tags\n"));
-
 
1719
  fprintf (file, _("\
-
 
1720
  --eh-frame-hdr              Create .eh_frame_hdr section\n"));
-
 
1721
  fprintf (file, _("\
-
 
1722
  --exclude-libs=LIBS         Make all symbols in LIBS hidden\n"));
-
 
1723
  fprintf (file, _("\
-
 
1724
  --hash-style=STYLE          Set hash style to sysv, gnu or both\n"));
-
 
1725
  fprintf (file, _("\
-
 
1726
  -P AUDITLIB, --depaudit=AUDITLIB\n" "\
-
 
1727
			      Specify a library to use for auditing dependencies\n"));
-
 
1728
  fprintf (file, _("\
-
 
1729
  -z combreloc                Merge dynamic relocs into one section and sort\n"));
-
 
1730
  fprintf (file, _("\
-
 
1731
  -z nocombreloc              Don't merge dynamic relocs into one section\n"));
-
 
1732
  fprintf (file, _("\
-
 
1733
  -z global                   Make symbols in DSO available for subsequently\n\
-
 
1734
			       loaded objects\n"));
-
 
1735
  fprintf (file, _("\
-
 
1736
  -z initfirst                Mark DSO to be initialized first at runtime\n"));
-
 
1737
  fprintf (file, _("\
-
 
1738
  -z interpose                Mark object to interpose all DSOs but executable\n"));
-
 
1739
  fprintf (file, _("\
-
 
1740
  -z lazy                     Mark object lazy runtime binding (default)\n"));
-
 
1741
  fprintf (file, _("\
-
 
1742
  -z loadfltr                 Mark object requiring immediate process\n"));
-
 
1743
  fprintf (file, _("\
-
 
1744
  -z nocopyreloc              Don't create copy relocs\n"));
-
 
1745
  fprintf (file, _("\
-
 
1746
  -z nodefaultlib             Mark object not to use default search paths\n"));
-
 
1747
  fprintf (file, _("\
-
 
1748
  -z nodelete                 Mark DSO non-deletable at runtime\n"));
-
 
1749
  fprintf (file, _("\
-
 
1750
  -z nodlopen                 Mark DSO not available to dlopen\n"));
-
 
1751
  fprintf (file, _("\
-
 
1752
  -z nodump                   Mark DSO not available to dldump\n"));
-
 
1753
  fprintf (file, _("\
-
 
1754
  -z now                      Mark object non-lazy runtime binding\n"));
-
 
1755
  fprintf (file, _("\
-
 
1756
  -z origin                   Mark object requiring immediate $ORIGIN\n\
-
 
1757
				processing at runtime\n"));
-
 
1758
  fprintf (file, _("\
-
 
1759
  -z relro                    Create RELRO program header\n"));
-
 
1760
  fprintf (file, _("\
-
 
1761
  -z norelro                  Don't create RELRO program header\n"));
-
 
1762
  fprintf (file, _("\
-
 
1763
  -z stacksize=SIZE           Set size of stack segment\n"));
-
 
1764
  fprintf (file, _("\
-
 
1765
  -z text                     Treat DT_TEXTREL in shared object as error\n"));
-
 
1766
  fprintf (file, _("\
-
 
1767
  -z notext                   Don't treat DT_TEXTREL in shared object as error\n"));
-
 
1768
  fprintf (file, _("\
-
 
1769
  -z textoff                  Don't treat DT_TEXTREL in shared object as error\n"));
-
 
1770
}
-
 
1771
 
-
 
1772
static void
-
 
1773
elf_static_list_options (FILE *file)
-
 
1774
{
-
 
1775
  fprintf (file, _("\
-
 
1776
  --build-id[=STYLE]          Generate build ID note\n"));
-
 
1777
  fprintf (file, _("\
-
 
1778
  --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]\n\
-
 
1779
                              Compress DWARF debug sections using zlib\n"));
-
 
1780
#ifdef DEFAULT_FLAG_COMPRESS_DEBUG
-
 
1781
  fprintf (file, _("\
-
 
1782
                               Default: zlib-gabi\n"));
-
 
1783
#else
-
 
1784
  fprintf (file, _("\
-
 
1785
                               Default: none\n"));
-
 
1786
#endif
-
 
1787
  fprintf (file, _("\
-
 
1788
  -z common-page-size=SIZE    Set common page size to SIZE\n"));
-
 
1789
  fprintf (file, _("\
-
 
1790
  -z max-page-size=SIZE       Set maximum page size to SIZE\n"));
-
 
1791
  fprintf (file, _("\
-
 
1792
  -z defs                     Report unresolved symbols in object files.\n"));
-
 
1793
  fprintf (file, _("\
-
 
1794
  -z muldefs                  Allow multiple definitions\n"));
-
 
1795
  fprintf (file, _("\
-
 
1796
  -z execstack                Mark executable as requiring executable stack\n"));
-
 
1797
  fprintf (file, _("\
-
 
1798
  -z noexecstack              Mark executable as not requiring executable stack\n"));
-
 
1799
}
-
 
1800
 
-
 
1801
static void
-
 
1802
elf_plt_unwind_list_options (FILE *file)
-
 
1803
{
-
 
1804
  fprintf (file, _("\
-
 
1805
  --ld-generated-unwind-info  Generate exception handling info for PLT\n\
-
 
1806
  --no-ld-generated-unwind-info\n\
-
 
1807
                              Don't generate exception handling info for PLT\n"));
-
 
1808
}
-
 
1809
 
-
 
1810
static void
-
 
1811
ld_list_options (FILE *file, bfd_boolean elf, bfd_boolean shlib,
-
 
1812
		 bfd_boolean plt_unwind)
-
 
1813
{
-
 
1814
  if (!elf)
-
 
1815
    return;
-
 
1816
  printf (_("ELF emulations:\n"));
-
 
1817
  if (plt_unwind)
-
 
1818
    elf_plt_unwind_list_options (file);
-
 
1819
  elf_static_list_options (file);
-
 
1820
  if (shlib)
-
 
1821
    elf_shlib_list_options (file);
-
 
1822
}
1600
 
1823
 
1601

1824

Line 1602... Line 1825...
1602
/* Print help messages for the options.  */
1825
/* Print help messages for the options.  */
1603
 
1826
 
Line 1708... Line 1931...
1708
  ldemul_list_emulations (stdout);
1931
  ldemul_list_emulations (stdout);
1709
  printf ("\n");
1932
  printf ("\n");
Line 1710... Line 1933...
1710
 
1933
 
1711
  /* xgettext:c-format */
1934
  /* xgettext:c-format */
-
 
1935
  printf (_("%s: emulation specific options:\n"), program_name);
-
 
1936
  ld_list_options (stdout, ELF_LIST_OPTIONS, ELF_SHLIB_LIST_OPTIONS,
1712
  printf (_("%s: emulation specific options:\n"), program_name);
1937
		   ELF_PLT_UNWIND_LIST_OPTIONS);
1713
  ldemul_list_emulation_options (stdout);
1938
  ldemul_list_emulation_options (stdout);
Line 1714... Line 1939...
1714
  printf ("\n");
1939
  printf ("\n");
1715
 
1940