* config/tc-s390.c (s390_elf_cons): Correct fixups for PLT
[deliverable/binutils-gdb.git] / gas / config / tc-i386.c
index c23541382b48b57dbb950d2826fdbbda8d1728a9..275b3e6c439d6ccef86aa3f5ccc2157d2cc16d6f 100644 (file)
@@ -157,7 +157,7 @@ const char extra_symbol_chars[] = "*%-(";
 
 /* This array holds the chars that always start a comment.  If the
    pre-processor is disabled, these aren't very useful.  */
-#if defined (TE_I386AIX) || ((defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) && ! defined (TE_LINUX) && !defined(TE_FreeBSD))
+#if defined (TE_I386AIX) || ((defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) && ! defined (TE_LINUX) && !defined(TE_FreeBSD) && !defined(TE_NetBSD))
 /* Putting '/' here makes it impossible to use the divide operator.
    However, we need it for compatibility with SVR4 systems.  */
 const char comment_chars[] = "#/";
@@ -175,7 +175,7 @@ const char comment_chars[] = "#";
    #NO_APP at the beginning of its output.
    Also note that comments started like this one will always work if
    '/' isn't otherwise defined.  */
-#if defined (TE_I386AIX) || ((defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) && ! defined (TE_LINUX) && !defined(TE_FreeBSD))
+#if defined (TE_I386AIX) || ((defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) && ! defined (TE_LINUX) && !defined(TE_FreeBSD) && !defined(TE_NetBSD))
 const char line_comment_chars[] = "";
 #else
 const char line_comment_chars[] = "/";
@@ -1269,7 +1269,8 @@ md_assemble (line)
          }
        if (!is_space_char (*l)
            && *l != END_OF_INSN
-           && *l != PREFIX_SEPARATOR)
+           && *l != PREFIX_SEPARATOR
+           && *l != ',')
          {
            as_bad (_("invalid character %s in mnemonic"),
                    output_invalid (*l));
@@ -1360,6 +1361,38 @@ md_assemble (line)
          }
       }
 
+    if (current_templates->start->opcode_modifier & (Jump | JumpByte))
+      {
+       /* Check for a branch hint.  We allow ",pt" and ",pn" for
+          predict taken and predict not taken respectively.
+          I'm not sure that branch hints actually do anything on loop
+          and jcxz insns (JumpByte) for current Pentium4 chips.  They
+          may work in the future and it doesn't hurt to accept them
+          now.  */
+       if (l[0] == ',' && l[1] == 'p')
+         {
+           if (l[2] == 't')
+             {
+               if (! add_prefix (DS_PREFIX_OPCODE))
+                 return;
+               l += 3;
+             }
+           else if (l[2] == 'n')
+             {
+               if (! add_prefix (CS_PREFIX_OPCODE))
+                 return;
+               l += 3;
+             }
+         }
+      }
+    /* Any other comma loses.  */
+    if (*l == ',')
+      {
+       as_bad (_("invalid character %s in mnemonic"),
+               output_invalid (*l));
+       return;
+      }
+
     /* Check if instruction is supported on specified architecture.  */
     if (cpu_arch_flags != 0)
       {
@@ -3148,27 +3181,41 @@ lex_got (reloc, adjust)
       int len;
 
       len = strlen (gotrel[j].str);
-      if (strncmp (cp + 1, gotrel[j].str, len) == 0)
+      if (strncasecmp (cp + 1, gotrel[j].str, len) == 0)
        {
          if (gotrel[j].rel[(unsigned int) flag_code] != 0)
            {
-             int first;
-             char *tmpbuf;
+             int first, second;
+             char *tmpbuf, *past_reloc;
 
              *reloc = gotrel[j].rel[(unsigned int) flag_code];
+             if (adjust)
+               *adjust = len;
 
              if (GOT_symbol == NULL)
                GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME);
 
              /* Replace the relocation token with ' ', so that
                 errors like foo@GOTOFF1 will be detected.  */
+
+             /* The length of the first part of our input line.  */
              first = cp - input_line_pointer;
-             tmpbuf = xmalloc (strlen (input_line_pointer));
+
+             /* The second part goes from after the reloc token until
+                (and including) an end_of_line char.  Don't use strlen
+                here as the end_of_line char may not be a NUL.  */
+             past_reloc = cp + 1 + len;
+             for (cp = past_reloc; !is_end_of_line[(unsigned char) *cp++]; )
+               ;
+             second = cp - past_reloc;
+
+             /* Allocate and copy string.  The trailing NUL shouldn't
+                be necessary, but be safe.  */
+             tmpbuf = xmalloc (first + second + 2);
              memcpy (tmpbuf, input_line_pointer, first);
              tmpbuf[first] = ' ';
-             strcpy (tmpbuf + first + 1, cp + 1 + len);
-             if (adjust)
-               *adjust = len;
+             memcpy (tmpbuf + first + 1, past_reloc, second);
+             tmpbuf[first + second + 1] = '\0';
              return tmpbuf;
            }
 
@@ -4055,15 +4102,6 @@ md_convert_frag (abfd, sec, fragP)
 
   /* Address we want to reach in file space.  */
   target_address = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset;
-#ifdef BFD_ASSEMBLER
-  /* Not needed otherwise?  */
-  {
-    /* Local symbols which have already been resolved have a NULL frag.  */
-    fragS *sym_frag = symbol_get_frag (fragP->fr_symbol);
-    if (sym_frag)
-      target_address += sym_frag->fr_address;
-  }
-#endif
 
   /* Address opcode resides at in file space.  */
   opcode_address = fragP->fr_address + fragP->fr_fix;
@@ -4747,8 +4785,9 @@ tc_gen_reloc (section, fixp)
          switch (fixp->fx_size)
            {
            default:
-             as_bad (_("can not do %d byte pc-relative relocation"),
-                     fixp->fx_size);
+             as_bad_where (fixp->fx_file, fixp->fx_line,
+                           _("can not do %d byte pc-relative relocation"),
+                           fixp->fx_size);
              code = BFD_RELOC_32_PCREL;
              break;
            case 1: code = BFD_RELOC_8_PCREL;  break;
@@ -4761,7 +4800,9 @@ tc_gen_reloc (section, fixp)
          switch (fixp->fx_size)
            {
            default:
-             as_bad (_("can not do %d byte relocation"), fixp->fx_size);
+             as_bad_where (fixp->fx_file, fixp->fx_line,
+                           _("can not do %d byte relocation"),
+                           fixp->fx_size);
              code = BFD_RELOC_32;
              break;
            case 1: code = BFD_RELOC_8;  break;
This page took 0.025361 seconds and 4 git commands to generate.