]> oss.titaniummirror.com Git - msp430-binutils.git/blobdiff - gas/config/tc-h8300.c
Imported binutils-2.20
[msp430-binutils.git] / gas / config / tc-h8300.c
index 57768d9aad91d77ab5a6057fa588bf839cff0a93..92c0d576027bf956121194d8d829a6903ea584ec 100644 (file)
@@ -1,6 +1,7 @@
 /* tc-h8300.c -- Assemble code for the Renesas H8/300
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -299,7 +300,7 @@ struct h8_op
 static void clever_message (const struct h8_instruction *, struct h8_op *);
 static void fix_operand_size (struct h8_op *, int);
 static void build_bytes (const struct h8_instruction *, struct h8_op *);
-static void do_a_fix_imm (int, int, struct h8_op *, int);
+static void do_a_fix_imm (int, int, struct h8_op *, int, const struct h8_instruction *);
 static void check_operand (struct h8_op *, unsigned int, char *);
 static const struct h8_instruction * get_specific (const struct h8_instruction *, struct h8_op *, int) ;
 static char *get_operands (unsigned, char *, struct h8_op *);
@@ -623,7 +624,7 @@ get_operand (char **ptr, struct h8_op *op, int direction)
              op->mode = (op->mode & ~SIZE) | L_8;
              break;
            default:
-             as_warn ("invalid suffix after register.");
+             as_warn (_("invalid suffix after register."));
              break;
            }
          src += 2;
@@ -1273,7 +1274,7 @@ check_operand (struct h8_op *operand, unsigned int width, char *string)
      (may relax into an 8bit absolute address).  */
 
 static void
-do_a_fix_imm (int offset, int nibble, struct h8_op *operand, int relaxmode)
+do_a_fix_imm (int offset, int nibble, struct h8_op *operand, int relaxmode, const struct h8_instruction *this_try)
 {
   int idx;
   int size;
@@ -1313,6 +1314,17 @@ do_a_fix_imm (int offset, int nibble, struct h8_op *operand, int relaxmode)
          check_operand (operand, 0xffff, t);
          bytes[0] |= operand->exp.X_add_number >> 8;
          bytes[1] |= operand->exp.X_add_number >> 0;
+#ifdef OBJ_ELF
+         /* MOVA needs both relocs to relax the second operand properly.  */
+         if (relaxmode != 0
+             && (OP_KIND(this_try->opcode->how) == O_MOVAB
+                 || OP_KIND(this_try->opcode->how) == O_MOVAW
+                 || OP_KIND(this_try->opcode->how) == O_MOVAL))
+           {
+             idx = BFD_RELOC_16;
+             fix_new_exp (frag_now, offset, 2, &operand->exp, 0, idx);
+           }
+#endif
          break;
        case L_24:
          check_operand (operand, 0xffffff, t);
@@ -1576,12 +1588,14 @@ build_bytes (const struct h8_instruction *this_try, struct h8_op *operand)
 
       if (x_mode == IMM || x_mode == DISP)
        do_a_fix_imm (output - frag_now->fr_literal + op_at[i] / 2,
-                     op_at[i] & 1, operand + i, (x & MEMRELAX) != 0);
+                     op_at[i] & 1, operand + i, (x & MEMRELAX) != 0,
+                     this_try);
 
       else if (x_mode == ABS)
        do_a_fix_imm (output - frag_now->fr_literal + op_at[i] / 2,
                      op_at[i] & 1, operand + i,
-                     (x & MEMRELAX) ? movb + 1 : 0);
+                     (x & MEMRELAX) ? movb + 1 : 0,
+                     this_try);
 
       else if (x_mode == PCREL)
        {
@@ -1815,7 +1829,12 @@ fix_operand_size (struct h8_op *operand, int size)
        /* This condition is long standing, though somewhat suspect.  */
        if (operand->exp.X_add_number > -128
            && operand->exp.X_add_number < 127)
-         operand->mode |= L_8;
+         {
+           if (operand->exp.X_add_symbol != NULL)
+             operand->mode |= bsize;
+           else
+             operand->mode |= L_8;
+         }
        else
          operand->mode |= L_16;
        break;
@@ -2005,68 +2024,19 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
   return 0;
 }
 
-/* Various routines to kill one day */
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
-/* Turn a string in input_line_pointer into a floating point constant
-   of type TYPE, and store the appropriate bytes in *LITP.  The number
-   of LITTLENUMS emitted is stored in *SIZEP.  An error message is
-   returned, or NULL on OK.  */
+/* Various routines to kill one day.  */
 
 char *
 md_atof (int type, char *litP, int *sizeP)
 {
-  int prec;
-  LITTLENUM_TYPE words[MAX_LITTLENUMS];
-  LITTLENUM_TYPE *wordP;
-  char *t;
-
-  switch (type)
-    {
-    case 'f':
-    case 'F':
-    case 's':
-    case 'S':
-      prec = 2;
-      break;
-
-    case 'd':
-    case 'D':
-    case 'r':
-    case 'R':
-      prec = 4;
-      break;
-
-    case 'x':
-    case 'X':
-      prec = 6;
-      break;
-
-    case 'p':
-    case 'P':
-      prec = 6;
-      break;
-
-    default:
-      *sizeP = 0;
-      return _("Bad call to MD_ATOF()");
-    }
-  t = atof_ieee (input_line_pointer, type, words);
-  if (t)
-    input_line_pointer = t;
-
-  *sizeP = prec * sizeof (LITTLENUM_TYPE);
-  for (wordP = words; prec--;)
-    {
-      md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
-      litP += sizeof (LITTLENUM_TYPE);
-    }
-  return 0;
+  return ieee_md_atof (type, litP, sizeP, TRUE);
 }
 \f
+#define OPTION_H_TICK_HEX      (OPTION_MD_BASE)
+
 const char *md_shortopts = "";
 struct option md_longopts[] = {
+  { "h-tick-hex", no_argument,       NULL, OPTION_H_TICK_HEX  },
   {NULL, no_argument, NULL, 0}
 };
 
@@ -2075,7 +2045,16 @@ size_t md_longopts_size = sizeof (md_longopts);
 int
 md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
 {
-  return 0;
+  switch (c)
+    {
+    case OPTION_H_TICK_HEX:
+      enable_h_tick_hex = 1;
+      break;
+
+    default:
+      return 0;
+    }
+  return 1;
 }
 
 void
@@ -2129,6 +2108,13 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
       *buf++ = (val >> 8);
       *buf++ = val;
       break;
+    case 8:
+      /* This can arise when the .quad or .8byte pseudo-ops are used.
+        Returning here (without setting fx_done) will cause the code
+        to attempt to generate a reloc which will then fail with the
+        slightly more helpful error message: "Cannot represent
+        relocation type BFD_RELOC_64".  */
+      return;
     default:
       abort ();
     }
@@ -2138,10 +2124,10 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 }
 
 int
-md_estimate_size_before_relax (register fragS *fragP ATTRIBUTE_UNUSED,
-                              register segT segment_type ATTRIBUTE_UNUSED)
+md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED,
+                              segT segment_type ATTRIBUTE_UNUSED)
 {
-  printf (_("call tomd_estimate_size_before_relax \n"));
+  printf (_("call to md_estimate_size_before_relax \n"));
   abort ();
 }
 
@@ -2170,13 +2156,13 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
          || S_GET_SEGMENT (fixp->fx_addsy) == undefined_section)
        {
          as_bad_where (fixp->fx_file, fixp->fx_line,
-                       "Difference of symbols in different sections is not supported");
+                       _("Difference of symbols in different sections is not supported"));
          return NULL;
        }
     }
 
-  rel = (arelent *) xmalloc (sizeof (arelent));
-  rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+  rel = xmalloc (sizeof (arelent));
+  rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
   rel->addend = fixp->fx_offset;
@@ -2186,7 +2172,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 #define DEBUG 0
 #if DEBUG
   fprintf (stderr, "%s\n", bfd_get_reloc_code_name (r_type));
-  fflush(stderr);
+  fflush (stderr);
 #endif
   rel->howto = bfd_reloc_type_lookup (stdoutput, r_type);
   if (rel->howto == NULL)