* config/tc-sh.c (md_assemble): For branches, check & update
[deliverable/binutils-gdb.git] / gas / config / tc-m68k.c
index 20c9c107b58ec6d6ede3d093a21f4832e98d43c6..d913dc6c528053bc28226b62f3bffeb07eea6d8b 100644 (file)
@@ -1,6 +1,6 @@
 /* tc-m68k.c -- Assemble for the m68k family
    Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -55,12 +55,12 @@ const char line_comment_chars[] = "#*";
 const char line_separator_chars[] = ";";
 
 /* Chars that can be used to separate mant from exp in floating point nums */
-CONST char EXP_CHARS[] = "eE";
+const char EXP_CHARS[] = "eE";
 
 /* Chars that mean this number is a floating point constant, as
    in "0f12.456" or "0d1.2345e12".  */
 
-CONST char FLT_CHARS[] = "rRsSfFdDxXeEpP";
+const char FLT_CHARS[] = "rRsSfFdDxXeEpP";
 
 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
    changed in read.c .  Ideally it shouldn't have to know about it at all,
@@ -258,12 +258,12 @@ insop (w, opcode)
 {
   int z;
   for (z = the_ins.numo; z > opcode->m_codenum; --z)
-    the_ins.opcode[z]=the_ins.opcode[z-1];
-  for (z = 0;z < the_ins.nrel; z++)
-    the_ins.reloc[z].n+=2;
+    the_ins.opcode[z] = the_ins.opcode[z - 1];
+  for (z = 0; z < the_ins.nrel; z++)
+    the_ins.reloc[z].n += 2;
   for (z = 0; z < the_ins.nfrag; z++)
     the_ins.fragb[z].fragoff++;
-  the_ins.opcode[opcode->m_codenum]=w;
+  the_ins.opcode[opcode->m_codenum] = w;
   the_ins.numo++;
 }
 
@@ -306,10 +306,10 @@ add_frag (add, off, type)
      offsetT off;
      int type;
 {
-  the_ins.fragb[the_ins.nfrag].fragoff=the_ins.numo;
-  the_ins.fragb[the_ins.nfrag].fadd=add;
-  the_ins.fragb[the_ins.nfrag].foff=off;
-  the_ins.fragb[the_ins.nfrag++].fragty=type;
+  the_ins.fragb[the_ins.nfrag].fragoff = the_ins.numo;
+  the_ins.fragb[the_ins.nfrag].fadd = add;
+  the_ins.fragb[the_ins.nfrag].foff = off;
+  the_ins.fragb[the_ins.nfrag++].fragty = type;
 }
 
 #define isvar(ex) \
@@ -471,7 +471,8 @@ static const int n_archs = sizeof (archs) / sizeof (archs[0]);
    How far Backward this mode will reach:
    How many bytes this mode will add to the size of the frag
    Which mode to go to if the offset won't fit in this one
-   */
+
+   Please check tc-m68k.h:md_prepare_relax_scan if changing this table.  */
 relax_typeS md_relax_table[] =
 {
   {   127,   -128,  0, TAB (BRANCHBWL, SHORT) },
@@ -553,12 +554,6 @@ const pseudo_typeS md_pseudo_table[] =
   {"extend", float_cons, 'x'},
   {"ldouble", float_cons, 'x'},
 
-#ifdef OBJ_ELF
-  /* Dwarf2 support for Gcc.  */
-  {"file", dwarf2_directive_file, 0},
-  {"loc", dwarf2_directive_loc, 0},
-#endif
-
   /* The following pseudo-ops are supported for MRI compatibility.  */
   {"chip", s_chip, 0},
   {"comline", s_space, 1},
@@ -610,7 +605,7 @@ const pseudo_typeS md_pseudo_table[] =
 extern void obj_coff_section PARAMS ((int));
 #endif
 
-CONST pseudo_typeS mote_pseudo_table[] =
+const pseudo_typeS mote_pseudo_table[] =
 {
 
   {"dcl", cons, 4},
@@ -843,10 +838,6 @@ int
 tc_m68k_fix_adjustable (fixP)
      fixS *fixP;
 {
-  /* Prevent all adjustments to global symbols.  */
-  if (! relaxable_symbol (fixP->fx_addsy))
-    return 0;
-
   /* adjust_reloc_syms doesn't know about the GOT */
   switch (fixP->fx_r_type)
     {
@@ -885,7 +876,7 @@ tc_m68k_fix_adjustable (fixP)
 
 arelent *
 tc_gen_reloc (section, fixp)
-     asection *section;
+     asection *section ATTRIBUTE_UNUSED;
      fixS *fixp;
 {
   arelent *reloc;
@@ -1223,7 +1214,7 @@ m68k_ip (instring)
                    default:
                      losing++;
                    }
-                  break;
+                 break;
 
                case 'n':
                  switch (opP->mode)
@@ -1233,7 +1224,7 @@ m68k_ip (instring)
                    default:
                      losing++;
                    }
-                  break;
+                 break;
 
                case 'o':
                  switch (opP->mode)
@@ -1245,7 +1236,7 @@ m68k_ip (instring)
                    default:
                      losing++;
                    }
-                  break;
+                 break;
 
                case 'p':
                  switch (opP->mode)
@@ -1258,12 +1249,12 @@ m68k_ip (instring)
                      break;
                    case DISP:
                      if (opP->reg == PC || opP->reg == ZPC)
-                        losing++;
+                       losing++;
                      break;
                    default:
                      losing++;
                    }
-                  break;
+                 break;
 
                case 'q':
                  switch (opP->mode)
@@ -1275,13 +1266,13 @@ m68k_ip (instring)
                      break;
                    case DISP:
                      if (opP->reg == PC || opP->reg == ZPC)
-                        losing++;
+                       losing++;
                      break;
                    default:
                      losing++;
                      break;
                    }
-                  break;
+                 break;
 
                case 'v':
                  switch (opP->mode)
@@ -1294,7 +1285,7 @@ m68k_ip (instring)
                      break;
                    case DISP:
                      if (opP->reg == PC || opP->reg == ZPC)
-                        losing++;
+                       losing++;
                      break;
                    default:
                      losing++;
@@ -2274,13 +2265,13 @@ m68k_ip (instring)
                              the frag obstack to make all the bytes
                              contiguous.  */
                          frag_grow (14);
-                         nextword += baseo & 0xff;
-                         addword (nextword);
-                         add_frag (adds (&opP->disp), offs (&opP->disp),
-                                   TAB (PCINDEX, SZ_UNDEF));
+                         nextword += baseo & 0xff;
+                         addword (nextword);
+                         add_frag (adds (&opP->disp), offs (&opP->disp),
+                                   TAB (PCINDEX, SZ_UNDEF));
 
                          break;
-                       }
+                       }
                    }
                }
              else
@@ -3953,6 +3944,11 @@ select_control_regs ()
   /* Note which set of "movec" control registers is available.  */
   switch (cpu_of_arch (current_architecture))
     {
+    case 0:
+      as_warn (_("architecture not yet selected: defaulting to 68020"));
+      control_regs = m68020_control_regs;
+      break;
+      
     case m68000:
       control_regs = m68000_control_regs;
       break;
@@ -4674,7 +4670,7 @@ md_estimate_size_before_relax (fragP, segment)
            {
              fragS *l;
 
-             for (l = fragP->fr_next; l != sym_frag; l = l->fr_next)
+             for (l = fragP->fr_next; l && l != sym_frag; l = l->fr_next)
                if (l->fr_fix != 0)
                  break;
              if (l == sym_frag)
@@ -4729,7 +4725,7 @@ tc_aout_fix_to_chars (where, fixP, segment_address_in_file)
    * Out: GNU LD relocation length code: 0, 1, or 2.
    */
 
-  static CONST unsigned char nbytes_r_length[] = {42, 0, 1, 42, 2};
+  static const unsigned char nbytes_r_length[] = {42, 0, 1, 42, 2};
   long r_symbolnum;
 
   know (fixP->fx_addsy != NULL);
@@ -4753,8 +4749,8 @@ tc_aout_fix_to_chars (where, fixP, segment_address_in_file)
 #endif /* OBJ_AOUT or OBJ_BOUT */
 
 #ifndef WORKING_DOT_WORD
-CONST int md_short_jump_size = 4;
-CONST int md_long_jump_size = 6;
+const int md_short_jump_size = 4;
+const int md_long_jump_size = 6;
 
 void
 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
@@ -5321,7 +5317,7 @@ opt_list_symbols (arg, on)
   if (on)
     listing |= LISTING_SYMBOLS;
   else
-    listing &=LISTING_SYMBOLS;
+    listing &= ~LISTING_SYMBOLS;
 }
 
 /* Handle the MRI REG pseudo-op.  */
@@ -5706,14 +5702,14 @@ parse_mri_control_operand (pcc, leftstart, leftstop, rightstart, rightstop)
       /* We must make sure we don't misinterpret AND/OR at the end of labels!
          if d0 <eq> #FOOAND and d1 <ne> #BAROR then
                         ^^^                 ^^ */
-      if (    (    s == input_line_pointer
-                || *(s-1) == ' '
-                || *(s-1) == '\t')
-           && (    (    strncasecmp (s, "AND", 3) == 0
-                     && (s[3] == '.' || ! is_part_of_name (s[3])))
-                || (    strncasecmp (s, "OR", 2) == 0
-                     && (s[2] == '.' || ! is_part_of_name (s[2])))))
-             break;
+      if ((s == input_line_pointer
+          || *(s-1) == ' '
+          || *(s-1) == '\t')
+         && ((strncasecmp (s, "AND", 3) == 0
+              && (s[3] == '.' || ! is_part_of_name (s[3])))
+             || (strncasecmp (s, "OR", 2) == 0
+                 && (s[2] == '.' || ! is_part_of_name (s[2])))))
+       break;
     }
 
   *rightstart = input_line_pointer;
@@ -5866,7 +5862,9 @@ build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
          temp = leftstop;
          leftstop = rightstop;
          rightstop = temp;
-       } else {
+       }
+      else
+       {
          cc = swap_mri_condition (cc);
        }
     }
@@ -6624,12 +6622,12 @@ s_mri_while (qual)
      This is important when assembling:
        while d0 <ne> 12(a0,d0*2) do
        while d0 <ne> #CONST*20   do */
-  while ( ! (    is_end_of_line[(unsigned char) *s]
-              || (     flag_mri
-                   && *s == '*'
-                   && (    s == input_line_pointer
-                        || *(s-1) == ' '
-                        || *(s-1) == '\t'))))
+  while (! (is_end_of_line[(unsigned char) *s]
+           || (flag_mri
+               && *s == '*'
+               && (s == input_line_pointer
+                   || *(s-1) == ' '
+                   || *(s-1) == '\t'))))
     s++;
   --s;
   while (*s == ' ' || *s == '\t')
@@ -6726,9 +6724,9 @@ s_mri_endw (ignore)
  */
 
 #ifdef OBJ_ELF
-CONST char *md_shortopts = "lSA:m:kQ:V";
+const char *md_shortopts = "lSA:m:kQ:V";
 #else
-CONST char *md_shortopts = "lSA:m:k";
+const char *md_shortopts = "lSA:m:k";
 #endif
 
 struct option md_longopts[] = {
@@ -6777,7 +6775,7 @@ md_parse_option (c, arg)
 
     case 'A':
       if (*arg == 'm')
-       arg++;
+       arg++;
       /* intentional fall-through */
     case 'm':
 
@@ -6915,16 +6913,41 @@ void
 md_show_usage (stream)
      FILE *stream;
 {
+  const char *default_cpu = TARGET_CPU;
+  int i;
+  unsigned int default_arch;
+
+  /* Get the canonical name for the default target CPU.  */
+  if (*default_cpu == 'm')
+    default_cpu++;
+  for (i = 0; i < n_archs; i++)
+    {
+      if (strcasecmp (default_cpu, archs[i].name) == 0)
+       {
+         default_arch = archs[i].arch;
+         for (i = 0; i < n_archs; i++)
+           {
+             if (archs[i].arch == default_arch
+                 && !archs[i].alias)
+               {
+                 default_cpu = archs[i].name;
+                 break;
+               }
+           }
+       }
+    }
+
   fprintf (stream, _("\
 680X0 options:\n\
 -l                     use 1 word for refs to undefined symbols [default 2]\n\
 -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040 | -m68060 |\n\
 -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -m68360 | -mcpu32 |\n\
 -m5200  | -m5202  | -m5204  | -m5206  | -m5206e | -m5307  | -m5407\n\
-                       specify variant of 680X0 architecture [default 68020]\n\
+                       specify variant of 680X0 architecture [default %s]\n\
 -m68881 | -m68882 | -mno-68881 | -mno-68882\n\
                        target has/lacks floating-point coprocessor\n\
-                       [default yes for 68020, 68030, and cpu32]\n"));
+                       [default yes for 68020, 68030, and cpu32]\n"),
+          default_cpu);
   fprintf (stream, _("\
 -m68851 | -mno-68851\n\
                        target has/lacks memory-management unit coprocessor\n\
@@ -7112,10 +7135,14 @@ tc_coff_sizemachdep (frag)
 #endif
 #endif
 #ifdef OBJ_ELF
-void m68k_elf_final_processing()
+void
+m68k_elf_final_processing ()
 {
-   /* Set file-specific flags if this is a cpu32 processor */
-   if (cpu_of_arch (current_architecture) & cpu32)
-     elf_elfheader (stdoutput)->e_flags |= EF_CPU32;
+  /* Set file-specific flags if this is a cpu32 processor */
+  if (cpu_of_arch (current_architecture) & cpu32)
+    elf_elfheader (stdoutput)->e_flags |= EF_CPU32;
+  else if ((cpu_of_arch (current_architecture) & m68000up)
+          && !(cpu_of_arch (current_architecture) & m68020up))
+    elf_elfheader (stdoutput)->e_flags |= EF_M68000;
 }
 #endif
This page took 0.030719 seconds and 4 git commands to generate.