Subversion Repositories Kolibri OS

Rev

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

Rev 5222 Rev 6324
Line 1... Line 1...
1
/* as.c - GAS main program.
1
/* as.c - GAS main program.
2
   Copyright 1987-2013 Free Software Foundation, Inc.
2
   Copyright (C) 1987-2015 Free Software Foundation, Inc.
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
   This file is part of GAS, the GNU Assembler.
4
   This file is part of GAS, the GNU Assembler.
5
 
5
 
Line 95... Line 95...
95
 
95
 
96
/* Enable verbose mode.  */
96
/* Enable verbose mode.  */
Line 97... Line 97...
97
int verbose = 0;
97
int verbose = 0;
98
 
98
 
Line 99... Line 99...
99
/* Keep the output file.  */
99
/* Keep the output file.  */
100
int keep_it = 0;
100
static int keep_it = 0;
101
 
101
 
102
segT reg_section;
102
segT reg_section;
Line 222... Line 222...
222
 
222
 
223
  fprintf (stderr, _("GNU assembler version %s (%s) using BFD version %s\n"),
223
  fprintf (stderr, _("GNU assembler version %s (%s) using BFD version %s\n"),
224
	   VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
224
	   VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
Line -... Line 225...
-
 
225
}
-
 
226
 
-
 
227
#ifdef DEFAULT_FLAG_COMPRESS_DEBUG
-
 
228
enum compressed_debug_section_type flag_compress_debug
-
 
229
  = COMPRESS_DEBUG_GABI_ZLIB;
225
}
230
#endif
226
 
231
 
227
static void
232
static void
228
show_usage (FILE * stream)
233
show_usage (FILE * stream)
Line 243... Line 248...
243
                      	  s      include symbols\n\
248
                      	  s      include symbols\n\
244
                      	  =FILE  list to FILE (must be last sub-option)\n"));
249
                      	  =FILE  list to FILE (must be last sub-option)\n"));
Line 245... Line 250...
245
 
250
 
246
  fprintf (stream, _("\
251
  fprintf (stream, _("\
247
  --alternate             initially turn on alternate macro syntax\n"));
252
  --alternate             initially turn on alternate macro syntax\n"));
248
#ifdef HAVE_ZLIB_H
253
#ifdef DEFAULT_FLAG_COMPRESS_DEBUG
249
  fprintf (stream, _("\
254
  fprintf (stream, _("\
250
  --compress-debug-sections\n\
255
  --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi}]\n\
251
                          compress DWARF debug sections using zlib\n"));
256
                          compress DWARF debug sections using zlib [default]\n"));
252
  fprintf (stream, _("\
257
  fprintf (stream, _("\
253
  --nocompress-debug-sections\n\
258
  --nocompress-debug-sections\n\
-
 
259
                          don't compress DWARF debug sections\n"));
-
 
260
#else
-
 
261
  fprintf (stream, _("\
-
 
262
  --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi}]\n\
254
                          don't compress DWARF debug sections\n"));
263
                          compress DWARF debug sections using zlib\n"));
-
 
264
  fprintf (stream, _("\
-
 
265
  --nocompress-debug-sections\n\
-
 
266
                          don't compress DWARF debug sections [default]\n"));
255
#endif /* HAVE_ZLIB_H */
267
#endif
256
  fprintf (stream, _("\
268
  fprintf (stream, _("\
257
  -D                      produce assembler debugging messages\n"));
269
  -D                      produce assembler debugging messages\n"));
258
  fprintf (stream, _("\
270
  fprintf (stream, _("\
259
  --debug-prefix-map OLD=NEW\n\
271
  --debug-prefix-map OLD=NEW\n\
Line 284... Line 296...
284
  fprintf (stream, _("\
296
  fprintf (stream, _("\
285
  --noexecstack           don't require executable stack for this object\n"));
297
  --noexecstack           don't require executable stack for this object\n"));
286
  fprintf (stream, _("\
298
  fprintf (stream, _("\
287
  --size-check=[error|warning]\n\
299
  --size-check=[error|warning]\n\
288
			  ELF .size directive check (default --size-check=error)\n"));
300
			  ELF .size directive check (default --size-check=error)\n"));
-
 
301
  fprintf (stream, _("\
-
 
302
  --sectname-subst        enable section name substitution sequences\n"));
289
#endif
303
#endif
290
  fprintf (stream, _("\
304
  fprintf (stream, _("\
291
  -f                      skip whitespace and comment preprocessing\n"));
305
  -f                      skip whitespace and comment preprocessing\n"));
292
  fprintf (stream, _("\
306
  fprintf (stream, _("\
293
  -g --gen-debug          generate debugging information\n"));
307
  -g --gen-debug          generate debugging information\n"));
Line 447... Line 461...
447
      OPTION_WARN,
461
      OPTION_WARN,
448
      OPTION_TARGET_HELP,
462
      OPTION_TARGET_HELP,
449
      OPTION_EXECSTACK,
463
      OPTION_EXECSTACK,
450
      OPTION_NOEXECSTACK,
464
      OPTION_NOEXECSTACK,
451
      OPTION_SIZE_CHECK,
465
      OPTION_SIZE_CHECK,
-
 
466
      OPTION_SECTNAME_SUBST,
452
      OPTION_ALTERNATE,
467
      OPTION_ALTERNATE,
453
      OPTION_AL,
468
      OPTION_AL,
454
      OPTION_HASH_TABLE_SIZE,
469
      OPTION_HASH_TABLE_SIZE,
455
      OPTION_REDUCE_MEMORY_OVERHEADS,
470
      OPTION_REDUCE_MEMORY_OVERHEADS,
456
      OPTION_WARN_FATAL,
471
      OPTION_WARN_FATAL,
Line 471... Line 486...
471
       necessary because -a= is a valid switch but getopt would
486
       necessary because -a= is a valid switch but getopt would
472
       normally reject it since --alternate does not take an argument.  */
487
       normally reject it since --alternate does not take an argument.  */
473
    ,{"a", optional_argument, NULL, 'a'}
488
    ,{"a", optional_argument, NULL, 'a'}
474
    /* Handle -al=.  */
489
    /* Handle -al=.  */
475
    ,{"al", optional_argument, NULL, OPTION_AL}
490
    ,{"al", optional_argument, NULL, OPTION_AL}
476
    ,{"compress-debug-sections", no_argument, NULL, OPTION_COMPRESS_DEBUG}
491
    ,{"compress-debug-sections", optional_argument, NULL, OPTION_COMPRESS_DEBUG}
477
    ,{"nocompress-debug-sections", no_argument, NULL, OPTION_NOCOMPRESS_DEBUG}
492
    ,{"nocompress-debug-sections", no_argument, NULL, OPTION_NOCOMPRESS_DEBUG}
478
    ,{"debug-prefix-map", required_argument, NULL, OPTION_DEBUG_PREFIX_MAP}
493
    ,{"debug-prefix-map", required_argument, NULL, OPTION_DEBUG_PREFIX_MAP}
479
    ,{"defsym", required_argument, NULL, OPTION_DEFSYM}
494
    ,{"defsym", required_argument, NULL, OPTION_DEFSYM}
480
    ,{"dump-config", no_argument, NULL, OPTION_DUMPCONFIG}
495
    ,{"dump-config", no_argument, NULL, OPTION_DUMPCONFIG}
481
    ,{"emulation", required_argument, NULL, OPTION_EMULATION}
496
    ,{"emulation", required_argument, NULL, OPTION_EMULATION}
482
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
497
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
483
    ,{"execstack", no_argument, NULL, OPTION_EXECSTACK}
498
    ,{"execstack", no_argument, NULL, OPTION_EXECSTACK}
484
    ,{"noexecstack", no_argument, NULL, OPTION_NOEXECSTACK}
499
    ,{"noexecstack", no_argument, NULL, OPTION_NOEXECSTACK}
485
    ,{"size-check", required_argument, NULL, OPTION_SIZE_CHECK}
500
    ,{"size-check", required_argument, NULL, OPTION_SIZE_CHECK}
-
 
501
    ,{"sectname-subst", no_argument, NULL, OPTION_SECTNAME_SUBST}
486
#endif
502
#endif
487
    ,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
503
    ,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
488
    ,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF2}
504
    ,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF2}
489
    /* GCC uses --gdwarf-2 but GAS uses to use --gdwarf2,
505
    /* GCC uses --gdwarf-2 but GAS uses to use --gdwarf2,
490
       so we keep it here for backwards compatibility.  */
506
       so we keep it here for backwards compatibility.  */
Line 624... Line 640...
624
	  break;
640
	  break;
Line 625... Line 641...
625
 
641
 
626
	case OPTION_VERSION:
642
	case OPTION_VERSION:
627
	  /* This output is intended to follow the GNU standards document.  */
643
	  /* This output is intended to follow the GNU standards document.  */
628
	  printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
644
	  printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
629
	  printf (_("Copyright 2013 Free Software Foundation, Inc.\n"));
645
	  printf (_("Copyright (C) 2015 Free Software Foundation, Inc.\n"));
630
	  printf (_("\
646
	  printf (_("\
631
This program is free software; you may redistribute it under the terms of\n\
647
This program is free software; you may redistribute it under the terms of\n\
632
the GNU General Public License version 3 or later.\n\
648
the GNU General Public License version 3 or later.\n\
633
This program has absolutely no warranty.\n"));
649
This program has absolutely no warranty.\n"));
Line 655... Line 671...
655
	  fprintf (stderr, _("bfd-target = %s\n"), TARGET_FORMAT);
671
	  fprintf (stderr, _("bfd-target = %s\n"), TARGET_FORMAT);
656
#endif
672
#endif
657
	  exit (EXIT_SUCCESS);
673
	  exit (EXIT_SUCCESS);
Line 658... Line 674...
658
 
674
 
659
	case OPTION_COMPRESS_DEBUG:
675
	case OPTION_COMPRESS_DEBUG:
-
 
676
	  if (optarg)
-
 
677
	    {
-
 
678
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
660
#ifdef HAVE_ZLIB_H
679
	      if (strcasecmp (optarg, "none") == 0)
-
 
680
		flag_compress_debug = COMPRESS_DEBUG_NONE;
-
 
681
	      else if (strcasecmp (optarg, "zlib") == 0)
-
 
682
		flag_compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
-
 
683
	      else if (strcasecmp (optarg, "zlib-gnu") == 0)
-
 
684
		flag_compress_debug = COMPRESS_DEBUG_GNU_ZLIB;
-
 
685
	      else if (strcasecmp (optarg, "zlib-gabi") == 0)
-
 
686
		flag_compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
-
 
687
	      else
-
 
688
		as_fatal (_("Invalid --compress-debug-sections option: `%s'"),
661
	  flag_compress_debug = 1;
689
			  optarg);
662
#else
690
#else
-
 
691
	      as_fatal (_("--compress-debug-sections=%s is unsupported"),
663
	  as_warn (_("cannot compress debug sections (zlib not installed)"));
692
			optarg);
-
 
693
#endif
-
 
694
	    }
-
 
695
	  else
664
#endif /* HAVE_ZLIB_H */
696
	    flag_compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
Line 665... Line 697...
665
	  break;
697
	  break;
666
 
698
 
667
	case OPTION_NOCOMPRESS_DEBUG:
699
	case OPTION_NOCOMPRESS_DEBUG:
Line 668... Line 700...
668
	  flag_compress_debug = 0;
700
	  flag_compress_debug = COMPRESS_DEBUG_NONE;
669
	  break;
701
	  break;
670
 
702
 
Line 832... Line 864...
832
	  else if (strcasecmp (optarg, "warning") == 0)
864
	  else if (strcasecmp (optarg, "warning") == 0)
833
	    flag_size_check = size_check_warning;
865
	    flag_size_check = size_check_warning;
834
	  else
866
	  else
835
	    as_fatal (_("Invalid --size-check= option: `%s'"), optarg);
867
	    as_fatal (_("Invalid --size-check= option: `%s'"), optarg);
836
	  break;
868
	  break;
-
 
869
 
-
 
870
	case OPTION_SECTNAME_SUBST:
-
 
871
	  flag_sectname_subst = 1;
-
 
872
	  break;
837
#endif
873
#endif
838
	case 'Z':
874
	case 'Z':
839
	  flag_always_generate_output = 1;
875
	  flag_always_generate_output = 1;
840
	  break;
876
	  break;
Line 1105... Line 1141...
1105
    }
1141
    }
1106
  if (!saw_a_file)
1142
  if (!saw_a_file)
1107
    read_a_source_file ("");
1143
    read_a_source_file ("");
1108
}
1144
}
1109

1145

1110
#ifdef OBJ_ELF
-
 
1111
static void
-
 
1112
create_obj_attrs_section (void)
-
 
1113
{
-
 
1114
  segT s;
-
 
1115
  char *p;
-
 
1116
  offsetT size;
-
 
1117
  const char *name;
-
 
1118
 
-
 
1119
  size = bfd_elf_obj_attr_size (stdoutput);
-
 
1120
  if (size)
-
 
1121
    {
-
 
1122
      name = get_elf_backend_data (stdoutput)->obj_attrs_section;
-
 
1123
      if (!name)
-
 
1124
	name = ".gnu.attributes";
-
 
1125
      s = subseg_new (name, 0);
-
 
1126
      elf_section_type (s)
-
 
1127
	= get_elf_backend_data (stdoutput)->obj_attrs_section_type;
-
 
1128
      bfd_set_section_flags (stdoutput, s, SEC_READONLY | SEC_DATA);
-
 
1129
      frag_now_fix ();
-
 
1130
      p = frag_more (size);
-
 
1131
      bfd_elf_set_obj_attr_contents (stdoutput, (bfd_byte *)p, size);
-
 
1132
    }
-
 
1133
}
-
 
1134
#endif
-
 
1135

-
 
Line 1136... Line 1146...
1136
 
1146
 
1137
int
1147
int
1138
main (int argc, char ** argv)
1148
main (int argc, char ** argv)
1139
{
1149
{
Line 1255... Line 1265...
1255
 
1265
 
1256
#ifdef md_end
1266
#ifdef md_end
1257
  md_end ();
1267
  md_end ();
Line 1258... Line -...
1258
#endif
-
 
1259
 
-
 
1260
#ifdef OBJ_ELF
-
 
1261
  if (IS_ELF)
-
 
1262
    create_obj_attrs_section ();
-
 
1263
#endif
1268
#endif
1264
 
1269
 
1265
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
1270
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
1266
  if ((flag_execstack || flag_noexecstack)
1271
  if ((flag_execstack || flag_noexecstack)
1267
      && OUTPUT_FLAVOR == bfd_target_elf_flavour)
1272
      && OUTPUT_FLAVOR == bfd_target_elf_flavour)
Line 1281... Line 1286...
1281
 
1286
 
1282
  /* If we constructed dwarf2 .eh_frame info, either via .cfi
1287
  /* If we constructed dwarf2 .eh_frame info, either via .cfi
1283
     directives from the user or by the backend, emit it now.  */
1288
     directives from the user or by the backend, emit it now.  */
Line 1284... Line -...
1284
  cfi_finish ();
-
 
1285
 
-
 
1286
  if (seen_at_least_1_file ()
-
 
1287
      && (flag_always_generate_output || had_errors () == 0))
-
 
1288
    keep_it = 1;
1289
  cfi_finish ();
-
 
1290
 
-
 
1291
  keep_it = 0;
-
 
1292
  if (seen_at_least_1_file ())
-
 
1293
    {
-
 
1294
      int n_warns, n_errs;
Line 1289... Line -...
1289
  else
-
 
1290
    keep_it = 0;
-
 
1291
 
-
 
1292
  /* This used to be done at the start of write_object_file in
-
 
1293
     write.c, but that caused problems when doing listings when
-
 
1294
     keep_it was zero.  This could probably be moved above md_end, but
-
 
1295
     I didn't want to risk the change.  */
-
 
1296
  subsegs_finish ();
1295
      char warn_msg[50];
Line -... Line 1296...
-
 
1296
      char err_msg[50];
-
 
1297
 
-
 
1298
      write_object_file ();
-
 
1299
 
-
 
1300
      n_warns = had_warnings ();
-
 
1301
      n_errs = had_errors ();
-
 
1302
 
-
 
1303
      if (n_warns == 1)
-
 
1304
	sprintf (warn_msg, _("%d warning"), n_warns);
-
 
1305
      else
-
 
1306
	sprintf (warn_msg, _("%d warnings"), n_warns);
-
 
1307
      if (n_errs == 1)
-
 
1308
	sprintf (err_msg, _("%d error"), n_errs);
-
 
1309
  else
-
 
1310
	sprintf (err_msg, _("%d errors"), n_errs);
-
 
1311
 
-
 
1312
      if (flag_fatal_warnings && n_warns != 0)
-
 
1313
	{
-
 
1314
	  if (n_errs == 0)
-
 
1315
	    as_bad (_("%s, treating warnings as errors"), warn_msg);
-
 
1316
	  n_errs += n_warns;
-
 
1317
	}
-
 
1318
 
-
 
1319
      if (n_errs == 0)
-
 
1320
	keep_it = 1;
-
 
1321
      else if (flag_always_generate_output)
-
 
1322
	{
-
 
1323
	  /* The -Z flag indicates that an object file should be generated,
-
 
1324
	     regardless of warnings and errors.  */
-
 
1325
	  keep_it = 1;
-
 
1326
	  fprintf (stderr, _("%s, %s, generating bad object file\n"),
1297
 
1327
		   err_msg, warn_msg);
Line 1298... Line 1328...
1298
  if (keep_it)
1328
	}
1299
    write_object_file ();
1329
    }
1300
 
1330
 
Line 1301... Line -...
1301
  fflush (stderr);
-
 
1302
 
-
 
1303
#ifndef NO_LISTING
-
 
1304
  listing_print (listing_filename, argv_orig);
-
 
1305
#endif
-
 
1306
 
-
 
1307
  if (flag_fatal_warnings && had_warnings () > 0 && had_errors () == 0)
1331
  fflush (stderr);
Line 1308... Line 1332...
1308
    as_bad (_("%d warnings, treating warnings as errors"), had_warnings ());
1332
 
Line 1309... Line 1333...
1309
 
1333
#ifndef NO_LISTING
1310
  if (had_errors () > 0 && ! flag_always_generate_output)
1334
  listing_print (listing_filename, argv_orig);
1311
    keep_it = 0;
1335
#endif
1312
 
1336
 
Line 1313... Line 1337...
1313
  input_scrub_end ();
1337
  input_scrub_end ();
1314
 
1338