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
/* tc-i386.c -- Assemble code for the Intel 80386
1
/* tc-i386.c -- Assemble code for the Intel 80386
2
   Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-
 
3
   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
-
 
4
   2012
-
 
5
   Free Software Foundation, Inc.
2
   Copyright (C) 1989-2015 Free Software Foundation, Inc.
Line 6... Line 3...
6
 
3
 
Line 7... Line 4...
7
   This file is part of GAS, the GNU Assembler.
4
   This file is part of GAS, the GNU Assembler.
8
 
5
 
Line 514... Line 511...
514
};
511
};
Line 515... Line 512...
515
 
512
 
516
static enum x86_elf_abi x86_elf_abi = I386_ABI;
513
static enum x86_elf_abi x86_elf_abi = I386_ABI;
Line -... Line 514...
-
 
514
#endif
-
 
515
 
-
 
516
#if defined (TE_PE) || defined (TE_PEP)
-
 
517
/* Use big object file format.  */
-
 
518
static int use_big_obj = 0;
-
 
519
#endif
-
 
520
 
-
 
521
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-
 
522
/* 1 if generating code for a shared library.  */
-
 
523
static int shared = 0;
517
#endif
524
#endif
518
 
525
 
519
/* 1 for intel syntax,
526
/* 1 for intel syntax,
Line 520... Line 527...
520
   0 if att syntax.  */
527
   0 if att syntax.  */
Line 539... Line 546...
539
static int add_bnd_prefix = 0;
546
static int add_bnd_prefix = 0;
Line 540... Line 547...
540
 
547
 
541
/* 1 if pseudo index register, eiz/riz, is allowed .  */
548
/* 1 if pseudo index register, eiz/riz, is allowed .  */
Line -... Line 549...
-
 
549
static int allow_index_reg = 0;
-
 
550
 
-
 
551
/* 1 if the assembler should ignore LOCK prefix, even if it was
-
 
552
   specified explicitly.  */
542
static int allow_index_reg = 0;
553
static int omit_lock_prefix = 0;
543
 
554
 
544
static enum check_kind
555
static enum check_kind
545
  {
556
  {
546
    check_none = 0,
557
    check_none = 0,
Line 612... Line 623...
612
  {
623
  {
613
    evexw0 = 0,
624
    evexw0 = 0,
614
    evexw1
625
    evexw1
615
  } evexwig;
626
  } evexwig;
Line -... Line 627...
-
 
627
 
-
 
628
/* Value to encode in EVEX RC bits, for SAE-only instructions.  */
-
 
629
static enum rc_type evexrcig = rne;
616
 
630
 
617
/* Pre-defined "_GLOBAL_OFFSET_TABLE_".  */
631
/* Pre-defined "_GLOBAL_OFFSET_TABLE_".  */
Line 618... Line 632...
618
static symbolS *GOT_symbol;
632
static symbolS *GOT_symbol;
619
 
633
 
Line 750... Line 764...
750
    CPU_COREI7_FLAGS, 0, 0 },
764
    CPU_COREI7_FLAGS, 0, 0 },
751
  { STRING_COMMA_LEN ("l1om"), PROCESSOR_L1OM,
765
  { STRING_COMMA_LEN ("l1om"), PROCESSOR_L1OM,
752
    CPU_L1OM_FLAGS, 0, 0 },
766
    CPU_L1OM_FLAGS, 0, 0 },
753
  { STRING_COMMA_LEN ("k1om"), PROCESSOR_K1OM,
767
  { STRING_COMMA_LEN ("k1om"), PROCESSOR_K1OM,
754
    CPU_K1OM_FLAGS, 0, 0 },
768
    CPU_K1OM_FLAGS, 0, 0 },
-
 
769
  { STRING_COMMA_LEN ("iamcu"), PROCESSOR_IAMCU,
-
 
770
    CPU_IAMCU_FLAGS, 0, 0 },
755
  { STRING_COMMA_LEN ("k6"), PROCESSOR_K6,
771
  { STRING_COMMA_LEN ("k6"), PROCESSOR_K6,
756
    CPU_K6_FLAGS, 0, 0 },
772
    CPU_K6_FLAGS, 0, 0 },
757
  { STRING_COMMA_LEN ("k6_2"), PROCESSOR_K6,
773
  { STRING_COMMA_LEN ("k6_2"), PROCESSOR_K6,
758
    CPU_K6_2_FLAGS, 0, 0 },
774
    CPU_K6_2_FLAGS, 0, 0 },
759
  { STRING_COMMA_LEN ("athlon"), PROCESSOR_ATHLON,
775
  { STRING_COMMA_LEN ("athlon"), PROCESSOR_ATHLON,
Line 770... Line 786...
770
    CPU_BDVER1_FLAGS, 0, 0 },
786
    CPU_BDVER1_FLAGS, 0, 0 },
771
  { STRING_COMMA_LEN ("bdver2"), PROCESSOR_BD,
787
  { STRING_COMMA_LEN ("bdver2"), PROCESSOR_BD,
772
    CPU_BDVER2_FLAGS, 0, 0 },
788
    CPU_BDVER2_FLAGS, 0, 0 },
773
  { STRING_COMMA_LEN ("bdver3"), PROCESSOR_BD,
789
  { STRING_COMMA_LEN ("bdver3"), PROCESSOR_BD,
774
    CPU_BDVER3_FLAGS, 0, 0 },
790
    CPU_BDVER3_FLAGS, 0, 0 },
-
 
791
  { STRING_COMMA_LEN ("bdver4"), PROCESSOR_BD,
-
 
792
    CPU_BDVER4_FLAGS, 0, 0 },
-
 
793
  { STRING_COMMA_LEN ("znver1"), PROCESSOR_ZNVER,
-
 
794
    CPU_ZNVER1_FLAGS, 0, 0 },
775
  { STRING_COMMA_LEN ("btver1"), PROCESSOR_BT,
795
  { STRING_COMMA_LEN ("btver1"), PROCESSOR_BT,
776
    CPU_BTVER1_FLAGS, 0, 0 },
796
    CPU_BTVER1_FLAGS, 0, 0 },
777
  { STRING_COMMA_LEN ("btver2"), PROCESSOR_BT,
797
  { STRING_COMMA_LEN ("btver2"), PROCESSOR_BT,
778
    CPU_BTVER2_FLAGS, 0, 0 },
798
    CPU_BTVER2_FLAGS, 0, 0 },
779
  { STRING_COMMA_LEN (".8087"), PROCESSOR_UNKNOWN,
799
  { STRING_COMMA_LEN (".8087"), PROCESSOR_UNKNOWN,
Line 814... Line 834...
814
    CPU_AVX512CD_FLAGS, 0, 0 },
834
    CPU_AVX512CD_FLAGS, 0, 0 },
815
  { STRING_COMMA_LEN (".avx512er"), PROCESSOR_UNKNOWN,
835
  { STRING_COMMA_LEN (".avx512er"), PROCESSOR_UNKNOWN,
816
    CPU_AVX512ER_FLAGS, 0, 0 },
836
    CPU_AVX512ER_FLAGS, 0, 0 },
817
  { STRING_COMMA_LEN (".avx512pf"), PROCESSOR_UNKNOWN,
837
  { STRING_COMMA_LEN (".avx512pf"), PROCESSOR_UNKNOWN,
818
    CPU_AVX512PF_FLAGS, 0, 0 },
838
    CPU_AVX512PF_FLAGS, 0, 0 },
-
 
839
  { STRING_COMMA_LEN (".avx512dq"), PROCESSOR_UNKNOWN,
-
 
840
    CPU_AVX512DQ_FLAGS, 0, 0 },
-
 
841
  { STRING_COMMA_LEN (".avx512bw"), PROCESSOR_UNKNOWN,
-
 
842
    CPU_AVX512BW_FLAGS, 0, 0 },
-
 
843
  { STRING_COMMA_LEN (".avx512vl"), PROCESSOR_UNKNOWN,
-
 
844
    CPU_AVX512VL_FLAGS, 0, 0 },
819
  { STRING_COMMA_LEN (".noavx"), PROCESSOR_UNKNOWN,
845
  { STRING_COMMA_LEN (".noavx"), PROCESSOR_UNKNOWN,
820
    CPU_ANY_AVX_FLAGS, 0, 1 },
846
    CPU_ANY_AVX_FLAGS, 0, 1 },
821
  { STRING_COMMA_LEN (".vmx"), PROCESSOR_UNKNOWN,
847
  { STRING_COMMA_LEN (".vmx"), PROCESSOR_UNKNOWN,
822
    CPU_VMX_FLAGS, 0, 0 },
848
    CPU_VMX_FLAGS, 0, 0 },
823
  { STRING_COMMA_LEN (".vmfunc"), PROCESSOR_UNKNOWN,
849
  { STRING_COMMA_LEN (".vmfunc"), PROCESSOR_UNKNOWN,
Line 826... Line 852...
826
    CPU_SMX_FLAGS, 0, 0 },
852
    CPU_SMX_FLAGS, 0, 0 },
827
  { STRING_COMMA_LEN (".xsave"), PROCESSOR_UNKNOWN,
853
  { STRING_COMMA_LEN (".xsave"), PROCESSOR_UNKNOWN,
828
    CPU_XSAVE_FLAGS, 0, 0 },
854
    CPU_XSAVE_FLAGS, 0, 0 },
829
  { STRING_COMMA_LEN (".xsaveopt"), PROCESSOR_UNKNOWN,
855
  { STRING_COMMA_LEN (".xsaveopt"), PROCESSOR_UNKNOWN,
830
    CPU_XSAVEOPT_FLAGS, 0, 0 },
856
    CPU_XSAVEOPT_FLAGS, 0, 0 },
-
 
857
  { STRING_COMMA_LEN (".xsavec"), PROCESSOR_UNKNOWN,
-
 
858
    CPU_XSAVEC_FLAGS, 0, 0 },
-
 
859
  { STRING_COMMA_LEN (".xsaves"), PROCESSOR_UNKNOWN,
-
 
860
    CPU_XSAVES_FLAGS, 0, 0 },
831
  { STRING_COMMA_LEN (".aes"), PROCESSOR_UNKNOWN,
861
  { STRING_COMMA_LEN (".aes"), PROCESSOR_UNKNOWN,
832
    CPU_AES_FLAGS, 0, 0 },
862
    CPU_AES_FLAGS, 0, 0 },
833
  { STRING_COMMA_LEN (".pclmul"), PROCESSOR_UNKNOWN,
863
  { STRING_COMMA_LEN (".pclmul"), PROCESSOR_UNKNOWN,
834
    CPU_PCLMUL_FLAGS, 0, 0 },
864
    CPU_PCLMUL_FLAGS, 0, 0 },
835
  { STRING_COMMA_LEN (".clmul"), PROCESSOR_UNKNOWN,
865
  { STRING_COMMA_LEN (".clmul"), PROCESSOR_UNKNOWN,
Line 900... Line 930...
900
    CPU_SMAP_FLAGS, 0, 0 },
930
    CPU_SMAP_FLAGS, 0, 0 },
901
  { STRING_COMMA_LEN (".mpx"), PROCESSOR_UNKNOWN,
931
  { STRING_COMMA_LEN (".mpx"), PROCESSOR_UNKNOWN,
902
    CPU_MPX_FLAGS, 0, 0 },
932
    CPU_MPX_FLAGS, 0, 0 },
903
  { STRING_COMMA_LEN (".sha"), PROCESSOR_UNKNOWN,
933
  { STRING_COMMA_LEN (".sha"), PROCESSOR_UNKNOWN,
904
    CPU_SHA_FLAGS, 0, 0 },
934
    CPU_SHA_FLAGS, 0, 0 },
-
 
935
  { STRING_COMMA_LEN (".clflushopt"), PROCESSOR_UNKNOWN,
-
 
936
    CPU_CLFLUSHOPT_FLAGS, 0, 0 },
-
 
937
  { STRING_COMMA_LEN (".prefetchwt1"), PROCESSOR_UNKNOWN,
-
 
938
    CPU_PREFETCHWT1_FLAGS, 0, 0 },
-
 
939
  { STRING_COMMA_LEN (".se1"), PROCESSOR_UNKNOWN,
-
 
940
    CPU_SE1_FLAGS, 0, 0 },
-
 
941
  { STRING_COMMA_LEN (".clwb"), PROCESSOR_UNKNOWN,
-
 
942
    CPU_CLWB_FLAGS, 0, 0 },
-
 
943
  { STRING_COMMA_LEN (".pcommit"), PROCESSOR_UNKNOWN,
-
 
944
    CPU_PCOMMIT_FLAGS, 0, 0 },
-
 
945
  { STRING_COMMA_LEN (".avx512ifma"), PROCESSOR_UNKNOWN,
-
 
946
    CPU_AVX512IFMA_FLAGS, 0, 0 },
-
 
947
  { STRING_COMMA_LEN (".avx512vbmi"), PROCESSOR_UNKNOWN,
-
 
948
    CPU_AVX512VBMI_FLAGS, 0, 0 },
-
 
949
  { STRING_COMMA_LEN (".clzero"), PROCESSOR_UNKNOWN,
-
 
950
    CPU_CLZERO_FLAGS, 0, 0 },
-
 
951
  { STRING_COMMA_LEN (".mwaitx"), PROCESSOR_UNKNOWN,
-
 
952
    CPU_MWAITX_FLAGS, 0, 0 },
-
 
953
  { STRING_COMMA_LEN (".ospke"), PROCESSOR_UNKNOWN,
-
 
954
    CPU_OSPKE_FLAGS, 0, 0 },
905
};
955
};
Line 906... Line 956...
906
 
956
 
907
#ifdef I386COFF
957
#ifdef I386COFF
908
/* Like s_lcomm_internal in gas/read.c but the alignment string
958
/* Like s_lcomm_internal in gas/read.c but the alignment string
Line 1092... Line 1142...
1092
  static const char alt_9[] =
1142
  static const char alt_9[] =
1093
    {0x66,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
1143
    {0x66,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
1094
  /* nopw %cs:0L(%[re]ax,%[re]ax,1) */
1144
  /* nopw %cs:0L(%[re]ax,%[re]ax,1) */
1095
  static const char alt_10[] =
1145
  static const char alt_10[] =
1096
    {0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
1146
    {0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
1097
  /* data16
-
 
1098
     nopw %cs:0L(%[re]ax,%[re]ax,1) */
-
 
1099
  static const char alt_long_11[] =
-
 
1100
    {0x66,
-
 
1101
     0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
-
 
1102
  /* data16
-
 
1103
     data16
-
 
1104
     nopw %cs:0L(%[re]ax,%[re]ax,1) */
-
 
1105
  static const char alt_long_12[] =
-
 
1106
    {0x66,
-
 
1107
     0x66,
-
 
1108
     0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
-
 
1109
  /* data16
-
 
1110
     data16
-
 
1111
     data16
-
 
1112
     nopw %cs:0L(%[re]ax,%[re]ax,1) */
-
 
1113
  static const char alt_long_13[] =
-
 
1114
    {0x66,
-
 
1115
     0x66,
-
 
1116
     0x66,
-
 
1117
     0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
-
 
1118
  /* data16
-
 
1119
     data16
-
 
1120
     data16
-
 
1121
     data16
-
 
1122
     nopw %cs:0L(%[re]ax,%[re]ax,1) */
-
 
1123
  static const char alt_long_14[] =
-
 
1124
    {0x66,
-
 
1125
     0x66,
-
 
1126
     0x66,
-
 
1127
     0x66,
-
 
1128
     0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
-
 
1129
  /* data16
-
 
1130
     data16
-
 
1131
     data16
-
 
1132
     data16
-
 
1133
     data16
-
 
1134
     nopw %cs:0L(%[re]ax,%[re]ax,1) */
-
 
1135
  static const char alt_long_15[] =
-
 
1136
    {0x66,
-
 
1137
     0x66,
-
 
1138
     0x66,
-
 
1139
     0x66,
-
 
1140
     0x66,
-
 
1141
     0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
-
 
1142
  /* nopl 0(%[re]ax,%[re]ax,1)
-
 
1143
     nopw 0(%[re]ax,%[re]ax,1) */
-
 
1144
  static const char alt_short_11[] =
-
 
1145
    {0x0f,0x1f,0x44,0x00,0x00,
-
 
1146
     0x66,0x0f,0x1f,0x44,0x00,0x00};
-
 
1147
  /* nopw 0(%[re]ax,%[re]ax,1)
-
 
1148
     nopw 0(%[re]ax,%[re]ax,1) */
-
 
1149
  static const char alt_short_12[] =
-
 
1150
    {0x66,0x0f,0x1f,0x44,0x00,0x00,
-
 
1151
     0x66,0x0f,0x1f,0x44,0x00,0x00};
-
 
1152
  /* nopw 0(%[re]ax,%[re]ax,1)
-
 
1153
     nopl 0L(%[re]ax) */
-
 
1154
  static const char alt_short_13[] =
-
 
1155
    {0x66,0x0f,0x1f,0x44,0x00,0x00,
-
 
1156
     0x0f,0x1f,0x80,0x00,0x00,0x00,0x00};
-
 
1157
  /* nopl 0L(%[re]ax)
-
 
1158
     nopl 0L(%[re]ax) */
-
 
1159
  static const char alt_short_14[] =
-
 
1160
    {0x0f,0x1f,0x80,0x00,0x00,0x00,0x00,
-
 
1161
     0x0f,0x1f,0x80,0x00,0x00,0x00,0x00};
-
 
1162
  /* nopl 0L(%[re]ax)
-
 
1163
     nopl 0L(%[re]ax,%[re]ax,1) */
-
 
1164
  static const char alt_short_15[] =
-
 
1165
    {0x0f,0x1f,0x80,0x00,0x00,0x00,0x00,
-
 
1166
     0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00};
-
 
1167
  static const char *const alt_short_patt[] = {
1147
  static const char *const alt_patt[] = {
1168
    f32_1, f32_2, alt_3, alt_4, alt_5, alt_6, alt_7, alt_8,
1148
    f32_1, f32_2, alt_3, alt_4, alt_5, alt_6, alt_7, alt_8,
1169
    alt_9, alt_10, alt_short_11, alt_short_12, alt_short_13,
-
 
1170
    alt_short_14, alt_short_15
-
 
1171
  };
-
 
1172
  static const char *const alt_long_patt[] = {
-
 
1173
    f32_1, f32_2, alt_3, alt_4, alt_5, alt_6, alt_7, alt_8,
-
 
1174
    alt_9, alt_10, alt_long_11, alt_long_12, alt_long_13,
-
 
1175
    alt_long_14, alt_long_15
1149
    alt_9, alt_10
1176
  };
1150
  };
Line 1177... Line 1151...
1177
 
1151
 
1178
  /* Only align for at least a positive non-zero boundary. */
1152
  /* Only align for at least a positive non-zero boundary. */
1179
  if (count <= 0 || count > MAX_MEM_FOR_RS_ALIGN_CODE)
1153
  if (count <= 0 || count > MAX_MEM_FOR_RS_ALIGN_CODE)
Line 1182... Line 1156...
1182
  /* We need to decide which NOP sequence to use for 32bit and
1156
  /* We need to decide which NOP sequence to use for 32bit and
1183
     64bit. When -mtune= is used:
1157
     64bit. When -mtune= is used:
Line 1184... Line 1158...
1184
 
1158
 
1185
     1. For PROCESSOR_I386, PROCESSOR_I486, PROCESSOR_PENTIUM and
1159
     1. For PROCESSOR_I386, PROCESSOR_I486, PROCESSOR_PENTIUM and
1186
     PROCESSOR_GENERIC32, f32_patt will be used.
-
 
1187
     2. For PROCESSOR_PENTIUMPRO, PROCESSOR_PENTIUM4, PROCESSOR_NOCONA,
-
 
1188
     PROCESSOR_CORE, PROCESSOR_CORE2, PROCESSOR_COREI7, and
1160
     PROCESSOR_GENERIC32, f32_patt will be used.
1189
     PROCESSOR_GENERIC64, alt_long_patt will be used.
-
 
1190
     3. For PROCESSOR_ATHLON, PROCESSOR_K6, PROCESSOR_K8 and
-
 
1191
     PROCESSOR_AMDFAM10, PROCESSOR_BD and PROCESSOR_BT, alt_short_patt
-
 
Line 1192... Line 1161...
1192
     will be used.
1161
     2. For the rest, alt_patt will be used.
1193
 
1162
 
1194
     When -mtune= isn't used, alt_long_patt will be used if
1163
     When -mtune= isn't used, alt_patt will be used if
Line 1195... Line 1164...
1195
     cpu_arch_isa_flags has CpuNop.  Otherwise, f32_patt will
1164
     cpu_arch_isa_flags has CpuNop.  Otherwise, f32_patt will
1196
     be used.
1165
     be used.
Line 1222... Line 1191...
1222
	    {
1191
	    {
1223
	    case PROCESSOR_UNKNOWN:
1192
	    case PROCESSOR_UNKNOWN:
1224
	      /* We use cpu_arch_isa_flags to check if we SHOULD
1193
	      /* We use cpu_arch_isa_flags to check if we SHOULD
1225
		 optimize with nops.  */
1194
		 optimize with nops.  */
1226
	      if (fragP->tc_frag_data.isa_flags.bitfield.cpunop)
1195
	      if (fragP->tc_frag_data.isa_flags.bitfield.cpunop)
1227
		patt = alt_long_patt;
1196
		patt = alt_patt;
1228
	      else
1197
	      else
1229
		patt = f32_patt;
1198
		patt = f32_patt;
1230
	      break;
1199
	      break;
1231
	    case PROCESSOR_PENTIUM4:
1200
	    case PROCESSOR_PENTIUM4:
1232
	    case PROCESSOR_NOCONA:
1201
	    case PROCESSOR_NOCONA:
Line 1234... Line 1203...
1234
	    case PROCESSOR_CORE2:
1203
	    case PROCESSOR_CORE2:
1235
	    case PROCESSOR_COREI7:
1204
	    case PROCESSOR_COREI7:
1236
	    case PROCESSOR_L1OM:
1205
	    case PROCESSOR_L1OM:
1237
	    case PROCESSOR_K1OM:
1206
	    case PROCESSOR_K1OM:
1238
	    case PROCESSOR_GENERIC64:
1207
	    case PROCESSOR_GENERIC64:
1239
	      patt = alt_long_patt;
-
 
1240
	      break;
-
 
1241
	    case PROCESSOR_K6:
1208
	    case PROCESSOR_K6:
1242
	    case PROCESSOR_ATHLON:
1209
	    case PROCESSOR_ATHLON:
1243
	    case PROCESSOR_K8:
1210
	    case PROCESSOR_K8:
1244
	    case PROCESSOR_AMDFAM10:
1211
	    case PROCESSOR_AMDFAM10:
1245
	    case PROCESSOR_BD:
1212
	    case PROCESSOR_BD:
-
 
1213
	    case PROCESSOR_ZNVER:
1246
	    case PROCESSOR_BT:
1214
	    case PROCESSOR_BT:
1247
	      patt = alt_short_patt;
1215
	      patt = alt_patt;
1248
	      break;
1216
	      break;
1249
	    case PROCESSOR_I386:
1217
	    case PROCESSOR_I386:
1250
	    case PROCESSOR_I486:
1218
	    case PROCESSOR_I486:
1251
	    case PROCESSOR_PENTIUM:
1219
	    case PROCESSOR_PENTIUM:
1252
	    case PROCESSOR_PENTIUMPRO:
1220
	    case PROCESSOR_PENTIUMPRO:
-
 
1221
	    case PROCESSOR_IAMCU:
1253
	    case PROCESSOR_GENERIC32:
1222
	    case PROCESSOR_GENERIC32:
1254
	      patt = f32_patt;
1223
	      patt = f32_patt;
1255
	      break;
1224
	      break;
1256
	    }
1225
	    }
1257
	}
1226
	}
Line 1266... Line 1235...
1266
	      break;
1235
	      break;
Line 1267... Line 1236...
1267
 
1236
 
1268
	    case PROCESSOR_I386:
1237
	    case PROCESSOR_I386:
1269
	    case PROCESSOR_I486:
1238
	    case PROCESSOR_I486:
-
 
1239
	    case PROCESSOR_PENTIUM:
1270
	    case PROCESSOR_PENTIUM:
1240
	    case PROCESSOR_IAMCU:
1271
	    case PROCESSOR_K6:
1241
	    case PROCESSOR_K6:
1272
	    case PROCESSOR_ATHLON:
1242
	    case PROCESSOR_ATHLON:
1273
	    case PROCESSOR_K8:
1243
	    case PROCESSOR_K8:
1274
	    case PROCESSOR_AMDFAM10:
1244
	    case PROCESSOR_AMDFAM10:
-
 
1245
	    case PROCESSOR_BD:
1275
	    case PROCESSOR_BD:
1246
	    case PROCESSOR_ZNVER:
1276
	    case PROCESSOR_BT:
1247
	    case PROCESSOR_BT:
1277
	    case PROCESSOR_GENERIC32:
1248
	    case PROCESSOR_GENERIC32:
1278
	      /* We use cpu_arch_isa_flags to check if we CAN optimize
1249
	      /* We use cpu_arch_isa_flags to check if we CAN optimize
1279
		 with nops.  */
1250
		 with nops.  */
1280
	      if (fragP->tc_frag_data.isa_flags.bitfield.cpunop)
1251
	      if (fragP->tc_frag_data.isa_flags.bitfield.cpunop)
1281
		patt = alt_short_patt;
1252
		patt = alt_patt;
1282
	      else
1253
	      else
1283
		patt = f32_patt;
1254
		patt = f32_patt;
1284
	      break;
1255
	      break;
1285
	    case PROCESSOR_PENTIUMPRO:
1256
	    case PROCESSOR_PENTIUMPRO:
Line 1289... Line 1260...
1289
	    case PROCESSOR_CORE2:
1260
	    case PROCESSOR_CORE2:
1290
	    case PROCESSOR_COREI7:
1261
	    case PROCESSOR_COREI7:
1291
	    case PROCESSOR_L1OM:
1262
	    case PROCESSOR_L1OM:
1292
	    case PROCESSOR_K1OM:
1263
	    case PROCESSOR_K1OM:
1293
	      if (fragP->tc_frag_data.isa_flags.bitfield.cpunop)
1264
	      if (fragP->tc_frag_data.isa_flags.bitfield.cpunop)
1294
		patt = alt_long_patt;
1265
		patt = alt_patt;
1295
	      else
1266
	      else
1296
		patt = f32_patt;
1267
		patt = f32_patt;
1297
	      break;
1268
	      break;
1298
	    case PROCESSOR_GENERIC64:
1269
	    case PROCESSOR_GENERIC64:
1299
	      patt = alt_long_patt;
1270
	      patt = alt_patt;
1300
	      break;
1271
	      break;
1301
	    }
1272
	    }
1302
	}
1273
	}
Line 1303... Line 1274...
1303
 
1274
 
Line 1325... Line 1296...
1325
	      fragP->fr_literal[fragP->fr_fix + 1] = count - 2;
1296
	      fragP->fr_literal[fragP->fr_fix + 1] = count - 2;
1326
	    }
1297
	    }
1327
	}
1298
	}
1328
      else
1299
      else
1329
	{
1300
	{
1330
	  /* Maximum length of an instruction is 15 byte.  If the
1301
	  /* Maximum length of an instruction is 10 byte.  If the
1331
	     padding is greater than 15 bytes and we don't use jump,
1302
	     padding is greater than 10 bytes and we don't use jump,
1332
	     we have to break it into smaller pieces.  */
1303
	     we have to break it into smaller pieces.  */
1333
	  int padding = count;
1304
	  int padding = count;
1334
	  while (padding > 15)
1305
	  while (padding > 10)
1335
	    {
1306
	    {
1336
	      padding -= 15;
1307
	      padding -= 10;
1337
	      memcpy (fragP->fr_literal + fragP->fr_fix + padding,
1308
	      memcpy (fragP->fr_literal + fragP->fr_fix + padding,
1338
		      patt [14], 15);
1309
		      patt [9], 10);
1339
	    }
1310
	    }
Line 1340... Line 1311...
1340
 
1311
 
1341
	  if (padding)
1312
	  if (padding)
1342
	    memcpy (fragP->fr_literal + fragP->fr_fix,
1313
	    memcpy (fragP->fr_literal + fragP->fr_fix,
Line 1417... Line 1388...
1417
    default:
1388
    default:
1418
      abort ();
1389
      abort ();
1419
    }
1390
    }
1420
}
1391
}
Line 1421... Line -...
1421
 
-
 
1422
static INLINE void
-
 
1423
cpu_flags_set (union i386_cpu_flags *x, unsigned int v)
-
 
1424
{
-
 
1425
  switch (ARRAY_SIZE(x->array))
-
 
1426
    {
-
 
1427
    case 3:
-
 
1428
      x->array[2] = v;
-
 
1429
    case 2:
-
 
1430
      x->array[1] = v;
-
 
1431
    case 1:
-
 
1432
      x->array[0] = v;
-
 
1433
      break;
-
 
1434
    default:
-
 
1435
      abort ();
-
 
1436
    }
-
 
1437
}
-
 
1438
 
1392
 
1439
static INLINE int
1393
static INLINE int
1440
cpu_flags_equal (const union i386_cpu_flags *x,
1394
cpu_flags_equal (const union i386_cpu_flags *x,
1441
		 const union i386_cpu_flags *y)
1395
		 const union i386_cpu_flags *y)
1442
{
1396
{
Line 1515... Line 1469...
1515
      abort ();
1469
      abort ();
1516
    }
1470
    }
1517
  return x;
1471
  return x;
1518
}
1472
}
Line -... Line 1473...
-
 
1473
 
-
 
1474
static int
-
 
1475
valid_iamcu_cpu_flags (const i386_cpu_flags *flags)
-
 
1476
{
-
 
1477
  if (cpu_arch_isa == PROCESSOR_IAMCU)
-
 
1478
    {
-
 
1479
      static const i386_cpu_flags iamcu_flags = CPU_IAMCU_COMPAT_FLAGS;
-
 
1480
      i386_cpu_flags compat_flags;
-
 
1481
      compat_flags = cpu_flags_and_not (*flags, iamcu_flags);
-
 
1482
      return cpu_flags_all_zero (&compat_flags);
-
 
1483
    }
-
 
1484
  else
-
 
1485
    return 1;
-
 
1486
}
1519
 
1487
 
1520
#define CPU_FLAGS_ARCH_MATCH		0x1
1488
#define CPU_FLAGS_ARCH_MATCH		0x1
1521
#define CPU_FLAGS_64BIT_MATCH		0x2
1489
#define CPU_FLAGS_64BIT_MATCH		0x2
1522
#define CPU_FLAGS_AES_MATCH		0x4
1490
#define CPU_FLAGS_AES_MATCH		0x4
1523
#define CPU_FLAGS_PCLMUL_MATCH		0x8
1491
#define CPU_FLAGS_PCLMUL_MATCH		0x8
Line 1663... Line 1631...
1663
static const i386_operand_type imm64 = OPERAND_TYPE_IMM64;
1631
static const i386_operand_type imm64 = OPERAND_TYPE_IMM64;
1664
static const i386_operand_type imm16_32 = OPERAND_TYPE_IMM16_32;
1632
static const i386_operand_type imm16_32 = OPERAND_TYPE_IMM16_32;
1665
static const i386_operand_type imm16_32s = OPERAND_TYPE_IMM16_32S;
1633
static const i386_operand_type imm16_32s = OPERAND_TYPE_IMM16_32S;
1666
static const i386_operand_type imm16_32_32s = OPERAND_TYPE_IMM16_32_32S;
1634
static const i386_operand_type imm16_32_32s = OPERAND_TYPE_IMM16_32_32S;
1667
static const i386_operand_type vec_imm4 = OPERAND_TYPE_VEC_IMM4;
1635
static const i386_operand_type vec_imm4 = OPERAND_TYPE_VEC_IMM4;
1668
static const i386_operand_type regbnd = OPERAND_TYPE_REGBND;
-
 
1669
static const i386_operand_type vec_disp8 = OPERAND_TYPE_VEC_DISP8;
-
 
Line 1670... Line 1636...
1670
 
1636
 
1671
enum operand_type
1637
enum operand_type
1672
{
1638
{
1673
  reg,
1639
  reg,
Line 1739... Line 1705...
1739
static INLINE int
1705
static INLINE int
1740
match_mem_size (const insn_template *t, unsigned int j)
1706
match_mem_size (const insn_template *t, unsigned int j)
1741
{
1707
{
1742
  return (match_reg_size (t, j)
1708
  return (match_reg_size (t, j)
1743
	  && !((i.types[j].bitfield.unspecified
1709
	  && !((i.types[j].bitfield.unspecified
-
 
1710
		&& !i.broadcast
1744
		&& !t->operand_types[j].bitfield.unspecified)
1711
		&& !t->operand_types[j].bitfield.unspecified)
1745
	       || (i.types[j].bitfield.fword
1712
	       || (i.types[j].bitfield.fword
1746
		   && !t->operand_types[j].bitfield.fword)
1713
		   && !t->operand_types[j].bitfield.fword)
1747
	       || (i.types[j].bitfield.tbyte
1714
	       || (i.types[j].bitfield.tbyte
1748
		   && !t->operand_types[j].bitfield.tbyte)
1715
		   && !t->operand_types[j].bitfield.tbyte)
Line 1919... Line 1886...
1919
  else
1886
  else
1920
    return 0;
1887
    return 0;
1921
}
1888
}
Line 1922... Line 1889...
1922
 
1889
 
1923
static INLINE int
1890
static INLINE int
1924
fits_in_signed_byte (offsetT num)
1891
fits_in_signed_byte (addressT num)
1925
{
1892
{
1926
  return (num >= -128) && (num <= 127);
1893
  return num + 0x80 <= 0xff;
Line 1927... Line 1894...
1927
}
1894
}
1928
 
1895
 
1929
static INLINE int
1896
static INLINE int
1930
fits_in_unsigned_byte (offsetT num)
1897
fits_in_unsigned_byte (addressT num)
1931
{
1898
{
Line 1932... Line 1899...
1932
  return (num & 0xff) == num;
1899
  return num <= 0xff;
1933
}
1900
}
1934
 
1901
 
1935
static INLINE int
1902
static INLINE int
1936
fits_in_unsigned_word (offsetT num)
1903
fits_in_unsigned_word (addressT num)
Line 1937... Line 1904...
1937
{
1904
{
1938
  return (num & 0xffff) == num;
1905
  return num <= 0xffff;
1939
}
1906
}
1940
 
1907
 
1941
static INLINE int
1908
static INLINE int
Line 1942... Line 1909...
1942
fits_in_signed_word (offsetT num)
1909
fits_in_signed_word (addressT num)
1943
{
1910
{
1944
  return (-32768 <= num) && (num <= 32767);
1911
  return num + 0x8000 <= 0xffff;
1945
}
1912
}
1946
 
1913
 
1947
static INLINE int
1914
static INLINE int
1948
fits_in_signed_long (offsetT num ATTRIBUTE_UNUSED)
1915
fits_in_signed_long (addressT num ATTRIBUTE_UNUSED)
1949
{
-
 
1950
#ifndef BFD64
1916
{
1951
  return 1;
1917
#ifndef BFD64
Line 1952... Line 1918...
1952
#else
1918
  return 1;
1953
  return (!(((offsetT) -1 << 31) & num)
1919
#else
1954
	  || (((offsetT) -1 << 31) & num) == ((offsetT) -1 << 31));
1920
  return num + 0x80000000 <= 0xffffffff;
1955
#endif
1921
#endif
1956
}				/* fits_in_signed_long() */
1922
}				/* fits_in_signed_long() */
1957
 
1923
 
1958
static INLINE int
1924
static INLINE int
1959
fits_in_unsigned_long (offsetT num ATTRIBUTE_UNUSED)
1925
fits_in_unsigned_long (addressT num ATTRIBUTE_UNUSED)
1960
{
1926
{
Line 1961... Line 1927...
1961
#ifndef BFD64
1927
#ifndef BFD64
1962
  return 1;
1928
  return 1;
Line 2226... Line 2192...
2226
  int ask_naked_reg = 0;
2192
  int ask_naked_reg = 0;
Line 2227... Line 2193...
2227
 
2193
 
2228
  SKIP_WHITESPACE ();
2194
  SKIP_WHITESPACE ();
2229
  if (!is_end_of_line[(unsigned char) *input_line_pointer])
2195
  if (!is_end_of_line[(unsigned char) *input_line_pointer])
2230
    {
2196
    {
2231
      char *string = input_line_pointer;
2197
      char *string;
Line 2232... Line 2198...
2232
      int e = get_symbol_end ();
2198
      int e = get_symbol_name (&string);
2233
 
2199
 
2234
      if (strcmp (string, "prefix") == 0)
2200
      if (strcmp (string, "prefix") == 0)
2235
	ask_naked_reg = 1;
2201
	ask_naked_reg = 1;
2236
      else if (strcmp (string, "noprefix") == 0)
2202
      else if (strcmp (string, "noprefix") == 0)
2237
	ask_naked_reg = -1;
2203
	ask_naked_reg = -1;
2238
      else
2204
      else
2239
	as_bad (_("bad argument to syntax directive."));
2205
	as_bad (_("bad argument to syntax directive."));
2240
      *input_line_pointer = e;
2206
      (void) restore_line_pointer (e);
Line 2241... Line 2207...
2241
    }
2207
    }
Line 2287... Line 2253...
2287
 
2253
 
Line 2288... Line 2254...
2288
  SKIP_WHITESPACE ();
2254
  SKIP_WHITESPACE ();
2289
 
2255
 
2290
  if (!is_end_of_line[(unsigned char) *input_line_pointer])
2256
  if (!is_end_of_line[(unsigned char) *input_line_pointer])
2291
    {
2257
    {
Line 2292... Line 2258...
2292
      char *string = input_line_pointer;
2258
      char *string;
2293
      int e = get_symbol_end ();
2259
      int e = get_symbol_name (&string);
2294
 
2260
 
2295
      if (strcmp (string, "none") == 0)
2261
      if (strcmp (string, "none") == 0)
2296
	*kind = check_none;
2262
	*kind = check_none;
2297
      else if (strcmp (string, "warning") == 0)
2263
      else if (strcmp (string, "warning") == 0)
2298
	*kind = check_warning;
2264
	*kind = check_warning;
2299
      else if (strcmp (string, "error") == 0)
2265
      else if (strcmp (string, "error") == 0)
2300
	*kind = check_error;
2266
	*kind = check_error;
2301
      else
2267
      else
2302
	as_bad (_("bad argument to %s_check directive."), str);
2268
	as_bad (_("bad argument to %s_check directive."), str);
2303
      *input_line_pointer = e;
2269
      (void) restore_line_pointer (e);
Line 2304... Line 2270...
2304
    }
2270
    }
Line 2326... Line 2292...
2326
      arch = cpu_arch_name;
2292
      arch = cpu_arch_name;
2327
      if (!arch)
2293
      if (!arch)
2328
	arch = default_arch;
2294
	arch = default_arch;
2329
    }
2295
    }
Line -... Line 2296...
-
 
2296
 
-
 
2297
  /* If we are targeting Intel MCU, we must enable it.  */
-
 
2298
  if (get_elf_backend_data (stdoutput)->elf_machine_code != EM_IAMCU
-
 
2299
      || new_flag.bitfield.cpuiamcu)
-
 
2300
    return;
2330
 
2301
 
2331
  /* If we are targeting Intel L1OM, we must enable it.  */
2302
  /* If we are targeting Intel L1OM, we must enable it.  */
2332
  if (get_elf_backend_data (stdoutput)->elf_machine_code != EM_L1OM
2303
  if (get_elf_backend_data (stdoutput)->elf_machine_code != EM_L1OM
2333
      || new_flag.bitfield.cpul1om)
2304
      || new_flag.bitfield.cpul1om)
Line 2347... Line 2318...
2347
{
2318
{
2348
  SKIP_WHITESPACE ();
2319
  SKIP_WHITESPACE ();
Line 2349... Line 2320...
2349
 
2320
 
2350
  if (!is_end_of_line[(unsigned char) *input_line_pointer])
2321
  if (!is_end_of_line[(unsigned char) *input_line_pointer])
2351
    {
2322
    {
2352
      char *string = input_line_pointer;
2323
      char *string;
2353
      int e = get_symbol_end ();
2324
      int e = get_symbol_name (&string);
2354
      unsigned int j;
2325
      unsigned int j;
Line 2355... Line 2326...
2355
      i386_cpu_flags flags;
2326
      i386_cpu_flags flags;
2356
 
2327
 
Line 2389... Line 2360...
2389
		flags = cpu_flags_or (cpu_arch_flags,
2360
		flags = cpu_flags_or (cpu_arch_flags,
2390
				      cpu_arch[j].flags);
2361
				      cpu_arch[j].flags);
2391
	      else
2362
	      else
2392
		flags = cpu_flags_and_not (cpu_arch_flags,
2363
		flags = cpu_flags_and_not (cpu_arch_flags,
2393
					   cpu_arch[j].flags);
2364
					   cpu_arch[j].flags);
-
 
2365
 
-
 
2366
	      if (!valid_iamcu_cpu_flags (&flags))
-
 
2367
		as_fatal (_("`%s' isn't valid for Intel MCU"),
-
 
2368
			  cpu_arch[j].name);
2394
	      if (!cpu_flags_equal (&flags, &cpu_arch_flags))
2369
	      else if (!cpu_flags_equal (&flags, &cpu_arch_flags))
2395
		{
2370
		{
2396
		  if (cpu_sub_arch_name)
2371
		  if (cpu_sub_arch_name)
2397
		    {
2372
		    {
2398
		      char *name = cpu_sub_arch_name;
2373
		      char *name = cpu_sub_arch_name;
2399
		      cpu_sub_arch_name = concat (name,
2374
		      cpu_sub_arch_name = concat (name,
Line 2404... Line 2379...
2404
		  else
2379
		  else
2405
		    cpu_sub_arch_name = xstrdup (cpu_arch[j].name);
2380
		    cpu_sub_arch_name = xstrdup (cpu_arch[j].name);
2406
		  cpu_arch_flags = flags;
2381
		  cpu_arch_flags = flags;
2407
		  cpu_arch_isa_flags = flags;
2382
		  cpu_arch_isa_flags = flags;
2408
		}
2383
		}
2409
	      *input_line_pointer = e;
2384
	      (void) restore_line_pointer (e);
2410
	      demand_empty_rest_of_line ();
2385
	      demand_empty_rest_of_line ();
2411
	      return;
2386
	      return;
2412
	    }
2387
	    }
2413
	}
2388
	}
2414
      if (j >= ARRAY_SIZE (cpu_arch))
2389
      if (j >= ARRAY_SIZE (cpu_arch))
Line 2421... Line 2396...
2421
 
2396
 
2422
  no_cond_jump_promotion = 0;
2397
  no_cond_jump_promotion = 0;
2423
  if (*input_line_pointer == ','
2398
  if (*input_line_pointer == ','
2424
      && !is_end_of_line[(unsigned char) input_line_pointer[1]])
2399
      && !is_end_of_line[(unsigned char) input_line_pointer[1]])
-
 
2400
    {
-
 
2401
      char *string;
-
 
2402
      char e;
2425
    {
2403
 
2426
      char *string = ++input_line_pointer;
2404
      ++input_line_pointer;
Line 2427... Line 2405...
2427
      int e = get_symbol_end ();
2405
      e = get_symbol_name (&string);
2428
 
2406
 
2429
      if (strcmp (string, "nojumps") == 0)
2407
      if (strcmp (string, "nojumps") == 0)
2430
	no_cond_jump_promotion = 1;
2408
	no_cond_jump_promotion = 1;
2431
      else if (strcmp (string, "jumps") == 0)
2409
      else if (strcmp (string, "jumps") == 0)
2432
	;
2410
	;
Line 2433... Line 2411...
2433
      else
2411
      else
2434
	as_bad (_("no such architecture modifier: `%s'"), string);
2412
	as_bad (_("no such architecture modifier: `%s'"), string);
Line 2435... Line 2413...
2435
 
2413
 
2436
      *input_line_pointer = e;
2414
      (void) restore_line_pointer (e);
Line 2454... Line 2432...
2454
      if (OUTPUT_FLAVOR != bfd_target_elf_flavour
2432
      if (OUTPUT_FLAVOR != bfd_target_elf_flavour
2455
	  || flag_code != CODE_64BIT)
2433
	  || flag_code != CODE_64BIT)
2456
	as_fatal (_("Intel K1OM is 64bit ELF only"));
2434
	as_fatal (_("Intel K1OM is 64bit ELF only"));
2457
      return bfd_arch_k1om;
2435
      return bfd_arch_k1om;
2458
    }
2436
    }
-
 
2437
  else if (cpu_arch_isa == PROCESSOR_IAMCU)
-
 
2438
    {
-
 
2439
      if (OUTPUT_FLAVOR != bfd_target_elf_flavour
-
 
2440
	  || flag_code == CODE_64BIT)
-
 
2441
	as_fatal (_("Intel MCU is 32bit ELF only"));
-
 
2442
      return bfd_arch_iamcu;
-
 
2443
    }
2459
  else
2444
  else
2460
    return bfd_arch_i386;
2445
    return bfd_arch_i386;
2461
}
2446
}
Line 2462... Line 2447...
2462
 
2447
 
Line 2482... Line 2467...
2482
      else if (default_arch[6] == '\0')
2467
      else if (default_arch[6] == '\0')
2483
	return bfd_mach_x86_64;
2468
	return bfd_mach_x86_64;
2484
      else
2469
      else
2485
	return bfd_mach_x64_32;
2470
	return bfd_mach_x64_32;
2486
    }
2471
    }
2487
  else if (!strcmp (default_arch, "i386"))
2472
  else if (!strcmp (default_arch, "i386")
-
 
2473
	   || !strcmp (default_arch, "iamcu"))
-
 
2474
    {
-
 
2475
      if (cpu_arch_isa == PROCESSOR_IAMCU)
-
 
2476
	{
-
 
2477
	  if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
-
 
2478
	    as_fatal (_("Intel MCU is 32bit ELF only"));
-
 
2479
	  return bfd_mach_i386_iamcu;
-
 
2480
	}
-
 
2481
      else
2488
    return bfd_mach_i386_i386;
2482
	return bfd_mach_i386_i386;
-
 
2483
    }
2489
  else
2484
  else
2490
    as_fatal (_("unknown architecture"));
2485
    as_fatal (_("unknown architecture"));
2491
}
2486
}
2492

2487

2493
void
2488
void
Line 2796... Line 2791...
2796

2791

2797
static bfd_reloc_code_real_type
2792
static bfd_reloc_code_real_type
2798
reloc (unsigned int size,
2793
reloc (unsigned int size,
2799
       int pcrel,
2794
       int pcrel,
2800
       int sign,
2795
       int sign,
2801
       int bnd_prefix,
-
 
2802
       bfd_reloc_code_real_type other)
2796
       bfd_reloc_code_real_type other)
2803
{
2797
{
2804
  if (other != NO_RELOC)
2798
  if (other != NO_RELOC)
2805
    {
2799
    {
2806
      reloc_howto_type *rel;
2800
      reloc_howto_type *rel;
Line 2809... Line 2803...
2809
	switch (other)
2803
	switch (other)
2810
	  {
2804
	  {
2811
	  case BFD_RELOC_X86_64_GOT32:
2805
	  case BFD_RELOC_X86_64_GOT32:
2812
	    return BFD_RELOC_X86_64_GOT64;
2806
	    return BFD_RELOC_X86_64_GOT64;
2813
	    break;
2807
	    break;
-
 
2808
	  case BFD_RELOC_X86_64_GOTPLT64:
-
 
2809
	    return BFD_RELOC_X86_64_GOTPLT64;
-
 
2810
	    break;
2814
	  case BFD_RELOC_X86_64_PLTOFF64:
2811
	  case BFD_RELOC_X86_64_PLTOFF64:
2815
	    return BFD_RELOC_X86_64_PLTOFF64;
2812
	    return BFD_RELOC_X86_64_PLTOFF64;
2816
	    break;
2813
	    break;
2817
	  case BFD_RELOC_X86_64_GOTPC32:
2814
	  case BFD_RELOC_X86_64_GOTPC32:
2818
	    other = BFD_RELOC_X86_64_GOTPC64;
2815
	    other = BFD_RELOC_X86_64_GOTPC64;
Line 2832... Line 2829...
2832
 
2829
 
2833
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
2830
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
2834
      if (other == BFD_RELOC_SIZE32)
2831
      if (other == BFD_RELOC_SIZE32)
2835
	{
2832
	{
2836
	  if (size == 8)
2833
	  if (size == 8)
2837
	    return BFD_RELOC_SIZE64;
2834
	    other = BFD_RELOC_SIZE64;
-
 
2835
	  if (pcrel)
2838
	  if (pcrel)
2836
	    {
-
 
2837
	      as_bad (_("there are no pc-relative size relocations"));
-
 
2838
	      return NO_RELOC;
2839
	    as_bad (_("there are no pc-relative size relocations"));
2839
	    }
2840
	}
2840
	}
Line 2841... Line 2841...
2841
#endif
2841
#endif
2842
 
2842
 
Line 2869... Line 2869...
2869
	as_bad (_("there are no unsigned pc-relative relocations"));
2869
	as_bad (_("there are no unsigned pc-relative relocations"));
2870
      switch (size)
2870
      switch (size)
2871
	{
2871
	{
2872
	case 1: return BFD_RELOC_8_PCREL;
2872
	case 1: return BFD_RELOC_8_PCREL;
2873
	case 2: return BFD_RELOC_16_PCREL;
2873
	case 2: return BFD_RELOC_16_PCREL;
2874
	case 4: return (bnd_prefix && object_64bit
-
 
2875
			? BFD_RELOC_X86_64_PC32_BND
-
 
2876
			: BFD_RELOC_32_PCREL);
2874
	case 4: return BFD_RELOC_32_PCREL;
2877
	case 8: return BFD_RELOC_64_PCREL;
2875
	case 8: return BFD_RELOC_64_PCREL;
2878
	}
2876
	}
2879
      as_bad (_("cannot do %u byte pc-relative relocation"), size);
2877
      as_bad (_("cannot do %u byte pc-relative relocation"), size);
2880
    }
2878
    }
2881
  else
2879
  else
Line 2930... Line 2928...
2930
  if (fixP->fx_r_type == BFD_RELOC_SIZE32
2928
  if (fixP->fx_r_type == BFD_RELOC_SIZE32
2931
      || fixP->fx_r_type == BFD_RELOC_SIZE64
2929
      || fixP->fx_r_type == BFD_RELOC_SIZE64
2932
      || fixP->fx_r_type == BFD_RELOC_386_GOTOFF
2930
      || fixP->fx_r_type == BFD_RELOC_386_GOTOFF
2933
      || fixP->fx_r_type == BFD_RELOC_386_PLT32
2931
      || fixP->fx_r_type == BFD_RELOC_386_PLT32
2934
      || fixP->fx_r_type == BFD_RELOC_386_GOT32
2932
      || fixP->fx_r_type == BFD_RELOC_386_GOT32
-
 
2933
      || fixP->fx_r_type == BFD_RELOC_386_GOT32X
2935
      || fixP->fx_r_type == BFD_RELOC_386_TLS_GD
2934
      || fixP->fx_r_type == BFD_RELOC_386_TLS_GD
2936
      || fixP->fx_r_type == BFD_RELOC_386_TLS_LDM
2935
      || fixP->fx_r_type == BFD_RELOC_386_TLS_LDM
2937
      || fixP->fx_r_type == BFD_RELOC_386_TLS_LDO_32
2936
      || fixP->fx_r_type == BFD_RELOC_386_TLS_LDO_32
2938
      || fixP->fx_r_type == BFD_RELOC_386_TLS_IE_32
2937
      || fixP->fx_r_type == BFD_RELOC_386_TLS_IE_32
2939
      || fixP->fx_r_type == BFD_RELOC_386_TLS_IE
2938
      || fixP->fx_r_type == BFD_RELOC_386_TLS_IE
Line 2943... Line 2942...
2943
      || fixP->fx_r_type == BFD_RELOC_386_TLS_GOTDESC
2942
      || fixP->fx_r_type == BFD_RELOC_386_TLS_GOTDESC
2944
      || fixP->fx_r_type == BFD_RELOC_386_TLS_DESC_CALL
2943
      || fixP->fx_r_type == BFD_RELOC_386_TLS_DESC_CALL
2945
      || fixP->fx_r_type == BFD_RELOC_X86_64_PLT32
2944
      || fixP->fx_r_type == BFD_RELOC_X86_64_PLT32
2946
      || fixP->fx_r_type == BFD_RELOC_X86_64_GOT32
2945
      || fixP->fx_r_type == BFD_RELOC_X86_64_GOT32
2947
      || fixP->fx_r_type == BFD_RELOC_X86_64_GOTPCREL
2946
      || fixP->fx_r_type == BFD_RELOC_X86_64_GOTPCREL
-
 
2947
      || fixP->fx_r_type == BFD_RELOC_X86_64_GOTPCRELX
-
 
2948
      || fixP->fx_r_type == BFD_RELOC_X86_64_REX_GOTPCRELX
2948
      || fixP->fx_r_type == BFD_RELOC_X86_64_TLSGD
2949
      || fixP->fx_r_type == BFD_RELOC_X86_64_TLSGD
2949
      || fixP->fx_r_type == BFD_RELOC_X86_64_TLSLD
2950
      || fixP->fx_r_type == BFD_RELOC_X86_64_TLSLD
2950
      || fixP->fx_r_type == BFD_RELOC_X86_64_DTPOFF32
2951
      || fixP->fx_r_type == BFD_RELOC_X86_64_DTPOFF32
2951
      || fixP->fx_r_type == BFD_RELOC_X86_64_DTPOFF64
2952
      || fixP->fx_r_type == BFD_RELOC_X86_64_DTPOFF64
2952
      || fixP->fx_r_type == BFD_RELOC_X86_64_GOTTPOFF
2953
      || fixP->fx_r_type == BFD_RELOC_X86_64_GOTTPOFF
Line 3146... Line 3147...
3146
	 of RXB bits from REX.  */
3147
	 of RXB bits from REX.  */
3147
      i.vex.bytes[1] = (~i.rex & 0x7) << 5 | m;
3148
      i.vex.bytes[1] = (~i.rex & 0x7) << 5 | m;
Line 3148... Line 3149...
3148
 
3149
 
3149
      /* Check the REX.W bit.  */
3150
      /* Check the REX.W bit.  */
3150
      w = (i.rex & REX_W) ? 1 : 0;
-
 
3151
      if (i.tm.opcode_modifier.vexw)
-
 
3152
	{
-
 
3153
	  if (w)
-
 
3154
	    abort ();
-
 
3155
 
3151
      w = (i.rex & REX_W) ? 1 : 0;
3156
	  if (i.tm.opcode_modifier.vexw == VEXW1)
3152
      if (i.tm.opcode_modifier.vexw == VEXW1)
3157
	    w = 1;
-
 
Line 3158... Line 3153...
3158
	}
3153
	w = 1;
3159
 
3154
 
3160
      i.vex.bytes[2] = (w << 7
3155
      i.vex.bytes[2] = (w << 7
3161
			| register_specifier << 3
3156
			| register_specifier << 3
Line 3324... Line 3319...
3324
  else
3319
  else
3325
    {
3320
    {
3326
      if (i.rounding->type != saeonly)
3321
      if (i.rounding->type != saeonly)
3327
	i.vex.bytes[3] |= 0x10 | (i.rounding->type << 5);
3322
	i.vex.bytes[3] |= 0x10 | (i.rounding->type << 5);
3328
      else
3323
      else
3329
	i.vex.bytes[3] |= 0x10;
3324
	i.vex.bytes[3] |= 0x10 | (evexrcig << 5);
3330
    }
3325
    }
Line 3331... Line 3326...
3331
 
3326
 
3332
  if (i.mask && i.mask->mask)
3327
  if (i.mask && i.mask->mask)
3333
    i.vex.bytes[3] |= i.mask->mask->reg_num;
3328
    i.vex.bytes[3] |= i.mask->mask->reg_num;
Line 3354... Line 3349...
3354
		  i.tm.name);
3349
		  i.tm.name);
Line 3355... Line 3350...
3355
 
3350
 
3356
      i.operands = 0;
3351
      i.operands = 0;
Line -... Line 3352...
-
 
3352
    }
-
 
3353
 
-
 
3354
  if (i.tm.cpu_flags.bitfield.cpumwaitx && i.operands > 0)
-
 
3355
    {
-
 
3356
      /* MONITORX/MWAITX instructions have fixed operands with an opcode
-
 
3357
	 suffix which is coded in the same place as an 8-bit immediate
-
 
3358
	 field would be.
-
 
3359
	 Here we check those operands and remove them afterwards.  */
-
 
3360
      unsigned int x;
-
 
3361
 
-
 
3362
      if (i.operands != 3)
-
 
3363
	abort();
-
 
3364
 
-
 
3365
      for (x = 0; x < 2; x++)
-
 
3366
	if (register_number (i.op[x].regs) != x)
-
 
3367
	  goto bad_register_operand;
-
 
3368
 
-
 
3369
      /* Check for third operand for mwaitx/monitorx insn.  */
-
 
3370
      if (register_number (i.op[x].regs)
-
 
3371
	  != (x + (i.tm.extension_opcode == 0xfb)))
-
 
3372
	{
-
 
3373
bad_register_operand:
-
 
3374
	  as_bad (_("can't use register '%s%s' as operand %d in '%s'."),
-
 
3375
		  register_prefix, i.op[x].regs->reg_name, x+1,
-
 
3376
		  i.tm.name);
-
 
3377
	}
-
 
3378
 
-
 
3379
      i.operands = 0;
3357
    }
3380
    }
3358
 
3381
 
3359
  /* These AMD 3DNow! and SSE2 instructions have an opcode suffix
3382
  /* These AMD 3DNow! and SSE2 instructions have an opcode suffix
3360
     which is coded in the same place as an 8-bit immediate field
3383
     which is coded in the same place as an 8-bit immediate field
Line 3609... Line 3632...
3609
    {
3632
    {
3610
      /* UnixWare fsub no args is alias for fsubp, fadd -> faddp, etc.  */
3633
      /* UnixWare fsub no args is alias for fsubp, fadd -> faddp, etc.  */
3611
      as_warn (_("translating to `%sp'"), i.tm.name);
3634
      as_warn (_("translating to `%sp'"), i.tm.name);
3612
    }
3635
    }
Line -... Line 3636...
-
 
3636
 
-
 
3637
  if (i.tm.opcode_modifier.vex || i.tm.opcode_modifier.evex)
-
 
3638
    {
-
 
3639
      if (flag_code == CODE_16BIT)
-
 
3640
	{
-
 
3641
	  as_bad (_("instruction `%s' isn't supported in 16-bit mode."),
-
 
3642
		  i.tm.name);
-
 
3643
	  return;
-
 
3644
	}
3613
 
3645
 
3614
  if (i.tm.opcode_modifier.vex)
3646
      if (i.tm.opcode_modifier.vex)
3615
    build_vex_prefix (t);
-
 
3616
 
3647
	build_vex_prefix (t);
3617
  if (i.tm.opcode_modifier.evex)
3648
      else
-
 
3649
	build_evex_prefix ();
Line 3618... Line 3650...
3618
    build_evex_prefix ();
3650
    }
3619
 
3651
 
3620
  /* Handle conversion of 'int $3' --> special int3 insn.  XOP or FMA4
3652
  /* Handle conversion of 'int $3' --> special int3 insn.  XOP or FMA4
3621
     instructions may define INT_OPCODE as well, so avoid this corner
3653
     instructions may define INT_OPCODE as well, so avoid this corner
Line 3935... Line 3967...
3935
  while (*l != END_OF_INSN)
3967
  while (*l != END_OF_INSN)
3936
    {
3968
    {
3937
      /* Skip optional white space before operand.  */
3969
      /* Skip optional white space before operand.  */
3938
      if (is_space_char (*l))
3970
      if (is_space_char (*l))
3939
	++l;
3971
	++l;
3940
      if (!is_operand_char (*l) && *l != END_OF_INSN)
3972
      if (!is_operand_char (*l) && *l != END_OF_INSN && *l != '"')
3941
	{
3973
	{
3942
	  as_bad (_("invalid character %s before operand %d"),
3974
	  as_bad (_("invalid character %s before operand %d"),
3943
		  output_invalid (*l),
3975
		  output_invalid (*l),
3944
		  i.operands + 1);
3976
		  i.operands + 1);
3945
	  return NULL;
3977
	  return NULL;
3946
	}
3978
	}
3947
      token_start = l;	/* after white space */
3979
      token_start = l;	/* After white space.  */
3948
      paren_not_balanced = 0;
3980
      paren_not_balanced = 0;
3949
      while (paren_not_balanced || *l != ',')
3981
      while (paren_not_balanced || *l != ',')
3950
	{
3982
	{
3951
	  if (*l == END_OF_INSN)
3983
	  if (*l == END_OF_INSN)
3952
	    {
3984
	    {
Line 3961... Line 3993...
3961
		  return NULL;
3993
		  return NULL;
3962
		}
3994
		}
3963
	      else
3995
	      else
3964
		break;	/* we are done */
3996
		break;	/* we are done */
3965
	    }
3997
	    }
3966
	  else if (!is_operand_char (*l) && !is_space_char (*l))
3998
	  else if (!is_operand_char (*l) && !is_space_char (*l) && *l != '"')
3967
	    {
3999
	    {
3968
	      as_bad (_("invalid character %s in operand %d"),
4000
	      as_bad (_("invalid character %s in operand %d"),
3969
		      output_invalid (*l),
4001
		      output_invalid (*l),
3970
		      i.operands + 1);
4002
		      i.operands + 1);
3971
	      return NULL;
4003
	      return NULL;
Line 4372... Line 4404...
4372
 
4404
 
4373
      gas_assert (i.reg_operands == 2 || i.mask);
4405
      gas_assert (i.reg_operands == 2 || i.mask);
4374
      if (i.reg_operands == 2 && !i.mask)
4406
      if (i.reg_operands == 2 && !i.mask)
4375
	{
4407
	{
4376
	  gas_assert (i.types[0].bitfield.regxmm
-
 
4377
		      || i.types[0].bitfield.regymm
4408
	  gas_assert (i.types[0].bitfield.regxmm
4378
		      || i.types[0].bitfield.regzmm);
4409
		      || i.types[0].bitfield.regymm);
4379
	  gas_assert (i.types[2].bitfield.regxmm
-
 
4380
		      || i.types[2].bitfield.regymm
4410
	  gas_assert (i.types[2].bitfield.regxmm
4381
		      || i.types[2].bitfield.regzmm);
4411
		      || i.types[2].bitfield.regymm);
4382
	  if (operand_check == check_none)
4412
	  if (operand_check == check_none)
4383
	    return 0;
4413
	    return 0;
4384
	  if (register_number (i.op[0].regs)
4414
	  if (register_number (i.op[0].regs)
4385
	      != register_number (i.index_reg)
4415
	      != register_number (i.index_reg)
Line 4393... Line 4423...
4393
	      i.error = invalid_vector_register_set;
4423
	      i.error = invalid_vector_register_set;
4394
	      return 1;
4424
	      return 1;
4395
	    }
4425
	    }
4396
	  as_warn (_("mask, index, and destination registers should be distinct"));
4426
	  as_warn (_("mask, index, and destination registers should be distinct"));
4397
	}
4427
	}
-
 
4428
      else if (i.reg_operands == 1 && i.mask)
-
 
4429
	{
-
 
4430
	  if ((i.types[1].bitfield.regymm
-
 
4431
	       || i.types[1].bitfield.regzmm)
-
 
4432
	      && (register_number (i.op[1].regs)
-
 
4433
		  == register_number (i.index_reg)))
-
 
4434
	    {
-
 
4435
	      if (operand_check == check_error)
-
 
4436
		{
-
 
4437
		  i.error = invalid_vector_register_set;
-
 
4438
		  return 1;
-
 
4439
		}
-
 
4440
	      if (operand_check != check_none)
-
 
4441
		as_warn (_("index and destination registers should be distinct"));
-
 
4442
	    }
-
 
4443
	}
4398
    }
4444
    }
Line 4399... Line 4445...
4399
 
4445
 
4400
  /* Check if broadcast is supported by the instruction and is applied
4446
  /* Check if broadcast is supported by the instruction and is applied
4401
     to the memory operand.  */
4447
     to the memory operand.  */
Line 4419... Line 4465...
4419
      broadcasted_opnd_size = t->opcode_modifier.vecesize ? 64 : 32;
4465
      broadcasted_opnd_size = t->opcode_modifier.vecesize ? 64 : 32;
4420
      if (i.broadcast->type == BROADCAST_1TO16)
4466
      if (i.broadcast->type == BROADCAST_1TO16)
4421
	broadcasted_opnd_size <<= 4; /* Broadcast 1to16.  */
4467
	broadcasted_opnd_size <<= 4; /* Broadcast 1to16.  */
4422
      else if (i.broadcast->type == BROADCAST_1TO8)
4468
      else if (i.broadcast->type == BROADCAST_1TO8)
4423
	broadcasted_opnd_size <<= 3; /* Broadcast 1to8.  */
4469
	broadcasted_opnd_size <<= 3; /* Broadcast 1to8.  */
-
 
4470
      else if (i.broadcast->type == BROADCAST_1TO4)
-
 
4471
	broadcasted_opnd_size <<= 2; /* Broadcast 1to4.  */
-
 
4472
      else if (i.broadcast->type == BROADCAST_1TO2)
-
 
4473
	broadcasted_opnd_size <<= 1; /* Broadcast 1to2.  */
4424
      else
4474
      else
4425
	goto bad_broadcast;
4475
	goto bad_broadcast;
Line 4426... Line 4476...
4426
 
4476
 
4427
      if ((broadcasted_opnd_size == 256
4477
      if ((broadcasted_opnd_size == 256
Line 4670... Line 4720...
4670
	  && ((!operand_types[0].bitfield.regmmx
4720
	  && ((!operand_types[0].bitfield.regmmx
4671
	       && !operand_types[0].bitfield.regxmm
4721
	       && !operand_types[0].bitfield.regxmm
4672
	       && !operand_types[0].bitfield.regymm
4722
	       && !operand_types[0].bitfield.regymm
4673
	       && !operand_types[0].bitfield.regzmm)
4723
	       && !operand_types[0].bitfield.regzmm)
4674
	      || (!operand_types[t->operands > 1].bitfield.regmmx
4724
	      || (!operand_types[t->operands > 1].bitfield.regmmx
4675
		  && !!operand_types[t->operands > 1].bitfield.regxmm
4725
		  && operand_types[t->operands > 1].bitfield.regxmm
4676
		  && !!operand_types[t->operands > 1].bitfield.regymm
4726
		  && operand_types[t->operands > 1].bitfield.regymm
4677
		  && !!operand_types[t->operands > 1].bitfield.regzmm))
4727
		  && operand_types[t->operands > 1].bitfield.regzmm))
4678
	  && (t->base_opcode != 0x0fc7
4728
	  && (t->base_opcode != 0x0fc7
4679
	      || t->extension_opcode != 1 /* cmpxchg8b */))
4729
	      || t->extension_opcode != 1 /* cmpxchg8b */))
4680
	continue;
4730
	continue;
Line 4681... Line 4731...
4681
 
4731
 
Line 4687... Line 4737...
4687
		      && !intel_float_operand (t->name))
4737
		      && !intel_float_operand (t->name))
4688
		   : intel_float_operand (t->name) != 2)
4738
		   : intel_float_operand (t->name) != 2)
4689
	       && ((!operand_types[0].bitfield.regmmx
4739
	       && ((!operand_types[0].bitfield.regmmx
4690
		    && !operand_types[0].bitfield.regxmm)
4740
		    && !operand_types[0].bitfield.regxmm)
4691
		   || (!operand_types[t->operands > 1].bitfield.regmmx
4741
		   || (!operand_types[t->operands > 1].bitfield.regmmx
4692
		       && !!operand_types[t->operands > 1].bitfield.regxmm)))
4742
		       && operand_types[t->operands > 1].bitfield.regxmm)))
4693
	continue;
4743
	continue;
Line 4694... Line 4744...
4694
 
4744
 
4695
      /* Do not verify operands when there are none.  */
4745
      /* Do not verify operands when there are none.  */
4696
      else
4746
      else
Line 4744... Line 4794...
4744
		}
4794
		}
4745
	      break;
4795
	      break;
4746
	    }
4796
	    }
4747
	  }
4797
	  }
Line -... Line 4798...
-
 
4798
 
-
 
4799
      /* Force 0x8b encoding for "mov foo@GOT, %eax".  */
-
 
4800
      if (i.reloc[0] == BFD_RELOC_386_GOT32 && t->base_opcode == 0xa0)
-
 
4801
	continue;
4748
 
4802
 
4749
      /* We check register size if needed.  */
4803
      /* We check register size if needed.  */
4750
      check_register = t->opcode_modifier.checkregsize;
4804
      check_register = t->opcode_modifier.checkregsize;
4751
      overlap0 = operand_type_and (i.types[0], operand_types[0]);
4805
      overlap0 = operand_type_and (i.types[0], operand_types[0]);
4752
      switch (t->operands)
4806
      switch (t->operands)
Line 5433... Line 5487...
5433
		    register_prefix, i.op[op].regs->reg_name,
5487
		    register_prefix, i.op[op].regs->reg_name,
5434
		    i.suffix);
5488
		    i.suffix);
5435
	    return 0;
5489
	    return 0;
5436
	  }
5490
	  }
5437
#if REGISTER_WARNINGS
5491
#if REGISTER_WARNINGS
5438
	else
-
 
5439
	  as_warn (_("using `%s%s' instead of `%s%s' due to `%c' suffix"),
5492
	as_warn (_("using `%s%s' instead of `%s%s' due to `%c' suffix"),
5440
		   register_prefix,
5493
		 register_prefix,
5441
		   (i.op[op].regs + REGNAM_EAX - REGNAM_AX)->reg_name,
5494
		 (i.op[op].regs + REGNAM_EAX - REGNAM_AX)->reg_name,
5442
		   register_prefix,
-
 
5443
		   i.op[op].regs->reg_name,
5495
		 register_prefix, i.op[op].regs->reg_name, i.suffix);
5444
		   i.suffix);
-
 
5445
#endif
5496
#endif
5446
      }
5497
      }
5447
  /* Warn if the r prefix on a general reg is missing.  */
5498
    /* Warn if the r prefix on a general reg is present.  */
5448
    else if (i.types[op].bitfield.reg64
5499
    else if (i.types[op].bitfield.reg64
5449
	     && (i.tm.operand_types[op].bitfield.reg32
5500
	     && (i.tm.operand_types[op].bitfield.reg32
5450
		 || i.tm.operand_types[op].bitfield.acc))
5501
		 || i.tm.operand_types[op].bitfield.acc))
5451
      {
5502
      {
5452
	if (intel_syntax
5503
	if (intel_syntax
Line 5485... Line 5536...
5485
		i.op[op].regs->reg_name,
5536
		i.op[op].regs->reg_name,
5486
		i.tm.name,
5537
		i.tm.name,
5487
		i.suffix);
5538
		i.suffix);
5488
	return 0;
5539
	return 0;
5489
      }
5540
      }
5490
  /* Warn if the e prefix on a general reg is missing.  */
5541
    /* Warn if the r prefix on a general reg is missing.  */
5491
    else if ((i.types[op].bitfield.reg16
5542
    else if ((i.types[op].bitfield.reg16
5492
	      || i.types[op].bitfield.reg32)
5543
	      || i.types[op].bitfield.reg32)
5493
	     && (i.tm.operand_types[op].bitfield.reg32
5544
	     && (i.tm.operand_types[op].bitfield.reg32
5494
		 || i.tm.operand_types[op].bitfield.acc))
5545
		 || i.tm.operand_types[op].bitfield.acc))
5495
      {
5546
      {
Line 5530... Line 5581...
5530
		i.op[op].regs->reg_name,
5581
		i.op[op].regs->reg_name,
5531
		i.tm.name,
5582
		i.tm.name,
5532
		i.suffix);
5583
		i.suffix);
5533
	return 0;
5584
	return 0;
5534
      }
5585
      }
5535
  /* Warn if the e prefix on a general reg is present.  */
5586
    /* Warn if the e or r prefix on a general reg is present.  */
5536
    else if ((!quiet_warnings || flag_code == CODE_64BIT)
5587
    else if ((!quiet_warnings || flag_code == CODE_64BIT)
5537
	     && i.types[op].bitfield.reg32
5588
	     && (i.types[op].bitfield.reg32
-
 
5589
		 || i.types[op].bitfield.reg64)
5538
	     && (i.tm.operand_types[op].bitfield.reg16
5590
	     && (i.tm.operand_types[op].bitfield.reg16
5539
		 || i.tm.operand_types[op].bitfield.acc))
5591
		 || i.tm.operand_types[op].bitfield.acc))
5540
      {
5592
      {
5541
	/* Prohibit these changes in the 64bit mode, since the
5593
	/* Prohibit these changes in the 64bit mode, since the
5542
	   lowering is more complicated.  */
5594
	   lowering is more complicated.  */
Line 5545... Line 5597...
5545
	    as_bad (_("incorrect register `%s%s' used with `%c' suffix"),
5597
	    as_bad (_("incorrect register `%s%s' used with `%c' suffix"),
5546
		    register_prefix, i.op[op].regs->reg_name,
5598
		    register_prefix, i.op[op].regs->reg_name,
5547
		    i.suffix);
5599
		    i.suffix);
5548
	    return 0;
5600
	    return 0;
5549
	  }
5601
	  }
5550
	else
-
 
5551
#if REGISTER_WARNINGS
5602
#if REGISTER_WARNINGS
5552
	  as_warn (_("using `%s%s' instead of `%s%s' due to `%c' suffix"),
5603
	as_warn (_("using `%s%s' instead of `%s%s' due to `%c' suffix"),
5553
		   register_prefix,
5604
		 register_prefix,
5554
		   (i.op[op].regs + REGNAM_AX - REGNAM_EAX)->reg_name,
5605
		 (i.op[op].regs + REGNAM_AX - REGNAM_EAX)->reg_name,
5555
		   register_prefix,
-
 
5556
		   i.op[op].regs->reg_name,
5606
		 register_prefix, i.op[op].regs->reg_name, i.suffix);
5557
		   i.suffix);
-
 
5558
#endif
5607
#endif
5559
      }
5608
      }
5560
  return 1;
5609
  return 1;
5561
}
5610
}
Line 6137... Line 6186...
6137
		vvvv = dest;
6186
		vvvv = dest;
Line 6138... Line 6187...
6138
 
6187
 
6139
	      op = i.tm.operand_types[vvvv];
6188
	      op = i.tm.operand_types[vvvv];
6140
	      op.bitfield.regmem = 0;
6189
	      op.bitfield.regmem = 0;
6141
	      if ((dest + 1) >= i.operands
6190
	      if ((dest + 1) >= i.operands
6142
		  || (op.bitfield.reg32 != 1
6191
		  || (!op.bitfield.reg32
6143
		      && !op.bitfield.reg64 != 1
6192
		      && op.bitfield.reg64
6144
		      && !operand_type_equal (&op, ®xmm)
6193
		      && !operand_type_equal (&op, ®xmm)
6145
		      && !operand_type_equal (&op, ®ymm)
6194
		      && !operand_type_equal (&op, ®ymm)
6146
		      && !operand_type_equal (&op, ®zmm)
6195
		      && !operand_type_equal (&op, ®zmm)
6147
		      && !operand_type_equal (&op, ®mask)))
6196
		      && !operand_type_equal (&op, ®mask)))
Line 6720... Line 6769...
6720
      off = 0;
6769
      off = 0;
6721
    }
6770
    }
Line 6722... Line 6771...
6722
 
6771
 
6723
  /* 1 possible extra opcode + 4 byte displacement go in var part.
6772
  /* 1 possible extra opcode + 4 byte displacement go in var part.
6724
     Pass reloc in fr_var.  */
6773
     Pass reloc in fr_var.  */
6725
  frag_var (rs_machine_dependent, 5,
-
 
6726
	    ((!object_64bit
-
 
6727
	      || i.reloc[0] != NO_RELOC 
-
 
6728
	      || (i.bnd_prefix == NULL && !add_bnd_prefix))
-
 
6729
	     ? i.reloc[0]
-
 
6730
	     : BFD_RELOC_X86_64_PC32_BND),
-
 
6731
	    subtype, sym, off, p);
6774
  frag_var (rs_machine_dependent, 5, i.reloc[0], subtype, sym, off, p);
Line 6732... Line 6775...
6732
}
6775
}
6733
 
6776
 
6734
static void
6777
static void
Line 6802... Line 6845...
6802
    default:
6845
    default:
6803
      abort ();
6846
      abort ();
6804
    }
6847
    }
Line 6805... Line 6848...
6805
 
6848
 
6806
  fixP = fix_new_exp (frag_now, p - frag_now->fr_literal, size,
6849
  fixP = fix_new_exp (frag_now, p - frag_now->fr_literal, size,
6807
		      i.op[0].disps, 1, reloc (size, 1, 1,
-
 
6808
					       (i.bnd_prefix != NULL
-
 
6809
						|| add_bnd_prefix),
-
 
Line 6810... Line 6850...
6810
					       i.reloc[0]));
6850
		      i.op[0].disps, 1, reloc (size, 1, 1, i.reloc[0]));
6811
 
6851
 
6812
  /* All jumps handled here are signed, but don't use a signed limit
6852
  /* All jumps handled here are signed, but don't use a signed limit
6813
     check for 32 and 16 bit jumps as we want to allow wrap around at
6853
     check for 32 and 16 bit jumps as we want to allow wrap around at
Line 6871... Line 6911...
6871
	}
6911
	}
6872
      md_number_to_chars (p, n, size);
6912
      md_number_to_chars (p, n, size);
6873
    }
6913
    }
6874
  else
6914
  else
6875
    fix_new_exp (frag_now, p - frag_now->fr_literal, size,
6915
    fix_new_exp (frag_now, p - frag_now->fr_literal, size,
6876
		 i.op[1].imms, 0, reloc (size, 0, 0, 0, i.reloc[1]));
6916
		 i.op[1].imms, 0, reloc (size, 0, 0, i.reloc[1]));
6877
  if (i.op[0].imms->X_op != O_constant)
6917
  if (i.op[0].imms->X_op != O_constant)
6878
    as_bad (_("can't handle non absolute segment in `%s'"),
6918
    as_bad (_("can't handle non absolute segment in `%s'"),
6879
	    i.tm.name);
6919
	    i.tm.name);
6880
  md_number_to_chars (p + size, (valueT) i.op[0].imms->X_add_number, 2);
6920
  md_number_to_chars (p + size, (valueT) i.op[0].imms->X_add_number, 2);
6881
}
6921
}
Line 6908... Line 6948...
6908
      char *p;
6948
      char *p;
6909
      unsigned char *q;
6949
      unsigned char *q;
6910
      unsigned int j;
6950
      unsigned int j;
6911
      unsigned int prefix;
6951
      unsigned int prefix;
Line -... Line 6952...
-
 
6952
 
-
 
6953
      /* Some processors fail on LOCK prefix. This options makes
-
 
6954
	 assembler ignore LOCK prefix and serves as a workaround.  */
-
 
6955
      if (omit_lock_prefix)
-
 
6956
	{
-
 
6957
	  if (i.tm.base_opcode == LOCK_PREFIX_OPCODE)
-
 
6958
	    return;
-
 
6959
	  i.prefix[LOCK_PREFIX] = 0;
-
 
6960
	}
6912
 
6961
 
6913
      /* Since the VEX/EVEX prefix contains the implicit prefix, we
6962
      /* Since the VEX/EVEX prefix contains the implicit prefix, we
6914
	 don't need the explicit prefix.  */
6963
	 don't need the explicit prefix.  */
6915
      if (!i.tm.opcode_modifier.vex && !i.tm.opcode_modifier.evex)
6964
      if (!i.tm.opcode_modifier.vex && !i.tm.opcode_modifier.evex)
6916
	{
6965
	{
Line 6943... Line 6992...
6943
	      break;
6992
	      break;
6944
	    default:
6993
	    default:
6945
	      abort ();
6994
	      abort ();
6946
	    }
6995
	    }
Line -... Line 6996...
-
 
6996
 
-
 
6997
#if defined (OBJ_MAYBE_ELF) || defined (OBJ_ELF)
-
 
6998
	  /* For x32, add a dummy REX_OPCODE prefix for mov/add with
-
 
6999
	     R_X86_64_GOTTPOFF relocation so that linker can safely
-
 
7000
	     perform IE->LE optimization.  */
-
 
7001
	  if (x86_elf_abi == X86_64_X32_ABI
-
 
7002
	      && i.operands == 2
-
 
7003
	      && i.reloc[0] == BFD_RELOC_X86_64_GOTTPOFF
-
 
7004
	      && i.prefix[REX_PREFIX] == 0)
-
 
7005
	    add_prefix (REX_OPCODE);
-
 
7006
#endif
6947
 
7007
 
6948
	  /* The prefix bytes.  */
7008
	  /* The prefix bytes.  */
6949
	  for (j = ARRAY_SIZE (i.prefix), q = i.prefix; j > 0; j--, q++)
7009
	  for (j = ARRAY_SIZE (i.prefix), q = i.prefix; j > 0; j--, q++)
6950
	    if (*q)
7010
	    if (*q)
6951
	      FRAG_APPEND_1_CHAR (*q);
7011
	      FRAG_APPEND_1_CHAR (*q);
Line 7104... Line 7164...
7104
	    {
7164
	    {
7105
	      enum bfd_reloc_code_real reloc_type;
7165
	      enum bfd_reloc_code_real reloc_type;
7106
	      int size = disp_size (n);
7166
	      int size = disp_size (n);
7107
	      int sign = i.types[n].bitfield.disp32s;
7167
	      int sign = i.types[n].bitfield.disp32s;
7108
	      int pcrel = (i.flags[n] & Operand_PCrel) != 0;
7168
	      int pcrel = (i.flags[n] & Operand_PCrel) != 0;
-
 
7169
	      fixS *fixP;
Line 7109... Line 7170...
7109
 
7170
 
7110
	      /* We can't have 8 bit displacement here.  */
7171
	      /* We can't have 8 bit displacement here.  */
Line 7111... Line 7172...
7111
	      gas_assert (!i.types[n].bitfield.disp8);
7172
	      gas_assert (!i.types[n].bitfield.disp8);
Line 7130... Line 7191...
7130
		  /* We should find the immediate.  */
7191
		  /* We should find the immediate.  */
7131
		  gas_assert (sz != 0);
7192
		  gas_assert (sz != 0);
7132
		}
7193
		}
Line 7133... Line 7194...
7133
 
7194
 
7134
	      p = frag_more (size);
7195
	      p = frag_more (size);
7135
	      reloc_type = reloc (size, pcrel, sign,
-
 
7136
				  (i.bnd_prefix != NULL
-
 
7137
				   || add_bnd_prefix),
-
 
7138
				  i.reloc[n]);
7196
	      reloc_type = reloc (size, pcrel, sign, i.reloc[n]);
7139
	      if (GOT_symbol
7197
	      if (GOT_symbol
7140
		  && GOT_symbol == i.op[n].disps->X_add_symbol
7198
		  && GOT_symbol == i.op[n].disps->X_add_symbol
7141
		  && (((reloc_type == BFD_RELOC_32
7199
		  && (((reloc_type == BFD_RELOC_32
7142
			|| reloc_type == BFD_RELOC_X86_64_32S
7200
			|| reloc_type == BFD_RELOC_X86_64_32S
Line 7175... Line 7233...
7175
		    /* Don't do the adjustment for x86-64, as there
7233
		    /* Don't do the adjustment for x86-64, as there
7176
		       the pcrel addressing is relative to the _next_
7234
		       the pcrel addressing is relative to the _next_
7177
		       insn, and that is taken care of in other code.  */
7235
		       insn, and that is taken care of in other code.  */
7178
		    reloc_type = BFD_RELOC_X86_64_GOTPC32;
7236
		    reloc_type = BFD_RELOC_X86_64_GOTPC32;
7179
		}
7237
		}
7180
	      fix_new_exp (frag_now, p - frag_now->fr_literal, size,
7238
	      fixP = fix_new_exp (frag_now, p - frag_now->fr_literal,
7181
			   i.op[n].disps, pcrel, reloc_type);
7239
				  size, i.op[n].disps, pcrel,
-
 
7240
				  reloc_type);
-
 
7241
	      /* Check for "call/jmp *mem", "mov mem, %reg",
-
 
7242
		 "test %reg, mem" and "binop mem, %reg" where binop
-
 
7243
		 is one of adc, add, and, cmp, or, sbb, sub, xor
-
 
7244
		 instructions.  */
-
 
7245
	      if ((i.rm.mode == 2
-
 
7246
		   || (i.rm.mode == 0 && i.rm.regmem == 5))
-
 
7247
		  && ((i.operands == 1
-
 
7248
		       && i.tm.base_opcode == 0xff
-
 
7249
		       && (i.rm.reg == 2 || i.rm.reg == 4))
-
 
7250
		      || (i.operands == 2
-
 
7251
			  && (i.tm.base_opcode == 0x8b
-
 
7252
			      || i.tm.base_opcode == 0x85
-
 
7253
			      || (i.tm.base_opcode & 0xc7) == 0x03))))
-
 
7254
		{
-
 
7255
		  if (object_64bit)
-
 
7256
		    {
-
 
7257
		      fixP->fx_tcbit = i.rex != 0;
-
 
7258
		      if (i.base_reg
-
 
7259
			  && (i.base_reg->reg_num == RegRip
-
 
7260
			      || i.base_reg->reg_num == RegEip))
-
 
7261
		      fixP->fx_tcbit2 = 1;
-
 
7262
		    }
-
 
7263
		  else
-
 
7264
		    fixP->fx_tcbit2 = 1;
-
 
7265
		}
7182
	    }
7266
	    }
7183
	}
7267
	}
7184
    }
7268
    }
7185
}
7269
}
Line 7224... Line 7308...
7224
		sign = 1;
7308
		sign = 1;
7225
	      else
7309
	      else
7226
		sign = 0;
7310
		sign = 0;
Line 7227... Line 7311...
7227
 
7311
 
7228
	      p = frag_more (size);
7312
	      p = frag_more (size);
Line 7229... Line 7313...
7229
	      reloc_type = reloc (size, 0, sign, 0, i.reloc[n]);
7313
	      reloc_type = reloc (size, 0, sign, i.reloc[n]);
7230
 
7314
 
7231
	      /*   This is tough to explain.  We end up with this one if we
7315
	      /*   This is tough to explain.  We end up with this one if we
7232
	       * have operands that look like
7316
	       * have operands that look like
Line 7311... Line 7395...
7311
    }
7395
    }
7312
}
7396
}
7313

7397

7314
/* x86_cons_fix_new is called via the expression parsing code when a
7398
/* x86_cons_fix_new is called via the expression parsing code when a
7315
   reloc is needed.  We use this hook to get the correct .got reloc.  */
7399
   reloc is needed.  We use this hook to get the correct .got reloc.  */
7316
static enum bfd_reloc_code_real got_reloc = NO_RELOC;
-
 
7317
static int cons_sign = -1;
7400
static int cons_sign = -1;
Line 7318... Line 7401...
7318
 
7401
 
7319
void
7402
void
7320
x86_cons_fix_new (fragS *frag, unsigned int off, unsigned int len,
7403
x86_cons_fix_new (fragS *frag, unsigned int off, unsigned int len,
7321
		  expressionS *exp)
7404
		  expressionS *exp, bfd_reloc_code_real_type r)
7322
{
7405
{
7323
  enum bfd_reloc_code_real r = reloc (len, 0, cons_sign, 0, got_reloc);
-
 
7324
 
-
 
Line 7325... Line 7406...
7325
  got_reloc = NO_RELOC;
7406
  r = reloc (len, 0, cons_sign, r);
7326
 
7407
 
7327
#ifdef TE_PE
7408
#ifdef TE_PE
7328
  if (exp->X_op == O_secrel)
7409
  if (exp->X_op == O_secrel)
Line 7346... Line 7427...
7346
  return stdoutput->arch_info->bits_per_address / 8;
7427
  return stdoutput->arch_info->bits_per_address / 8;
7347
}
7428
}
Line 7348... Line 7429...
7348
 
7429
 
7349
#if !(defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) || defined (OBJ_MACH_O)) \
7430
#if !(defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) || defined (OBJ_MACH_O)) \
7350
    || defined (LEX_AT)
7431
    || defined (LEX_AT)
7351
# define lex_got(reloc, adjust, types, bnd_prefix) NULL
7432
# define lex_got(reloc, adjust, types) NULL
7352
#else
7433
#else
7353
/* Parse operands of the form
7434
/* Parse operands of the form
7354
   @GOTOFF+
7435
   @GOTOFF+
Line 7360... Line 7441...
7360
   is non-null set it to the length of the string we removed from the
7441
   is non-null set it to the length of the string we removed from the
7361
   input line.  Otherwise return NULL.  */
7442
   input line.  Otherwise return NULL.  */
7362
static char *
7443
static char *
7363
lex_got (enum bfd_reloc_code_real *rel,
7444
lex_got (enum bfd_reloc_code_real *rel,
7364
	 int *adjust,
7445
	 int *adjust,
7365
	 i386_operand_type *types,
7446
	 i386_operand_type *types)
7366
	 int bnd_prefix)
-
 
7367
{
7447
{
7368
  /* Some of the relocations depend on the size of what field is to
7448
  /* Some of the relocations depend on the size of what field is to
7369
     be relocated.  But in our callers i386_immediate and i386_displacement
7449
     be relocated.  But in our callers i386_immediate and i386_displacement
7370
     we don't yet know the operand size (this will be set by insn
7450
     we don't yet know the operand size (this will be set by insn
7371
     matching).  Hence we record the word32 relocation here,
7451
     matching).  Hence we record the word32 relocation here,
Line 7496... Line 7576...
7496
		len++;
7576
		len++;
7497
	      if (adjust)
7577
	      if (adjust)
7498
		*adjust = len;
7578
		*adjust = len;
7499
	      memcpy (tmpbuf + first, past_reloc, second);
7579
	      memcpy (tmpbuf + first, past_reloc, second);
7500
	      tmpbuf[first + second] = '\0';
7580
	      tmpbuf[first + second] = '\0';
7501
	      if (bnd_prefix && *rel == BFD_RELOC_X86_64_PLT32)
-
 
7502
		*rel = BFD_RELOC_X86_64_PLT32_BND;
-
 
7503
	      return tmpbuf;
7581
	      return tmpbuf;
7504
	    }
7582
	    }
Line 7505... Line 7583...
7505
 
7583
 
7506
	  as_bad (_("@%s reloc is not supported with %d-bit output format"),
7584
	  as_bad (_("@%s reloc is not supported with %d-bit output format"),
Line 7530... Line 7608...
7530
   This function is copied from the ELF version above adjusted for PE targets.  */
7608
   This function is copied from the ELF version above adjusted for PE targets.  */
Line 7531... Line 7609...
7531
 
7609
 
7532
static char *
7610
static char *
7533
lex_got (enum bfd_reloc_code_real *rel ATTRIBUTE_UNUSED,
7611
lex_got (enum bfd_reloc_code_real *rel ATTRIBUTE_UNUSED,
7534
	 int *adjust ATTRIBUTE_UNUSED,
7612
	 int *adjust ATTRIBUTE_UNUSED,
7535
	 i386_operand_type *types,
-
 
7536
	 int bnd_prefix ATTRIBUTE_UNUSED)
7613
	 i386_operand_type *types)
7537
{
7614
{
7538
  static const struct
7615
  static const struct
7539
  {
7616
  {
7540
    const char *str;
7617
    const char *str;
Line 7616... Line 7693...
7616
  return NULL;
7693
  return NULL;
7617
}
7694
}
Line 7618... Line 7695...
7618
 
7695
 
Line 7619... Line 7696...
7619
#endif /* TE_PE */
7696
#endif /* TE_PE */
7620
 
7697
 
7621
void
7698
bfd_reloc_code_real_type
-
 
7699
x86_cons (expressionS *exp, int size)
-
 
7700
{
7622
x86_cons (expressionS *exp, int size)
7701
  bfd_reloc_code_real_type got_reloc = NO_RELOC;
Line 7623... Line 7702...
7623
{
7702
 
7624
  intel_syntax = -intel_syntax;
7703
  intel_syntax = -intel_syntax;
7625
 
7704
 
Line 7630... Line 7709...
7630
      char *save;
7709
      char *save;
7631
      char *gotfree_input_line;
7710
      char *gotfree_input_line;
7632
      int adjust = 0;
7711
      int adjust = 0;
Line 7633... Line 7712...
7633
 
7712
 
7634
      save = input_line_pointer;
7713
      save = input_line_pointer;
7635
      gotfree_input_line = lex_got (&got_reloc, &adjust, NULL, 0);
7714
      gotfree_input_line = lex_got (&got_reloc, &adjust, NULL);
7636
      if (gotfree_input_line)
7715
      if (gotfree_input_line)
Line 7637... Line 7716...
7637
	input_line_pointer = gotfree_input_line;
7716
	input_line_pointer = gotfree_input_line;
Line 7665... Line 7744...
7665
 
7744
 
Line 7666... Line 7745...
7666
  intel_syntax = -intel_syntax;
7745
  intel_syntax = -intel_syntax;
7667
 
7746
 
-
 
7747
  if (intel_syntax)
-
 
7748
    i386_intel_simplify (exp);
7668
  if (intel_syntax)
7749
 
Line 7669... Line 7750...
7669
    i386_intel_simplify (exp);
7750
  return got_reloc;
7670
}
7751
}
7671
 
7752
 
Line 7725... Line 7806...
7725
		goto duplicated_vec_op;
7806
		goto duplicated_vec_op;
Line 7726... Line 7807...
7726
 
7807
 
7727
	      op_string += 3;
7808
	      op_string += 3;
7728
	      if (*op_string == '8')
7809
	      if (*op_string == '8')
-
 
7810
		bcst_type = BROADCAST_1TO8;
-
 
7811
	      else if (*op_string == '4')
-
 
7812
		bcst_type = BROADCAST_1TO4;
-
 
7813
	      else if (*op_string == '2')
7729
		bcst_type = BROADCAST_1TO8;
7814
		bcst_type = BROADCAST_1TO2;
7730
	      else if (*op_string == '1'
7815
	      else if (*op_string == '1'
7731
		       && *(op_string+1) == '6')
7816
		       && *(op_string+1) == '6')
7732
		{
7817
		{
7733
		  bcst_type = BROADCAST_1TO16;
7818
		  bcst_type = BROADCAST_1TO16;
Line 7858... Line 7943...
7858
    ++imm_start;
7943
    ++imm_start;
Line 7859... Line 7944...
7859
 
7944
 
7860
  save_input_line_pointer = input_line_pointer;
7945
  save_input_line_pointer = input_line_pointer;
Line 7861... Line 7946...
7861
  input_line_pointer = imm_start;
7946
  input_line_pointer = imm_start;
7862
 
-
 
7863
  gotfree_input_line = lex_got (&i.reloc[this_operand], NULL, &types,
-
 
7864
				(i.bnd_prefix != NULL
7947
 
7865
				 || add_bnd_prefix));
7948
  gotfree_input_line = lex_got (&i.reloc[this_operand], NULL, &types);
Line 7866... Line 7949...
7866
  if (gotfree_input_line)
7949
  if (gotfree_input_line)
Line 7926... Line 8009...
7926
    {
8009
    {
7927
      as_bad (_("unimplemented segment %s in operand"), exp_seg->name);
8010
      as_bad (_("unimplemented segment %s in operand"), exp_seg->name);
7928
      return 0;
8011
      return 0;
7929
    }
8012
    }
7930
#endif
8013
#endif
7931
  else if (!intel_syntax && exp->X_op == O_register)
8014
  else if (!intel_syntax && exp_seg == reg_section)
7932
    {
8015
    {
7933
      if (imm_start)
8016
      if (imm_start)
7934
	as_bad (_("illegal immediate register operand %s"), imm_start);
8017
	as_bad (_("illegal immediate register operand %s"), imm_start);
7935
      return 0;
8018
      return 0;
7936
    }
8019
    }
Line 8117... Line 8200...
8117
	 So here we provide the missing zero.  */
8200
	 So here we provide the missing zero.  */
Line 8118... Line 8201...
8118
 
8201
 
8119
      *displacement_string_end = '0';
8202
      *displacement_string_end = '0';
8120
    }
8203
    }
8121
#endif
8204
#endif
8122
  gotfree_input_line = lex_got (&i.reloc[this_operand], NULL, &types,
-
 
8123
				(i.bnd_prefix != NULL
-
 
8124
				 || add_bnd_prefix));
8205
  gotfree_input_line = lex_got (&i.reloc[this_operand], NULL, &types);
8125
  if (gotfree_input_line)
8206
  if (gotfree_input_line)
Line 8126... Line 8207...
8126
    input_line_pointer = gotfree_input_line;
8207
    input_line_pointer = gotfree_input_line;
Line 8587... Line 8668...
8587
      /* If it is a RC or SAE immediate, do nothing.  */
8668
      /* If it is a RC or SAE immediate, do nothing.  */
8588
      ;
8669
      ;
8589
    }
8670
    }
8590
  else if (is_digit_char (*op_string)
8671
  else if (is_digit_char (*op_string)
8591
	   || is_identifier_char (*op_string)
8672
	   || is_identifier_char (*op_string)
-
 
8673
	   || *op_string == '"'
8592
	   || *op_string == '(')
8674
	   || *op_string == '(')
8593
    {
8675
    {
8594
      /* This is a memory reference of some sort.  */
8676
      /* This is a memory reference of some sort.  */
8595
      char *base_string;
8677
      char *base_string;
Line 8801... Line 8883...
8801
     Unconditional jumps can grow by 4 bytes and others by 5 bytes.  */
8883
     Unconditional jumps can grow by 4 bytes and others by 5 bytes.  */
8802
  gas_assert (frag->fr_type == rs_machine_dependent);
8884
  gas_assert (frag->fr_type == rs_machine_dependent);
8803
  return TYPE_FROM_RELAX_STATE (frag->fr_subtype) == UNCOND_JUMP ? 4 : 5;
8885
  return TYPE_FROM_RELAX_STATE (frag->fr_subtype) == UNCOND_JUMP ? 4 : 5;
8804
}
8886
}
Line -... Line 8887...
-
 
8887
 
-
 
8888
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-
 
8889
static int
-
 
8890
elf_symbol_resolved_in_segment_p (symbolS *fr_symbol, offsetT fr_var)
-
 
8891
{
-
 
8892
  /* STT_GNU_IFUNC symbol must go through PLT.  */
-
 
8893
  if ((symbol_get_bfdsym (fr_symbol)->flags
-
 
8894
       & BSF_GNU_INDIRECT_FUNCTION) != 0)
-
 
8895
    return 0;
-
 
8896
 
-
 
8897
  if (!S_IS_EXTERNAL (fr_symbol))
-
 
8898
    /* Symbol may be weak or local.  */
-
 
8899
    return !S_IS_WEAK (fr_symbol);
-
 
8900
 
-
 
8901
  /* Global symbols with non-default visibility can't be preempted. */
-
 
8902
  if (ELF_ST_VISIBILITY (S_GET_OTHER (fr_symbol)) != STV_DEFAULT)
-
 
8903
    return 1;
-
 
8904
 
-
 
8905
  if (fr_var != NO_RELOC)
-
 
8906
    switch ((enum bfd_reloc_code_real) fr_var)
-
 
8907
      {
-
 
8908
      case BFD_RELOC_386_PLT32:
-
 
8909
      case BFD_RELOC_X86_64_PLT32:
-
 
8910
	/* Symbol with PLT relocatin may be preempted. */
-
 
8911
	return 0;
-
 
8912
      default:
-
 
8913
	abort ();
-
 
8914
      }
-
 
8915
 
-
 
8916
  /* Global symbols with default visibility in a shared library may be
-
 
8917
     preempted by another definition.  */
-
 
8918
  return !shared;
-
 
8919
}
-
 
8920
#endif
8805
 
8921
 
Line 8806... Line 8922...
8806
/* md_estimate_size_before_relax()
8922
/* md_estimate_size_before_relax()
8807
 
8923
 
8808
   Called just before relax() for rs_machine_dependent frags.  The x86
8924
   Called just before relax() for rs_machine_dependent frags.  The x86
Line 8824... Line 8940...
8824
     an externally visible symbol, because it may be overridden by a
8940
     an externally visible symbol, because it may be overridden by a
8825
     shared library.  */
8941
     shared library.  */
8826
  if (S_GET_SEGMENT (fragP->fr_symbol) != segment
8942
  if (S_GET_SEGMENT (fragP->fr_symbol) != segment
8827
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
8943
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
8828
      || (IS_ELF
8944
      || (IS_ELF
8829
	  && (S_IS_EXTERNAL (fragP->fr_symbol)
8945
	  && !elf_symbol_resolved_in_segment_p (fragP->fr_symbol,
8830
	      || S_IS_WEAK (fragP->fr_symbol)
8946
						fragP->fr_var))
8831
	      || ((symbol_get_bfdsym (fragP->fr_symbol)->flags
-
 
8832
		   & BSF_GNU_INDIRECT_FUNCTION))))
-
 
8833
#endif
8947
#endif
8834
#if defined (OBJ_COFF) && defined (TE_PE)
8948
#if defined (OBJ_COFF) && defined (TE_PE)
8835
      || (OUTPUT_FLAVOR == bfd_target_coff_flavour
8949
      || (OUTPUT_FLAVOR == bfd_target_coff_flavour
8836
	  && S_IS_WEAK (fragP->fr_symbol))
8950
	  && S_IS_WEAK (fragP->fr_symbol))
8837
#endif
8951
#endif
Line 9079... Line 9193...
9079
 
9193
 
9080
  if (fixP->fx_addsy != NULL
9194
  if (fixP->fx_addsy != NULL
9081
      && (fixP->fx_r_type == BFD_RELOC_32_PCREL
9195
      && (fixP->fx_r_type == BFD_RELOC_32_PCREL
9082
	  || fixP->fx_r_type == BFD_RELOC_64_PCREL
9196
	  || fixP->fx_r_type == BFD_RELOC_64_PCREL
9083
	  || fixP->fx_r_type == BFD_RELOC_16_PCREL
9197
	  || fixP->fx_r_type == BFD_RELOC_16_PCREL
9084
	  || fixP->fx_r_type == BFD_RELOC_8_PCREL
-
 
9085
	  || fixP->fx_r_type == BFD_RELOC_X86_64_PC32_BND)
9198
	  || fixP->fx_r_type == BFD_RELOC_8_PCREL)
9086
      && !use_rela_relocations)
9199
      && !use_rela_relocations)
9087
    {
9200
    {
9088
      /* This is a hack.  There should be a better way to handle this.
9201
      /* This is a hack.  There should be a better way to handle this.
9089
	 This covers for the fact that bfd_install_relocation will
9202
	 This covers for the fact that bfd_install_relocation will
Line 9122... Line 9235...
9122
	  || S_IS_WEAK (fixP->fx_addsy))
9235
	  || S_IS_WEAK (fixP->fx_addsy))
9123
	value += md_pcrel_from (fixP);
9236
	value += md_pcrel_from (fixP);
9124
#endif
9237
#endif
9125
    }
9238
    }
9126
#if defined (OBJ_COFF) && defined (TE_PE)
9239
#if defined (OBJ_COFF) && defined (TE_PE)
-
 
9240
  if (fixP->fx_addsy != NULL
9127
  if (fixP->fx_addsy != NULL && S_IS_WEAK (fixP->fx_addsy))
9241
      && S_IS_WEAK (fixP->fx_addsy)
-
 
9242
      /* PR 16858: Do not modify weak function references.  */
-
 
9243
      && ! fixP->fx_pcrel)
9128
    {
9244
    {
-
 
9245
#if !defined (TE_PEP)
-
 
9246
      /* For x86 PE weak function symbols are neither PC-relative
-
 
9247
	 nor do they set S_IS_FUNCTION.  So the only reliable way
-
 
9248
	 to detect them is to check the flags of their containing
-
 
9249
	 section.  */
-
 
9250
      if (S_GET_SEGMENT (fixP->fx_addsy) != NULL
-
 
9251
	  && S_GET_SEGMENT (fixP->fx_addsy)->flags & SEC_CODE)
-
 
9252
	;
-
 
9253
      else
-
 
9254
#endif
9129
      value -= S_GET_VALUE (fixP->fx_addsy);
9255
      value -= S_GET_VALUE (fixP->fx_addsy);
9130
    }
9256
    }
9131
#endif
9257
#endif
Line 9132... Line 9258...
9132
 
9258
 
Line 9136... Line 9262...
9136
  if (IS_ELF && fixP->fx_addsy)
9262
  if (IS_ELF && fixP->fx_addsy)
9137
    switch (fixP->fx_r_type)
9263
    switch (fixP->fx_r_type)
9138
      {
9264
      {
9139
      case BFD_RELOC_386_PLT32:
9265
      case BFD_RELOC_386_PLT32:
9140
      case BFD_RELOC_X86_64_PLT32:
9266
      case BFD_RELOC_X86_64_PLT32:
9141
      case BFD_RELOC_X86_64_PLT32_BND:
-
 
9142
	/* Make the jump instruction point to the address of the operand.  At
9267
	/* Make the jump instruction point to the address of the operand.  At
9143
	   runtime we merely add the offset to the actual PLT entry.  */
9268
	   runtime we merely add the offset to the actual PLT entry.  */
9144
	value = -4;
9269
	value = -4;
9145
	break;
9270
	break;
Line 9378... Line 9503...
9378
      char *save = input_line_pointer;
9503
      char *save = input_line_pointer;
9379
      char c;
9504
      char c;
9380
      symbolS *symbolP;
9505
      symbolS *symbolP;
Line 9381... Line 9506...
9381
 
9506
 
9382
      input_line_pointer = reg_string;
9507
      input_line_pointer = reg_string;
9383
      c = get_symbol_end ();
9508
      c = get_symbol_name (®_string);
9384
      symbolP = symbol_find (reg_string);
9509
      symbolP = symbol_find (reg_string);
9385
      if (symbolP && S_GET_SEGMENT (symbolP) == reg_section)
9510
      if (symbolP && S_GET_SEGMENT (symbolP) == reg_section)
9386
	{
9511
	{
Line 9387... Line 9512...
9387
	  const expressionS *e = symbol_get_value_expression (symbolP);
9512
	  const expressionS *e = symbol_get_value_expression (symbolP);
9388
 
9513
 
9389
	  know (e->X_op == O_register);
9514
	  know (e->X_op == O_register);
9390
	  know (e->X_add_number >= 0
9515
	  know (e->X_add_number >= 0
-
 
9516
		&& (valueT) e->X_add_number < i386_regtab_size);
-
 
9517
	  r = i386_regtab + e->X_add_number;
9391
		&& (valueT) e->X_add_number < i386_regtab_size);
9518
	  if ((r->reg_flags & RegVRex))
9392
	  r = i386_regtab + e->X_add_number;
9519
	    i.need_vrex = 1;
9393
	  *end_op = input_line_pointer;
9520
	  *end_op = input_line_pointer;
9394
	}
9521
	}
9395
      *input_line_pointer = c;
9522
      *input_line_pointer = c;
Line 9481... Line 9608...
9481
#define OPTION_MAVXSCALAR (OPTION_MD_BASE + 13)
9608
#define OPTION_MAVXSCALAR (OPTION_MD_BASE + 13)
9482
#define OPTION_X32 (OPTION_MD_BASE + 14)
9609
#define OPTION_X32 (OPTION_MD_BASE + 14)
9483
#define OPTION_MADD_BND_PREFIX (OPTION_MD_BASE + 15)
9610
#define OPTION_MADD_BND_PREFIX (OPTION_MD_BASE + 15)
9484
#define OPTION_MEVEXLIG (OPTION_MD_BASE + 16)
9611
#define OPTION_MEVEXLIG (OPTION_MD_BASE + 16)
9485
#define OPTION_MEVEXWIG (OPTION_MD_BASE + 17)
9612
#define OPTION_MEVEXWIG (OPTION_MD_BASE + 17)
-
 
9613
#define OPTION_MBIG_OBJ (OPTION_MD_BASE + 18)
-
 
9614
#define OPTION_OMIT_LOCK_PREFIX (OPTION_MD_BASE + 19)
-
 
9615
#define OPTION_MEVEXRCIG (OPTION_MD_BASE + 20)
-
 
9616
#define OPTION_MSHARED (OPTION_MD_BASE + 21)
-
 
9617
#define OPTION_MAMD64 (OPTION_MD_BASE + 22)
-
 
9618
#define OPTION_MINTEL64 (OPTION_MD_BASE + 23)
Line 9486... Line 9619...
9486
 
9619
 
9487
struct option md_longopts[] =
9620
struct option md_longopts[] =
9488
{
9621
{
9489
  {"32", no_argument, NULL, OPTION_32},
9622
  {"32", no_argument, NULL, OPTION_32},
9490
#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
9623
#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
9491
     || defined (TE_PE) || defined (TE_PEP) || defined (OBJ_MACH_O))
9624
     || defined (TE_PE) || defined (TE_PEP) || defined (OBJ_MACH_O))
9492
  {"64", no_argument, NULL, OPTION_64},
9625
  {"64", no_argument, NULL, OPTION_64},
9493
#endif
9626
#endif
9494
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
9627
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-
 
9628
  {"x32", no_argument, NULL, OPTION_X32},
9495
  {"x32", no_argument, NULL, OPTION_X32},
9629
  {"mshared", no_argument, NULL, OPTION_MSHARED},
9496
#endif
9630
#endif
9497
  {"divide", no_argument, NULL, OPTION_DIVIDE},
9631
  {"divide", no_argument, NULL, OPTION_DIVIDE},
9498
  {"march", required_argument, NULL, OPTION_MARCH},
9632
  {"march", required_argument, NULL, OPTION_MARCH},
9499
  {"mtune", required_argument, NULL, OPTION_MTUNE},
9633
  {"mtune", required_argument, NULL, OPTION_MTUNE},
Line 9507... Line 9641...
9507
  {"moperand-check", required_argument, NULL, OPTION_MOPERAND_CHECK},
9641
  {"moperand-check", required_argument, NULL, OPTION_MOPERAND_CHECK},
9508
  {"mavxscalar", required_argument, NULL, OPTION_MAVXSCALAR},
9642
  {"mavxscalar", required_argument, NULL, OPTION_MAVXSCALAR},
9509
  {"madd-bnd-prefix", no_argument, NULL, OPTION_MADD_BND_PREFIX},
9643
  {"madd-bnd-prefix", no_argument, NULL, OPTION_MADD_BND_PREFIX},
9510
  {"mevexlig", required_argument, NULL, OPTION_MEVEXLIG},
9644
  {"mevexlig", required_argument, NULL, OPTION_MEVEXLIG},
9511
  {"mevexwig", required_argument, NULL, OPTION_MEVEXWIG},
9645
  {"mevexwig", required_argument, NULL, OPTION_MEVEXWIG},
-
 
9646
# if defined (TE_PE) || defined (TE_PEP)
-
 
9647
  {"mbig-obj", no_argument, NULL, OPTION_MBIG_OBJ},
-
 
9648
#endif
-
 
9649
  {"momit-lock-prefix", required_argument, NULL, OPTION_OMIT_LOCK_PREFIX},
-
 
9650
  {"mevexrcig", required_argument, NULL, OPTION_MEVEXRCIG},
-
 
9651
  {"mamd64", no_argument, NULL, OPTION_MAMD64},
-
 
9652
  {"mintel64", no_argument, NULL, OPTION_MINTEL64},
9512
  {NULL, no_argument, NULL, 0}
9653
  {NULL, no_argument, NULL, 0}
9513
};
9654
};
9514
size_t md_longopts_size = sizeof (md_longopts);
9655
size_t md_longopts_size = sizeof (md_longopts);
Line 9515... Line 9656...
9515
 
9656
 
Line 9546... Line 9687...
9546
 
9687
 
9547
    case 's':
9688
    case 's':
9548
      /* -s: On i386 Solaris, this tells the native assembler to use
9689
      /* -s: On i386 Solaris, this tells the native assembler to use
9549
	 .stab instead of .stab.excl.  We always use .stab anyhow.  */
9690
	 .stab instead of .stab.excl.  We always use .stab anyhow.  */
-
 
9691
      break;
-
 
9692
 
-
 
9693
    case OPTION_MSHARED:
-
 
9694
      shared = 1;
9550
      break;
9695
      break;
9551
#endif
9696
#endif
9552
#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
9697
#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
9553
     || defined (TE_PE) || defined (TE_PEP) || defined (OBJ_MACH_O))
9698
     || defined (TE_PE) || defined (TE_PEP) || defined (OBJ_MACH_O))
9554
    case OPTION_64:
9699
    case OPTION_64:
Line 9655... Line 9800...
9655
		    flags = cpu_flags_or (cpu_arch_flags,
9800
		    flags = cpu_flags_or (cpu_arch_flags,
9656
					  cpu_arch[j].flags);
9801
					  cpu_arch[j].flags);
9657
		  else
9802
		  else
9658
		    flags = cpu_flags_and_not (cpu_arch_flags,
9803
		    flags = cpu_flags_and_not (cpu_arch_flags,
9659
					       cpu_arch[j].flags);
9804
					       cpu_arch[j].flags);
-
 
9805
 
-
 
9806
		  if (!valid_iamcu_cpu_flags (&flags))
-
 
9807
		    as_fatal (_("`%s' isn't valid for Intel MCU"), arch);
9660
		  if (!cpu_flags_equal (&flags, &cpu_arch_flags))
9808
		  else if (!cpu_flags_equal (&flags, &cpu_arch_flags))
9661
		    {
9809
		    {
9662
		      if (cpu_sub_arch_name)
9810
		      if (cpu_sub_arch_name)
9663
			{
9811
			{
9664
			  char *name = cpu_sub_arch_name;
9812
			  char *name = cpu_sub_arch_name;
9665
			  cpu_sub_arch_name = concat (name,
9813
			  cpu_sub_arch_name = concat (name,
Line 9779... Line 9927...
9779
	evexlig = evexl512;
9927
	evexlig = evexl512;
9780
      else
9928
      else
9781
	as_fatal (_("invalid -mevexlig= option: `%s'"), arg);
9929
	as_fatal (_("invalid -mevexlig= option: `%s'"), arg);
9782
      break;
9930
      break;
Line -... Line 9931...
-
 
9931
 
-
 
9932
    case OPTION_MEVEXRCIG:
-
 
9933
      if (strcmp (arg, "rne") == 0)
-
 
9934
	evexrcig = rne;
-
 
9935
      else if (strcmp (arg, "rd") == 0)
-
 
9936
	evexrcig = rd;
-
 
9937
      else if (strcmp (arg, "ru") == 0)
-
 
9938
	evexrcig = ru;
-
 
9939
      else if (strcmp (arg, "rz") == 0)
-
 
9940
	evexrcig = rz;
-
 
9941
      else
-
 
9942
	as_fatal (_("invalid -mevexrcig= option: `%s'"), arg);
-
 
9943
      break;
9783
 
9944
 
9784
    case OPTION_MEVEXWIG:
9945
    case OPTION_MEVEXWIG:
9785
      if (strcmp (arg, "0") == 0)
9946
      if (strcmp (arg, "0") == 0)
9786
	evexwig = evexw0;
9947
	evexwig = evexw0;
9787
      else if (strcmp (arg, "1") == 0)
9948
      else if (strcmp (arg, "1") == 0)
9788
	evexwig = evexw1;
9949
	evexwig = evexw1;
9789
      else
9950
      else
9790
	as_fatal (_("invalid -mevexwig= option: `%s'"), arg);
9951
	as_fatal (_("invalid -mevexwig= option: `%s'"), arg);
Line -... Line 9952...
-
 
9952
      break;
-
 
9953
 
-
 
9954
# if defined (TE_PE) || defined (TE_PEP)
-
 
9955
    case OPTION_MBIG_OBJ:
-
 
9956
      use_big_obj = 1;
-
 
9957
      break;
-
 
9958
#endif
-
 
9959
 
-
 
9960
    case OPTION_OMIT_LOCK_PREFIX:
-
 
9961
      if (strcasecmp (arg, "yes") == 0)
-
 
9962
        omit_lock_prefix = 1;
-
 
9963
      else if (strcasecmp (arg, "no") == 0)
-
 
9964
        omit_lock_prefix = 0;
-
 
9965
      else
-
 
9966
        as_fatal (_("invalid -momit-lock-prefix= option: `%s'"), arg);
-
 
9967
      break;
-
 
9968
 
-
 
9969
    case OPTION_MAMD64:
-
 
9970
      cpu_arch_flags.bitfield.cpuamd64 = 1;
-
 
9971
      cpu_arch_flags.bitfield.cpuintel64 = 0;
-
 
9972
      cpu_arch_isa_flags.bitfield.cpuamd64 = 1;
-
 
9973
      cpu_arch_isa_flags.bitfield.cpuintel64 = 0;
-
 
9974
      break;
-
 
9975
 
-
 
9976
    case OPTION_MINTEL64:
-
 
9977
      cpu_arch_flags.bitfield.cpuamd64 = 0;
-
 
9978
      cpu_arch_flags.bitfield.cpuintel64 = 1;
-
 
9979
      cpu_arch_isa_flags.bitfield.cpuamd64 = 0;
-
 
9980
      cpu_arch_isa_flags.bitfield.cpuintel64 = 1;
9791
      break;
9981
      break;
9792
 
9982
 
9793
    default:
9983
    default:
9794
      return 0;
9984
      return 0;
9795
    }
9985
    }
Line 9929... Line 10119...
9929
                           length\n"));
10119
                           length\n"));
9930
  fprintf (stream, _("\
10120
  fprintf (stream, _("\
9931
  -mevexwig=[0|1]         encode EVEX instructions with specific EVEX.W value\n\
10121
  -mevexwig=[0|1]         encode EVEX instructions with specific EVEX.W value\n\
9932
                           for EVEX.W bit ignored instructions\n"));
10122
                           for EVEX.W bit ignored instructions\n"));
9933
  fprintf (stream, _("\
10123
  fprintf (stream, _("\
-
 
10124
  -mevexrcig=[rne|rd|ru|rz]\n\
-
 
10125
                          encode EVEX instructions with specific EVEX.RC value\n\
-
 
10126
                           for SAE-only ignored instructions\n"));
-
 
10127
  fprintf (stream, _("\
9934
  -mmnemonic=[att|intel]  use AT&T/Intel mnemonic\n"));
10128
  -mmnemonic=[att|intel]  use AT&T/Intel mnemonic\n"));
9935
  fprintf (stream, _("\
10129
  fprintf (stream, _("\
9936
  -msyntax=[att|intel]    use AT&T/Intel syntax\n"));
10130
  -msyntax=[att|intel]    use AT&T/Intel syntax\n"));
9937
  fprintf (stream, _("\
10131
  fprintf (stream, _("\
9938
  -mindex-reg             support pseudo index registers\n"));
10132
  -mindex-reg             support pseudo index registers\n"));
Line 9940... Line 10134...
9940
  -mnaked-reg             don't require `%%' prefix for registers\n"));
10134
  -mnaked-reg             don't require `%%' prefix for registers\n"));
9941
  fprintf (stream, _("\
10135
  fprintf (stream, _("\
9942
  -mold-gcc               support old (<= 2.8.1) versions of gcc\n"));
10136
  -mold-gcc               support old (<= 2.8.1) versions of gcc\n"));
9943
  fprintf (stream, _("\
10137
  fprintf (stream, _("\
9944
  -madd-bnd-prefix        add BND prefix for all valid branches\n"));
10138
  -madd-bnd-prefix        add BND prefix for all valid branches\n"));
-
 
10139
  fprintf (stream, _("\
-
 
10140
  -mshared                disable branch optimization for shared code\n"));
-
 
10141
# if defined (TE_PE) || defined (TE_PEP)
-
 
10142
  fprintf (stream, _("\
-
 
10143
  -mbig-obj               generate big object files\n"));
-
 
10144
#endif
-
 
10145
  fprintf (stream, _("\
-
 
10146
  -momit-lock-prefix=[no|yes]\n\
-
 
10147
                          strip all lock prefixes\n"));
-
 
10148
  fprintf (stream, _("\
-
 
10149
  -mamd64                 accept only AMD64 ISA\n"));
-
 
10150
  fprintf (stream, _("\
-
 
10151
  -mintel64               accept only Intel64 ISA\n"));
9945
}
10152
}
Line 9946... Line 10153...
9946
 
10153
 
9947
#if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \
10154
#if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \
9948
     || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
10155
     || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
Line 9961... Line 10168...
9961
      else
10168
      else
9962
	x86_elf_abi = X86_64_X32_ABI;
10169
	x86_elf_abi = X86_64_X32_ABI;
9963
    }
10170
    }
9964
  else if (!strcmp (default_arch, "i386"))
10171
  else if (!strcmp (default_arch, "i386"))
9965
    update_code_flag (CODE_32BIT, 1);
10172
    update_code_flag (CODE_32BIT, 1);
-
 
10173
  else if (!strcmp (default_arch, "iamcu"))
-
 
10174
    {
-
 
10175
      update_code_flag (CODE_32BIT, 1);
-
 
10176
      if (cpu_arch_isa == PROCESSOR_UNKNOWN)
-
 
10177
	{
-
 
10178
	  static const i386_cpu_flags iamcu_flags = CPU_IAMCU_FLAGS;
-
 
10179
	  cpu_arch_name = "iamcu";
-
 
10180
	  cpu_sub_arch_name = NULL;
-
 
10181
	  cpu_arch_flags = iamcu_flags;
-
 
10182
	  cpu_arch_isa = PROCESSOR_IAMCU;
-
 
10183
	  cpu_arch_isa_flags = iamcu_flags;
-
 
10184
	  if (!cpu_arch_tune_set)
-
 
10185
	    {
-
 
10186
	      cpu_arch_tune = cpu_arch_isa;
-
 
10187
	      cpu_arch_tune_flags = cpu_arch_isa_flags;
-
 
10188
	    }
-
 
10189
	}
-
 
10190
      else
-
 
10191
	as_fatal (_("Intel MCU doesn't support `%s' architecture"),
-
 
10192
		  cpu_arch_name);
-
 
10193
    }
9966
  else
10194
  else
9967
    as_fatal (_("unknown architecture"));
10195
    as_fatal (_("unknown architecture"));
Line 9968... Line 10196...
9968
 
10196
 
9969
  if (cpu_flags_all_zero (&cpu_arch_isa_flags))
10197
  if (cpu_flags_all_zero (&cpu_arch_isa_flags))
Line 9978... Line 10206...
9978
      return AOUT_TARGET_FORMAT;
10206
      return AOUT_TARGET_FORMAT;
9979
#endif
10207
#endif
9980
#if defined (OBJ_MAYBE_COFF) || defined (OBJ_COFF)
10208
#if defined (OBJ_MAYBE_COFF) || defined (OBJ_COFF)
9981
# if defined (TE_PE) || defined (TE_PEP)
10209
# if defined (TE_PE) || defined (TE_PEP)
9982
    case bfd_target_coff_flavour:
10210
    case bfd_target_coff_flavour:
-
 
10211
      if (flag_code == CODE_64BIT)
9983
      return flag_code == CODE_64BIT ? "pe-x86-64" : "pe-i386";
10212
	return use_big_obj ? "pe-bigobj-x86-64" : "pe-x86-64";
-
 
10213
      else
-
 
10214
	return "pe-i386";
9984
# elif defined (TE_GO32)
10215
# elif defined (TE_GO32)
9985
    case bfd_target_coff_flavour:
10216
    case bfd_target_coff_flavour:
9986
      return "coff-go32";
10217
      return "coff-go32";
9987
# else
10218
# else
9988
    case bfd_target_coff_flavour:
10219
    case bfd_target_coff_flavour:
Line 10015... Line 10246...
10015
	  {
10246
	  {
10016
	    if (x86_elf_abi != X86_64_ABI)
10247
	    if (x86_elf_abi != X86_64_ABI)
10017
	      as_fatal (_("Intel L1OM is 64bit only"));
10248
	      as_fatal (_("Intel L1OM is 64bit only"));
10018
	    return ELF_TARGET_L1OM_FORMAT;
10249
	    return ELF_TARGET_L1OM_FORMAT;
10019
	  }
10250
	  }
10020
	if (cpu_arch_isa == PROCESSOR_K1OM)
10251
	else if (cpu_arch_isa == PROCESSOR_K1OM)
10021
	  {
10252
	  {
10022
	    if (x86_elf_abi != X86_64_ABI)
10253
	    if (x86_elf_abi != X86_64_ABI)
10023
	      as_fatal (_("Intel K1OM is 64bit only"));
10254
	      as_fatal (_("Intel K1OM is 64bit only"));
10024
	    return ELF_TARGET_K1OM_FORMAT;
10255
	    return ELF_TARGET_K1OM_FORMAT;
10025
	  }
10256
	  }
-
 
10257
	else if (cpu_arch_isa == PROCESSOR_IAMCU)
-
 
10258
	  {
-
 
10259
	    if (x86_elf_abi != I386_ABI)
-
 
10260
	      as_fatal (_("Intel MCU is 32bit only"));
-
 
10261
	    return ELF_TARGET_IAMCU_FORMAT;
-
 
10262
	  }
10026
	else
10263
	else
10027
	  return format;
10264
	  return format;
10028
      }
10265
      }
10029
#endif
10266
#endif
10030
#if defined (OBJ_MACH_O)
10267
#if defined (OBJ_MACH_O)
Line 10044... Line 10281...
10044
    }
10281
    }
10045
}
10282
}
Line 10046... Line 10283...
10046
 
10283
 
Line 10047... Line -...
10047
#endif /* OBJ_MAYBE_ more than one  */
-
 
10048
 
-
 
10049
#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF))
-
 
10050
void
-
 
10051
i386_elf_emit_arch_note (void)
-
 
10052
{
-
 
10053
  if (IS_ELF && cpu_arch_name != NULL)
-
 
10054
    {
-
 
10055
      char *p;
-
 
10056
      asection *seg = now_seg;
-
 
10057
      subsegT subseg = now_subseg;
-
 
10058
      Elf_Internal_Note i_note;
-
 
10059
      Elf_External_Note e_note;
-
 
10060
      asection *note_secp;
-
 
10061
      int len;
-
 
10062
 
-
 
10063
      /* Create the .note section.  */
-
 
10064
      note_secp = subseg_new (".note", 0);
-
 
10065
      bfd_set_section_flags (stdoutput,
-
 
10066
			     note_secp,
-
 
10067
			     SEC_HAS_CONTENTS | SEC_READONLY);
-
 
10068
 
-
 
10069
      /* Process the arch string.  */
-
 
10070
      len = strlen (cpu_arch_name);
-
 
10071
 
-
 
10072
      i_note.namesz = len + 1;
-
 
10073
      i_note.descsz = 0;
-
 
10074
      i_note.type = NT_ARCH;
-
 
10075
      p = frag_more (sizeof (e_note.namesz));
-
 
10076
      md_number_to_chars (p, (valueT) i_note.namesz, sizeof (e_note.namesz));
-
 
10077
      p = frag_more (sizeof (e_note.descsz));
-
 
10078
      md_number_to_chars (p, (valueT) i_note.descsz, sizeof (e_note.descsz));
-
 
10079
      p = frag_more (sizeof (e_note.type));
-
 
10080
      md_number_to_chars (p, (valueT) i_note.type, sizeof (e_note.type));
-
 
10081
      p = frag_more (len + 1);
-
 
10082
      strcpy (p, cpu_arch_name);
-
 
10083
 
-
 
10084
      frag_align (2, 0, 0);
-
 
10085
 
-
 
10086
      subseg_set (seg, subseg);
-
 
10087
    }
-
 
10088
}
-
 
10089
#endif
10284
#endif /* OBJ_MAYBE_ more than one  */
10090

10285

10091
symbolS *
10286
symbolS *
10092
md_undefined_symbol (char *name)
10287
md_undefined_symbol (char *name)
10093
{
10288
{
Line 10122... Line 10317...
10122
	 easier to fix it here since that is how the other a.out targets
10317
	 easier to fix it here since that is how the other a.out targets
10123
	 work.  */
10318
	 work.  */
10124
      int align;
10319
      int align;
Line 10125... Line 10320...
10125
 
10320
 
10126
      align = bfd_get_section_alignment (stdoutput, segment);
10321
      align = bfd_get_section_alignment (stdoutput, segment);
10127
      size = ((size + (1 << align) - 1) & ((valueT) -1 << align));
10322
      size = ((size + (1 << align) - 1) & (-((valueT) 1 << align)));
10128
    }
10323
    }
Line 10129... Line 10324...
10129
#endif
10324
#endif
10130
 
10325
 
Line 10160... Line 10355...
10160
#endif
10355
#endif
Line 10161... Line 10356...
10161
 
10356
 
10162
void
10357
void
10163
i386_validate_fix (fixS *fixp)
10358
i386_validate_fix (fixS *fixp)
-
 
10359
{
-
 
10360
  if (fixp->fx_subsy)
10164
{
10361
    {
10165
  if (fixp->fx_subsy && fixp->fx_subsy == GOT_symbol)
10362
      if (fixp->fx_subsy == GOT_symbol)
10166
    {
10363
	{
10167
      if (fixp->fx_r_type == BFD_RELOC_32_PCREL)
10364
	  if (fixp->fx_r_type == BFD_RELOC_32_PCREL)
10168
	{
10365
	    {
10169
	  if (!object_64bit)
10366
	      if (!object_64bit)
-
 
10367
		abort ();
-
 
10368
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-
 
10369
	      if (fixp->fx_tcbit2)
-
 
10370
		fixp->fx_r_type = (fixp->fx_tcbit
-
 
10371
				   ? BFD_RELOC_X86_64_REX_GOTPCRELX
-
 
10372
				   : BFD_RELOC_X86_64_GOTPCRELX);
-
 
10373
	      else
10170
	    abort ();
10374
#endif
10171
	  fixp->fx_r_type = BFD_RELOC_X86_64_GOTPCREL;
10375
		fixp->fx_r_type = BFD_RELOC_X86_64_GOTPCREL;
10172
	}
10376
	    }
10173
      else
10377
	  else
10174
	{
10378
	    {
Line 10178... Line 10382...
10178
	    fixp->fx_r_type = BFD_RELOC_X86_64_GOTOFF64;
10382
		fixp->fx_r_type = BFD_RELOC_X86_64_GOTOFF64;
10179
	}
10383
	    }
10180
      fixp->fx_subsy = 0;
10384
	  fixp->fx_subsy = 0;
10181
    }
10385
	}
10182
}
10386
    }
-
 
10387
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-
 
10388
  else if (!object_64bit)
-
 
10389
    {
-
 
10390
      if (fixp->fx_r_type == BFD_RELOC_386_GOT32
-
 
10391
	  && fixp->fx_tcbit2)
-
 
10392
	fixp->fx_r_type = BFD_RELOC_386_GOT32X;
-
 
10393
    }
-
 
10394
#endif
-
 
10395
}
Line 10183... Line 10396...
10183
 
10396
 
10184
arelent *
10397
arelent *
10185
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
10398
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
10186
{
10399
{
Line 10208... Line 10421...
10208
	  return NULL;
10421
	  return NULL;
10209
	}
10422
	}
10210
#endif
10423
#endif
Line 10211... Line 10424...
10211
 
10424
 
10212
    case BFD_RELOC_X86_64_PLT32:
-
 
10213
    case BFD_RELOC_X86_64_PLT32_BND:
10425
    case BFD_RELOC_X86_64_PLT32:
10214
    case BFD_RELOC_X86_64_GOT32:
10426
    case BFD_RELOC_X86_64_GOT32:
-
 
10427
    case BFD_RELOC_X86_64_GOTPCREL:
-
 
10428
    case BFD_RELOC_X86_64_GOTPCRELX:
10215
    case BFD_RELOC_X86_64_GOTPCREL:
10429
    case BFD_RELOC_X86_64_REX_GOTPCRELX:
10216
    case BFD_RELOC_386_PLT32:
10430
    case BFD_RELOC_386_PLT32:
-
 
10431
    case BFD_RELOC_386_GOT32:
10217
    case BFD_RELOC_386_GOT32:
10432
    case BFD_RELOC_386_GOT32X:
10218
    case BFD_RELOC_386_GOTOFF:
10433
    case BFD_RELOC_386_GOTOFF:
10219
    case BFD_RELOC_386_GOTPC:
10434
    case BFD_RELOC_386_GOTPC:
10220
    case BFD_RELOC_386_TLS_GD:
10435
    case BFD_RELOC_386_TLS_GD:
10221
    case BFD_RELOC_386_TLS_LDM:
10436
    case BFD_RELOC_386_TLS_LDM:
Line 10269... Line 10484...
10269
			    fixp->fx_size);
10484
			    fixp->fx_size);
10270
	      code = BFD_RELOC_32_PCREL;
10485
	      code = BFD_RELOC_32_PCREL;
10271
	      break;
10486
	      break;
10272
	    case 1: code = BFD_RELOC_8_PCREL;  break;
10487
	    case 1: code = BFD_RELOC_8_PCREL;  break;
10273
	    case 2: code = BFD_RELOC_16_PCREL; break;
10488
	    case 2: code = BFD_RELOC_16_PCREL; break;
10274
	    case 4:
-
 
10275
	      code = (fixp->fx_r_type == BFD_RELOC_X86_64_PC32_BND
-
 
10276
		      ? fixp-> fx_r_type : BFD_RELOC_32_PCREL);
10489
	    case 4: code = BFD_RELOC_32_PCREL; break;
10277
	      break;
-
 
10278
#ifdef BFD64
10490
#ifdef BFD64
10279
	    case 8: code = BFD_RELOC_64_PCREL; break;
10491
	    case 8: code = BFD_RELOC_64_PCREL; break;
10280
#endif
10492
#endif
10281
	    }
10493
	    }
10282
	}
10494
	}
Line 10365... Line 10577...
10365
	rel->addend = fixp->fx_offset;
10577
	rel->addend = fixp->fx_offset;
10366
      else
10578
      else
10367
	switch (code)
10579
	switch (code)
10368
	  {
10580
	  {
10369
	  case BFD_RELOC_X86_64_PLT32:
10581
	  case BFD_RELOC_X86_64_PLT32:
10370
	  case BFD_RELOC_X86_64_PLT32_BND:
-
 
10371
	  case BFD_RELOC_X86_64_GOT32:
10582
	  case BFD_RELOC_X86_64_GOT32:
10372
	  case BFD_RELOC_X86_64_GOTPCREL:
10583
	  case BFD_RELOC_X86_64_GOTPCREL:
-
 
10584
	  case BFD_RELOC_X86_64_GOTPCRELX:
-
 
10585
	  case BFD_RELOC_X86_64_REX_GOTPCRELX:
10373
	  case BFD_RELOC_X86_64_TLSGD:
10586
	  case BFD_RELOC_X86_64_TLSGD:
10374
	  case BFD_RELOC_X86_64_TLSLD:
10587
	  case BFD_RELOC_X86_64_TLSLD:
10375
	  case BFD_RELOC_X86_64_GOTTPOFF:
10588
	  case BFD_RELOC_X86_64_GOTTPOFF:
10376
	  case BFD_RELOC_X86_64_GOTPC32_TLSDESC:
10589
	  case BFD_RELOC_X86_64_GOTPC32_TLSDESC:
10377
	  case BFD_RELOC_X86_64_TLSDESC_CALL:
10590
	  case BFD_RELOC_X86_64_TLSDESC_CALL: