gas/
[deliverable/binutils-gdb.git] / gas / config / tc-i386.c
index 889bfc3767240c9846ac4e977595abaadb1930a0..1786b1d17c8f2c2826f97b8477aa6168dc15650d 100644 (file)
@@ -32,7 +32,6 @@
 #include "subsegs.h"
 #include "dwarf2dbg.h"
 #include "dw2gencfi.h"
-#include "opcode/i386.h"
 #include "elf/x86-64.h"
 
 #ifndef REGISTER_WARNINGS
@@ -78,7 +77,7 @@ static const reg_entry *parse_register (char *, char **);
 static char *parse_insn (char *, char *);
 static char *parse_operands (char *, const char *);
 static void swap_operands (void);
-static void swap_imm_operands (void);
+static void swap_2_operands (int, int);
 static void optimize_imm (void);
 static void optimize_disp (void);
 static int match_template (void);
@@ -740,10 +739,11 @@ i386_align_code (fragS *fragP, int count)
 
   /* We need to decide which NOP sequence to use for 32bit and
      64bit. When -mtune= is used:
-  
+
      1. For PROCESSOR_I486, PROCESSOR_PENTIUM and PROCESSOR_GENERIC32,
      f32_patt will be used.
-     2. For PROCESSOR_K8 and PROCESSOR_AMDFAM10 in 64bit, NOPs with 0x66 prefix will be used.
+     2. For PROCESSOR_K8 and PROCESSOR_AMDFAM10 in 64bit, NOPs with
+     0x66 prefix will be used.
      3. For PROCESSOR_CORE2, alt_long_patt will be used.
      4. For PROCESSOR_PENTIUMPRO, PROCESSOR_PENTIUM4, PROCESSOR_NOCONA,
      PROCESSOR_CORE, PROCESSOR_CORE2, PROCESSOR_K6, PROCESSOR_ATHLON
@@ -772,7 +772,7 @@ i386_align_code (fragS *fragP, int count)
       int pos = 0;
 
       /* The recommended way to pad 64bit code is to use NOPs preceded
-         by maximally four 0x66 prefixes.  Balance the size of nops.  */
+        by maximally four 0x66 prefixes.  Balance the size of nops.  */
       for (i = 0; i < remains; i++)
        {
          memset (fragP->fr_literal + fragP->fr_fix + pos, 0x66, len);
@@ -814,7 +814,7 @@ i386_align_code (fragS *fragP, int count)
            case PROCESSOR_ATHLON:
            case PROCESSOR_K8:
            case PROCESSOR_GENERIC64:
-           case PROCESSOR_AMDFAM10:  
+           case PROCESSOR_AMDFAM10:
              patt = alt_short_patt;
              break;
            case PROCESSOR_I486:
@@ -822,7 +822,7 @@ i386_align_code (fragS *fragP, int count)
            case PROCESSOR_GENERIC32:
              patt = f32_patt;
              break;
-           } 
+           }
        }
       else
        {
@@ -843,7 +843,7 @@ i386_align_code (fragS *fragP, int count)
            case PROCESSOR_K6:
            case PROCESSOR_ATHLON:
            case PROCESSOR_K8:
-            case PROCESSOR_AMDFAM10:
+           case PROCESSOR_AMDFAM10:
            case PROCESSOR_GENERIC32:
              /* We use cpu_arch_isa_flags to check if we CAN optimize
                 for Cpu686.  */
@@ -861,7 +861,7 @@ i386_align_code (fragS *fragP, int count)
            case PROCESSOR_GENERIC64:
              patt = alt_short_patt;
              break;
-           } 
+           }
        }
 
       memcpy (fragP->fr_literal + fragP->fr_fix,
@@ -991,9 +991,9 @@ add_prefix (unsigned int prefix)
   if (prefix >= REX_OPCODE && prefix < REX_OPCODE + 16
       && flag_code == CODE_64BIT)
     {
-      if ((i.prefix[REX_PREFIX] & prefix & REX_MODE64)
-         || ((i.prefix[REX_PREFIX] & (REX_EXTX | REX_EXTY | REX_EXTZ))
-             && (prefix & (REX_EXTX | REX_EXTY | REX_EXTZ))))
+      if ((i.prefix[REX_PREFIX] & prefix & REX_W)
+         || ((i.prefix[REX_PREFIX] & (REX_R | REX_X | REX_B))
+             && (prefix & (REX_R | REX_X | REX_B))))
        ret = 0;
       q = REX_PREFIX;
     }
@@ -1130,7 +1130,8 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
                  cpu_arch_name = cpu_arch[i].name;
                  cpu_sub_arch_name = NULL;
                  cpu_arch_flags = (cpu_arch[i].flags
-                                   | (flag_code == CODE_64BIT ? Cpu64 : CpuNo64));
+                                   | (flag_code == CODE_64BIT
+                                      ? Cpu64 : CpuNo64));
                  cpu_arch_isa = cpu_arch[i].type;
                  cpu_arch_isa_flags = cpu_arch[i].flags;
                  if (!cpu_arch_tune_set)
@@ -1236,10 +1237,9 @@ md_begin ()
   reg_hash = hash_new ();
   {
     const reg_entry *regtab;
+    unsigned int regtab_size = i386_regtab_size;
 
-    for (regtab = i386_regtab;
-        regtab < i386_regtab + sizeof (i386_regtab) / sizeof (i386_regtab[0]);
-        regtab++)
+    for (regtab = i386_regtab; regtab_size--; regtab++)
       {
        hash_err = hash_insert (reg_hash, regtab->reg_name, (PTR) regtab);
        if (hash_err)
@@ -1294,6 +1294,7 @@ md_begin ()
 #endif
     digit_chars['-'] = '-';
     mnemonic_chars['-'] = '-';
+    mnemonic_chars['.'] = '.';
     identifier_chars['_'] = '_';
     identifier_chars['.'] = '.';
 
@@ -1353,10 +1354,10 @@ pi (char *line, i386_insn *x)
   fprintf (stdout, "  sib:  base %x  index %x  scale %x\n",
           x->sib.base, x->sib.index, x->sib.scale);
   fprintf (stdout, "  rex: 64bit %x  extX %x  extY %x  extZ %x\n",
-          (x->rex & REX_MODE64) != 0,
-          (x->rex & REX_EXTX) != 0,
-          (x->rex & REX_EXTY) != 0,
-          (x->rex & REX_EXTZ) != 0);
+          (x->rex & REX_W) != 0,
+          (x->rex & REX_R) != 0,
+          (x->rex & REX_X) != 0,
+          (x->rex & REX_B) != 0);
   for (i = 0; i < x->operands; i++)
     {
       fprintf (stdout, "    #%d:  ", i + 1);
@@ -1714,14 +1715,14 @@ md_assemble (line)
   if (line == NULL)
     return;
 
-  /* The order of the immediates should be reversed 
+  /* The order of the immediates should be reversed
      for 2 immediates extrq and insertq instructions */
-  if ((i.imm_operands == 2) && 
-      ((strcmp (mnemonic, "extrq") == 0) 
-       || (strcmp (mnemonic, "insertq") == 0)))
+  if ((i.imm_operands == 2)
+      && ((strcmp (mnemonic, "extrq") == 0)
+         || (strcmp (mnemonic, "insertq") == 0)))
     {
-      swap_imm_operands ();  
-      /* "extrq" and insertq" are the only two instructions whose operands 
+      swap_2_operands (0, 1);
+      /* "extrq" and insertq" are the only two instructions whose operands
         have to be reversed even though they have two immediate operands.
       */
       if (intel_syntax)
@@ -1735,7 +1736,8 @@ md_assemble (line)
      "enter".  We also don't reverse intersegment "jmp" and "call"
      instructions with 2 immediate operands so that the immediate segment
      precedes the offset, as it does when in AT&T mode. */
-  if (intel_syntax && i.operands > 1
+  if (intel_syntax
+      && i.operands > 1
       && (strcmp (mnemonic, "bound") != 0)
       && (strcmp (mnemonic, "invlpga") != 0)
       && !((i.types[0] & Imm) && (i.types[1] & Imm)))
@@ -1763,7 +1765,7 @@ md_assemble (line)
       /* Undo SYSV386_COMPAT brokenness when in Intel mode.  See i386.h  */
       if (SYSV386_COMPAT
          && (i.tm.base_opcode & 0xfffffde0) == 0xdce0)
-       i.tm.base_opcode ^= FloatR;
+       i.tm.base_opcode ^= Opcode_FloatR;
 
       /* Zap movzx and movsx suffix.  The suffix may have been set from
         "word ptr" or "byte ptr" on the source operand, but we'll use
@@ -1877,7 +1879,7 @@ md_assemble (line)
     }
 
   if ((i.tm.opcode_modifier & Rex64) != 0)
-    i.rex |= REX_MODE64;
+    i.rex |= REX_W;
 
   /* For 8 bit registers we need an empty rex prefix.  Also if the
      instruction already has a prefix, we need to convert old
@@ -1901,7 +1903,8 @@ md_assemble (line)
            {
              /* In case it is "hi" register, give up.  */
              if (i.op[x].regs->reg_num > 3)
-               as_bad (_("can't encode register '%%%s' in an instruction requiring REX prefix."),
+               as_bad (_("can't encode register '%%%s' in an "
+                         "instruction requiring REX prefix."),
                        i.op[x].regs->reg_name);
 
              /* Otherwise it is equivalent to the extended register.
@@ -2258,14 +2261,12 @@ parse_operands (char *l, const char *mnemonic)
 }
 
 static void
-swap_imm_operands (void)
+swap_2_operands (int xchg1, int xchg2)
 {
   union i386_op temp_op;
   unsigned int temp_type;
   enum bfd_reloc_code_real temp_reloc;
-  int xchg1 = 0;
-  int xchg2 = 1;
-  
+
   temp_type = i.types[xchg2];
   i.types[xchg2] = i.types[xchg1];
   i.types[xchg1] = temp_type;
@@ -2277,42 +2278,16 @@ swap_imm_operands (void)
   i.reloc[xchg1] = temp_reloc;
 }
 
-
 static void
 swap_operands (void)
 {
-  union i386_op temp_op;
-  unsigned int temp_type;
-  enum bfd_reloc_code_real temp_reloc;
-  int xchg1, xchg2;
-
   switch (i.operands)
     {
     case 4:
-      xchg1 = 1;
-      xchg2 = i.operands - 2;
-      temp_type = i.types[xchg2];
-      i.types[xchg2] = i.types[xchg1];
-      i.types[xchg1] = temp_type;
-      temp_op = i.op[xchg2];
-      i.op[xchg2] = i.op[xchg1];
-      i.op[xchg1] = temp_op;
-      temp_reloc = i.reloc[xchg2];
-      i.reloc[xchg2] = i.reloc[xchg1];
-      i.reloc[xchg1] = temp_reloc;
+      swap_2_operands (1, i.operands - 2);
     case 3:
     case 2:
-      xchg1 = 0;
-      xchg2 = i.operands - 1;
-      temp_type = i.types[xchg2];
-      i.types[xchg2] = i.types[xchg1];
-      i.types[xchg1] = temp_type;
-      temp_op = i.op[xchg2];
-      i.op[xchg2] = i.op[xchg1];
-      i.op[xchg1] = temp_op;
-      temp_reloc = i.reloc[xchg2];
-      i.reloc[xchg2] = i.reloc[xchg1];
-      i.reloc[xchg1] = temp_reloc;
+      swap_2_operands (0, i.operands - 1);
       break;
     default:
       abort ();
@@ -2420,8 +2395,10 @@ optimize_imm (void)
              unsigned int mask, allowed = 0;
              const template *t;
 
-             for (t = current_templates->start; t < current_templates->end; ++t)
-               allowed |= t->operand_types[op];
+             for (t = current_templates->start;
+                  t < current_templates->end;
+                  ++t)
+               allowed |= t->operand_types[op];
              switch (guess_suffix)
                {
                case QWORD_MNEM_SUFFIX:
@@ -2645,6 +2622,15 @@ match_template (void)
            continue;
          break;
        case 2:
+         /* xchg %eax, %eax is a special case. It is an aliase for nop
+            only in 32bit mode and we can use opcode 0x90.  In 64bit
+            mode, we can't use 0x90 for xchg %eax, %eax since it should
+            zero-extend %eax to %rax.  */
+         if (flag_code == CODE_64BIT
+             && t->base_opcode == 0x90
+             && i.types [0] == (Acc | Reg32)
+             && i.types [1] == (Acc | Reg32))
+           continue;
        case 3:
        case 4:
          overlap1 = i.types[1] & operand_types[1];
@@ -2679,7 +2665,14 @@ match_template (void)
                }
              /* found_reverse_match holds which of D or FloatDR
                 we've found.  */
-             found_reverse_match = t->opcode_modifier & (D | FloatDR);
+             if ((t->opcode_modifier & D))
+               found_reverse_match = Opcode_D;
+             else if ((t->opcode_modifier & FloatD))
+               found_reverse_match = Opcode_FloatD;
+             else
+               found_reverse_match = 0;
+             if ((t->opcode_modifier & FloatR))
+               found_reverse_match |= Opcode_FloatR;
            }
          else
            {
@@ -2913,7 +2906,8 @@ process_suffix (void)
        {
          if (i.tm.opcode_modifier & W)
            {
-             as_bad (_("no instruction mnemonic suffix given and no register operands; can't size instruction"));
+             as_bad (_("no instruction mnemonic suffix given and "
+                       "no register operands; can't size instruction"));
              return 0;
            }
        }
@@ -2990,8 +2984,8 @@ process_suffix (void)
          if (i.operands != 2
              || i.types [0] != (Acc | Reg64)
              || i.types [1] != (Acc | Reg64)
-             || strcmp (i.tm.name, "xchg") != 0)
-         i.rex |= REX_MODE64;
+             || i.tm.base_opcode != 0x90)
+         i.rex |= REX_W;
        }
 
       /* Size floating point instruction.  */
@@ -3221,7 +3215,8 @@ finalize_imm (void)
          && overlap0 != Imm16 && overlap0 != Imm32S
          && overlap0 != Imm32 && overlap0 != Imm64)
        {
-         as_bad (_("no instruction mnemonic suffix given; can't determine immediate size"));
+         as_bad (_("no instruction mnemonic suffix given; "
+                   "can't determine immediate size"));
          return 0;
        }
     }
@@ -3254,7 +3249,9 @@ finalize_imm (void)
          && overlap1 != Imm16 && overlap1 != Imm32S
          && overlap1 != Imm32 && overlap1 != Imm64)
        {
-         as_bad (_("no instruction mnemonic suffix given; can't determine immediate size %x %c"),overlap1, i.suffix);
+         as_bad (_("no instruction mnemonic suffix given; "
+                   "can't determine immediate size %x %c"),
+                 overlap1, i.suffix);
          return 0;
        }
     }
@@ -3292,28 +3289,43 @@ process_operands (void)
 
   if (i.tm.opcode_modifier & ShortForm)
     {
-      /* The register or float register operand is in operand 0 or 1.  */
-      unsigned int op = (i.types[0] & (Reg | FloatReg)) ? 0 : 1;
-      /* Register goes in low 3 bits of opcode.  */
-      i.tm.base_opcode |= i.op[op].regs->reg_num;
-      if ((i.op[op].regs->reg_flags & RegRex) != 0)
-       i.rex |= REX_EXTZ;
-      if (!quiet_warnings && (i.tm.opcode_modifier & Ugh) != 0)
+      if (i.types[0] & (SReg2 | SReg3))
        {
-         /* Warn about some common errors, but press on regardless.
-            The first case can be generated by gcc (<= 2.8.1).  */
-         if (i.operands == 2)
+         if (i.tm.base_opcode == POP_SEG_SHORT
+             && i.op[0].regs->reg_num == 1)
            {
-             /* Reversed arguments on faddp, fsubp, etc.  */
-             as_warn (_("translating to `%s %%%s,%%%s'"), i.tm.name,
-                      i.op[1].regs->reg_name,
-                      i.op[0].regs->reg_name);
+             as_bad (_("you can't `pop %%cs'"));
+             return 0;
            }
-         else
+         i.tm.base_opcode |= (i.op[0].regs->reg_num << 3);
+         if ((i.op[0].regs->reg_flags & RegRex) != 0)
+           i.rex |= REX_B;
+       }
+      else
+       {
+         /* The register or float register operand is in operand 0 or 1.  */
+         unsigned int op = (i.types[0] & (Reg | FloatReg)) ? 0 : 1;
+         /* Register goes in low 3 bits of opcode.  */
+         i.tm.base_opcode |= i.op[op].regs->reg_num;
+         if ((i.op[op].regs->reg_flags & RegRex) != 0)
+           i.rex |= REX_B;
+         if (!quiet_warnings && (i.tm.opcode_modifier & Ugh) != 0)
            {
-             /* Extraneous `l' suffix on fp insn.  */
-             as_warn (_("translating to `%s %%%s'"), i.tm.name,
-                      i.op[0].regs->reg_name);
+             /* Warn about some common errors, but press on regardless.
+                The first case can be generated by gcc (<= 2.8.1).  */
+             if (i.operands == 2)
+               {
+                 /* Reversed arguments on faddp, fsubp, etc.  */
+                 as_warn (_("translating to `%s %%%s,%%%s'"), i.tm.name,
+                          i.op[1].regs->reg_name,
+                          i.op[0].regs->reg_name);
+               }
+             else
+               {
+                 /* Extraneous `l' suffix on fp insn.  */
+                 as_warn (_("translating to `%s %%%s'"), i.tm.name,
+                          i.op[0].regs->reg_name);
+               }
            }
        }
     }
@@ -3325,19 +3337,7 @@ process_operands (void)
 
       default_seg = build_modrm_byte ();
     }
-  else if (i.tm.opcode_modifier & (Seg2ShortForm | Seg3ShortForm))
-    {
-      if (i.tm.base_opcode == POP_SEG_SHORT
-         && i.op[0].regs->reg_num == 1)
-       {
-         as_bad (_("you can't `pop %%cs'"));
-         return 0;
-       }
-      i.tm.base_opcode |= (i.op[0].regs->reg_num << 3);
-      if ((i.op[0].regs->reg_flags & RegRex) != 0)
-       i.rex |= REX_EXTZ;
-    }
-  else if ((i.tm.base_opcode & ~(D | W)) == MOV_AX_DISP32)
+  else if ((i.tm.base_opcode & ~0x3) == MOV_AX_DISP32)
     {
       default_seg = &ds;
     }
@@ -3412,29 +3412,29 @@ build_modrm_byte (void)
         destination operand, then we assume the source operand may
         sometimes be a memory operand and so we need to store the
         destination in the i.rm.reg field.  */
-      if ((i.tm.operand_types[dest] & AnyMem) == 0)
+      if ((i.tm.operand_types[dest] & (AnyMem | RegMem)) == 0)
        {
          i.rm.reg = i.op[dest].regs->reg_num;
          i.rm.regmem = i.op[source].regs->reg_num;
          if ((i.op[dest].regs->reg_flags & RegRex) != 0)
-           i.rex |= REX_EXTX;
+           i.rex |= REX_R;
          if ((i.op[source].regs->reg_flags & RegRex) != 0)
-           i.rex |= REX_EXTZ;
+           i.rex |= REX_B;
        }
       else
        {
          i.rm.reg = i.op[source].regs->reg_num;
          i.rm.regmem = i.op[dest].regs->reg_num;
          if ((i.op[dest].regs->reg_flags & RegRex) != 0)
-           i.rex |= REX_EXTZ;
+           i.rex |= REX_B;
          if ((i.op[source].regs->reg_flags & RegRex) != 0)
-           i.rex |= REX_EXTX;
+           i.rex |= REX_R;
        }
-      if (flag_code != CODE_64BIT && (i.rex & (REX_EXTX | REX_EXTZ)))
+      if (flag_code != CODE_64BIT && (i.rex & (REX_R | REX_B)))
        {
          if (!((i.types[0] | i.types[1]) & Control))
            abort ();
-         i.rex &= ~(REX_EXTX | REX_EXTZ);
+         i.rex &= ~(REX_R | REX_B);
          add_prefix (LOCK_PREFIX_OPCODE);
        }
     }
@@ -3443,9 +3443,12 @@ build_modrm_byte (void)
       if (i.mem_operands)
        {
          unsigned int fake_zero_displacement = 0;
-         unsigned int op = ((i.types[0] & AnyMem)
-                            ? 0
-                            : (i.types[1] & AnyMem) ? 1 : 2);
+         unsigned int op;
+
+         for (op = 0; op < i.operands; op++)
+           if ((i.types[op] & AnyMem))
+             break;
+         assert (op < i.operands);
 
          default_seg = &ds;
 
@@ -3493,7 +3496,7 @@ build_modrm_byte (void)
                  else
                    i.types[op] |= Disp32S;
                  if ((i.index_reg->reg_flags & RegRex) != 0)
-                   i.rex |= REX_EXTY;
+                   i.rex |= REX_X;
                }
            }
          /* RIP addressing for 64bit mode.  */
@@ -3546,7 +3549,7 @@ build_modrm_byte (void)
 
              i.rm.regmem = i.base_reg->reg_num;
              if ((i.base_reg->reg_flags & RegRex) != 0)
-               i.rex |= REX_EXTZ;
+               i.rex |= REX_B;
              i.sib.base = i.base_reg->reg_num;
              /* x86-64 ignores REX prefix bit here to avoid decoder
                 complications.  */
@@ -3583,7 +3586,7 @@ build_modrm_byte (void)
                  i.sib.index = i.index_reg->reg_num;
                  i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
                  if ((i.index_reg->reg_flags & RegRex) != 0)
-                   i.rex |= REX_EXTY;
+                   i.rex |= REX_X;
                }
 
              if (i.disp_operands
@@ -3616,31 +3619,28 @@ build_modrm_byte (void)
         registers are coded into the i.rm.reg field.  */
       if (i.reg_operands)
        {
-         unsigned int op =
-           ((i.types[0]
-             & (Reg | RegMMX | RegXMM
-                | SReg2 | SReg3
-                | Control | Debug | Test))
-            ? 0
-            : ((i.types[1]
-                & (Reg | RegMMX | RegXMM
-                   | SReg2 | SReg3
-                   | Control | Debug | Test))
-               ? 1
-               : 2));
+         unsigned int op;
+
+         for (op = 0; op < i.operands; op++)
+           if ((i.types[op] & (Reg | RegMMX | RegXMM
+                               | SReg2 | SReg3
+                               | Control | Debug | Test)))
+             break;
+         assert (op < i.operands);
+
          /* If there is an extension opcode to put here, the register
             number must be put into the regmem field.  */
          if (i.tm.extension_opcode != None)
            {
              i.rm.regmem = i.op[op].regs->reg_num;
              if ((i.op[op].regs->reg_flags & RegRex) != 0)
-               i.rex |= REX_EXTZ;
+               i.rex |= REX_B;
            }
          else
            {
              i.rm.reg = i.op[op].regs->reg_num;
              if ((i.op[op].regs->reg_flags & RegRex) != 0)
-               i.rex |= REX_EXTX;
+               i.rex |= REX_R;
            }
 
          /* Now, if no memory operand has set i.rm.mode = 0, 1, 2 we
@@ -4304,23 +4304,57 @@ lex_got (enum bfd_reloc_code_real *reloc,
     const enum bfd_reloc_code_real rel[2];
     const unsigned int types64;
   } gotrel[] = {
-    { "PLTOFF",   { 0,                        BFD_RELOC_X86_64_PLTOFF64 }, Imm64 },
-    { "PLT",      { BFD_RELOC_386_PLT32,      BFD_RELOC_X86_64_PLT32    }, Imm32|Imm32S|Disp32 },
-    { "GOTPLT",   { 0,                        BFD_RELOC_X86_64_GOTPLT64 }, Imm64|Disp64 },
-    { "GOTOFF",   { BFD_RELOC_386_GOTOFF,     BFD_RELOC_X86_64_GOTOFF64 }, Imm64|Disp64 },
-    { "GOTPCREL", { 0,                        BFD_RELOC_X86_64_GOTPCREL }, Imm32|Imm32S|Disp32 },
-    { "TLSGD",    { BFD_RELOC_386_TLS_GD,     BFD_RELOC_X86_64_TLSGD    }, Imm32|Imm32S|Disp32 },
-    { "TLSLDM",   { BFD_RELOC_386_TLS_LDM,    0                         }, 0 },
-    { "TLSLD",    { 0,                        BFD_RELOC_X86_64_TLSLD    }, Imm32|Imm32S|Disp32 },
-    { "GOTTPOFF", { BFD_RELOC_386_TLS_IE_32,  BFD_RELOC_X86_64_GOTTPOFF }, Imm32|Imm32S|Disp32 },
-    { "TPOFF",    { BFD_RELOC_386_TLS_LE_32,  BFD_RELOC_X86_64_TPOFF32  }, Imm32|Imm32S|Imm64|Disp32|Disp64 },
-    { "NTPOFF",   { BFD_RELOC_386_TLS_LE,     0                         }, 0 },
-    { "DTPOFF",   { BFD_RELOC_386_TLS_LDO_32, BFD_RELOC_X86_64_DTPOFF32 }, Imm32|Imm32S|Imm64|Disp32|Disp64 },
-    { "GOTNTPOFF",{ BFD_RELOC_386_TLS_GOTIE,  0                         }, 0 },
-    { "INDNTPOFF",{ BFD_RELOC_386_TLS_IE,     0                         }, 0 },
-    { "GOT",      { BFD_RELOC_386_GOT32,      BFD_RELOC_X86_64_GOT32    }, Imm32|Imm32S|Disp32|Imm64 },
-    { "TLSDESC",  { BFD_RELOC_386_TLS_GOTDESC, BFD_RELOC_X86_64_GOTPC32_TLSDESC }, Imm32|Imm32S|Disp32 },
-    { "TLSCALL",  { BFD_RELOC_386_TLS_DESC_CALL, BFD_RELOC_X86_64_TLSDESC_CALL }, Imm32|Imm32S|Disp32 }
+    { "PLTOFF",   { 0,
+                   BFD_RELOC_X86_64_PLTOFF64 },
+      Imm64 },
+    { "PLT",      { BFD_RELOC_386_PLT32,
+                   BFD_RELOC_X86_64_PLT32    },
+      Imm32 | Imm32S | Disp32 },
+    { "GOTPLT",   { 0,
+                   BFD_RELOC_X86_64_GOTPLT64 },
+      Imm64 | Disp64 },
+    { "GOTOFF",   { BFD_RELOC_386_GOTOFF,
+                   BFD_RELOC_X86_64_GOTOFF64 },
+      Imm64 | Disp64 },
+    { "GOTPCREL", { 0,
+                   BFD_RELOC_X86_64_GOTPCREL },
+      Imm32 | Imm32S | Disp32 },
+    { "TLSGD",    { BFD_RELOC_386_TLS_GD,
+                   BFD_RELOC_X86_64_TLSGD    },
+      Imm32 | Imm32S | Disp32 },
+    { "TLSLDM",   { BFD_RELOC_386_TLS_LDM,
+                   0                         },
+      0 },
+    { "TLSLD",    { 0,
+                   BFD_RELOC_X86_64_TLSLD    },
+      Imm32 | Imm32S | Disp32 },
+    { "GOTTPOFF", { BFD_RELOC_386_TLS_IE_32,
+                   BFD_RELOC_X86_64_GOTTPOFF },
+      Imm32 | Imm32S | Disp32 },
+    { "TPOFF",    { BFD_RELOC_386_TLS_LE_32,
+                   BFD_RELOC_X86_64_TPOFF32  },
+      Imm32 | Imm32S | Imm64 | Disp32 | Disp64 },
+    { "NTPOFF",   { BFD_RELOC_386_TLS_LE,
+                   0                         },
+      0 },
+    { "DTPOFF",   { BFD_RELOC_386_TLS_LDO_32,
+                   BFD_RELOC_X86_64_DTPOFF32 },
+      Imm32 | Imm32S | Imm64 | Disp32 | Disp64 },
+    { "GOTNTPOFF",{ BFD_RELOC_386_TLS_GOTIE,
+                   0                         },
+      0 },
+    { "INDNTPOFF",{ BFD_RELOC_386_TLS_IE,
+                   0                         },
+      0 },
+    { "GOT",      { BFD_RELOC_386_GOT32,
+                   BFD_RELOC_X86_64_GOT32    },
+      Imm32 | Imm32S | Disp32 | Imm64 },
+    { "TLSDESC",  { BFD_RELOC_386_TLS_GOTDESC,
+                   BFD_RELOC_X86_64_GOTPC32_TLSDESC },
+      Imm32 | Imm32S | Disp32 },
+    { "TLSCALL",  { BFD_RELOC_386_TLS_DESC_CALL,
+                   BFD_RELOC_X86_64_TLSDESC_CALL },
+      Imm32 | Imm32S | Disp32 }
   };
   char *cp;
   unsigned int j;
@@ -4351,7 +4385,7 @@ lex_got (enum bfd_reloc_code_real *reloc,
              if (types)
                {
                  if (flag_code != CODE_64BIT)
-                   *types = Imm32|Disp32;
+                   *types = Imm32 | Disp32;
                  else
                    *types = gotrel[j].types64;
                }
@@ -4510,9 +4544,10 @@ i386_immediate (char *imm_start)
       /* Size it properly later.  */
       i.types[this_operand] |= Imm64;
       /* If BFD64, sign extend val.  */
-      if (!use_rela_relocations)
-       if ((exp->X_add_number & ~(((addressT) 2 << 31) - 1)) == 0)
-         exp->X_add_number = (exp->X_add_number ^ ((addressT) 1 << 31)) - ((addressT) 1 << 31);
+      if (!use_rela_relocations
+         && (exp->X_add_number & ~(((addressT) 2 << 31) - 1)) == 0)
+       exp->X_add_number
+         = (exp->X_add_number ^ ((addressT) 1 << 31)) - ((addressT) 1 << 31);
     }
 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
   else if (OUTPUT_FLAVOR == bfd_target_aout_flavour
@@ -4864,7 +4899,8 @@ i386_index_check (const char *operand_string)
             FIXME.  There doesn't seem to be any real need for separate
             Disp16 and Disp32 flags.  The same goes for Imm16 and Imm32.
             Removing them would probably clean up the code quite a lot.  */
-         if (flag_code != CODE_64BIT && (i.types[this_operand] & (Disp16 | Disp32)))
+         if (flag_code != CODE_64BIT
+             && (i.types[this_operand] & (Disp16 | Disp32)))
            i.types[this_operand] ^= (Disp16 | Disp32);
          fudged = 1;
          goto tryprefix;
@@ -5043,7 +5079,8 @@ i386_operand (char *operand_string)
            ++base_string;
 
          if (*base_string == ','
-             || ((i.base_reg = parse_register (base_string, &end_op)) != NULL))
+             || ((i.base_reg = parse_register (base_string, &end_op))
+                 != NULL))
            {
              displacement_string_end = temp_string;
 
@@ -5063,7 +5100,8 @@ i386_operand (char *operand_string)
                  if (is_space_char (*base_string))
                    ++base_string;
 
-                 if ((i.index_reg = parse_register (base_string, &end_op)) != NULL)
+                 if ((i.index_reg = parse_register (base_string, &end_op))
+                     != NULL)
                    {
                      base_string = end_op;
                      if (is_space_char (*base_string))
@@ -5076,7 +5114,8 @@ i386_operand (char *operand_string)
                        }
                      else if (*base_string != ')')
                        {
-                         as_bad (_("expecting `,' or `)' after index register in `%s'"),
+                         as_bad (_("expecting `,' or `)' "
+                                   "after index register in `%s'"),
                                  operand_string);
                          return 0;
                        }
@@ -5100,21 +5139,24 @@ i386_operand (char *operand_string)
                        ++base_string;
                      if (*base_string != ')')
                        {
-                         as_bad (_("expecting `)' after scale factor in `%s'"),
+                         as_bad (_("expecting `)' "
+                                   "after scale factor in `%s'"),
                                  operand_string);
                          return 0;
                        }
                    }
                  else if (!i.index_reg)
                    {
-                     as_bad (_("expecting index register or scale factor after `,'; got '%c'"),
+                     as_bad (_("expecting index register or scale factor "
+                               "after `,'; got '%c'"),
                              *base_string);
                      return 0;
                    }
                }
              else if (*base_string != ')')
                {
-                 as_bad (_("expecting `,' or `)' after base register in `%s'"),
+                 as_bad (_("expecting `,' or `)' "
+                           "after base register in `%s'"),
                          operand_string);
                  return 0;
                }
@@ -5330,7 +5372,8 @@ md_convert_frag (abfd, sec, fragP)
     {
       if (no_cond_jump_promotion
          && TYPE_FROM_RELAX_STATE (fragP->fr_subtype) != UNCOND_JUMP)
-       as_warn_where (fragP->fr_file, fragP->fr_line, _("long jump required"));
+       as_warn_where (fragP->fr_file, fragP->fr_line,
+                      _("long jump required"));
 
       switch (fragP->fr_subtype)
        {
@@ -5381,8 +5424,8 @@ md_convert_frag (abfd, sec, fragP)
   if (DISP_SIZE_FROM_RELAX_STATE (fragP->fr_subtype) == 4
       && object_64bit
       && ((addressT) (displacement_from_opcode_start - extension
-                      + ((addressT) 1 << 31))
-          > (((addressT) 2 << 31) - 1)))
+                     + ((addressT) 1 << 31))
+         > (((addressT) 2 << 31) - 1)))
     {
       as_bad_where (fragP->fr_file, fragP->fr_line,
                    _("jump target out of range"));
@@ -5757,7 +5800,8 @@ parse_register (char *reg_string, char **end_op)
          const expressionS *e = symbol_get_value_expression (symbolP);
 
          know (e->X_op == O_register);
-         know (e->X_add_number >= 0 && (valueT) e->X_add_number < ARRAY_SIZE (i386_regtab));
+         know (e->X_add_number >= 0
+               && (valueT) e->X_add_number < i386_regtab_size);
          r = i386_regtab + e->X_add_number;
          *end_op = input_line_pointer;
        }
@@ -5984,7 +6028,7 @@ md_show_usage (stream)
   fprintf (stream, _("\
   -march=CPU/-mtune=CPU   generate code/optimize for CPU, where CPU is one of:\n\
                            i386, i486, pentium, pentiumpro, pentium4, nocona,\n\
-                          core, core2, k6, athlon, k8, generic32, generic64\n"));
+                           core, core2, k6, athlon, k8, generic32, generic64\n"));
 
 }
 
@@ -6533,8 +6577,8 @@ struct intel_parser_s
     int got_a_float;           /* Whether the operand is a float.  */
     int op_modifier;           /* Operand modifier.  */
     int is_mem;                        /* 1 if operand is memory reference.  */
-    int in_offset;                     /* >=1 if parsing operand of offset.  */
-    int in_bracket;                    /* >=1 if parsing operand in brackets.  */
+    int in_offset;             /* >=1 if parsing operand of offset.  */
+    int in_bracket;            /* >=1 if parsing operand in brackets.  */
     const reg_entry *reg;      /* Last register reference found.  */
     char *disp;                        /* Displacement string being built.  */
     char *next_operand;                /* Resume point when splitting operands.  */
@@ -6675,7 +6719,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
        ret = i386_immediate (intel_parser.disp);
 
       if (intel_parser.next_operand && this_operand >= MAX_OPERANDS - 1)
-        ret = 0;
+       ret = 0;
       if (!ret || !intel_parser.next_operand)
        break;
       intel_parser.op_string = intel_parser.next_operand;
@@ -6744,7 +6788,9 @@ intel_e05 (void)
       if (!intel_e06())
        return 0;
 
-      if (cur_token.code == '&' || cur_token.code == '|' || cur_token.code == '^')
+      if (cur_token.code == '&'
+         || cur_token.code == '|'
+         || cur_token.code == '^')
        {
          char str[2];
 
@@ -6779,7 +6825,9 @@ intel_e06 (void)
       if (!intel_e09())
        return 0;
 
-      if (cur_token.code == '*' || cur_token.code == '/' || cur_token.code == '%')
+      if (cur_token.code == '*'
+         || cur_token.code == '/'
+         || cur_token.code == '%')
        {
          char str[2];
 
@@ -7091,7 +7139,8 @@ intel_bracket_expr (void)
                /* Defer the warning until all of the operand was parsed.  */
                intel_parser.is_mem = -1;
              else if (!quiet_warnings)
-               as_warn (_("`[%.*s]' taken to mean just `%.*s'"), len, start, len, start);
+               as_warn (_("`[%.*s]' taken to mean just `%.*s'"),
+                        len, start, len, start);
            }
        }
       intel_parser.op_modifier |= was_offset;
@@ -7181,7 +7230,8 @@ intel_e11 (void)
          {
            if (!(reg->reg_type & (SReg2 | SReg3)))
              {
-               as_bad (_("`%s' is not a valid segment register"), reg->reg_name);
+               as_bad (_("`%s' is not a valid segment register"),
+                       reg->reg_name);
                return 0;
              }
            else if (i.seg[i.mem_operands])
@@ -7371,7 +7421,8 @@ intel_e11 (void)
        /* Get the next token to check for register scaling.  */
        intel_match_token (cur_token.code);
 
-       /* Check if this constant is a scaling factor for an index register.  */
+       /* Check if this constant is a scaling factor for an
+          index register.  */
        if (cur_token.code == '*')
          {
            if (intel_match_token ('*') && cur_token.code == T_REG)
@@ -7380,14 +7431,17 @@ intel_e11 (void)
 
                if (!intel_parser.in_bracket)
                  {
-                   as_bad (_("Register scaling only allowed in memory operands"));
+                   as_bad (_("Register scaling only allowed "
+                             "in memory operands"));
                    return 0;
                  }
 
-               if (reg->reg_type & Reg16) /* Disallow things like [1*si]. */
-                 reg = i386_regtab + REGNAM_AX + 4; /* sp is invalid as index */
+                /* Disallow things like [1*si].
+                   sp and esp are invalid as index.  */
+               if (reg->reg_type & Reg16)
+                 reg = i386_regtab + REGNAM_AX + 4;
                else if (i.index_reg)
-                 reg = i386_regtab + REGNAM_EAX + 4; /* esp is invalid as index */
+                 reg = i386_regtab + REGNAM_EAX + 4;
 
                /* The constant is followed by `* reg', so it must be
                   a valid scale.  */
This page took 0.034287 seconds and 4 git commands to generate.