include/elf/
[deliverable/binutils-gdb.git] / gas / config / tc-m68k.c
index c04eb6ee111622e1c8543efab051ff0485d6f7f3..466a8d3e77bc34d94e0d4729cb239404542848f1 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.
@@ -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) \
@@ -348,7 +348,6 @@ static void s_mri_repeat PARAMS ((int));
 static void s_mri_until PARAMS ((int));
 static void s_mri_while PARAMS ((int));
 static void s_mri_endw PARAMS ((int));
-static void md_apply_fix_2 PARAMS ((fixS *, offsetT));
 static void md_convert_frag_1 PARAMS ((fragS *));
 
 static int current_architecture;
@@ -472,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) },
@@ -1224,7 +1224,7 @@ m68k_ip (instring)
                    default:
                      losing++;
                    }
-                  break;
+                 break;
 
                case 'n':
                  switch (opP->mode)
@@ -1234,7 +1234,7 @@ m68k_ip (instring)
                    default:
                      losing++;
                    }
-                  break;
+                 break;
 
                case 'o':
                  switch (opP->mode)
@@ -1246,7 +1246,7 @@ m68k_ip (instring)
                    default:
                      losing++;
                    }
-                  break;
+                 break;
 
                case 'p':
                  switch (opP->mode)
@@ -1259,12 +1259,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)
@@ -1276,13 +1276,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)
@@ -1295,7 +1295,7 @@ m68k_ip (instring)
                      break;
                    case DISP:
                      if (opP->reg == PC || opP->reg == ZPC)
-                        losing++;
+                       losing++;
                      break;
                    default:
                      losing++;
@@ -2275,13 +2275,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
@@ -2573,14 +2573,14 @@ m68k_ip (instring)
              if (adds (&opP->disp) == 0)
                {
                  if (the_ins.opcode[0] == 0x6000)      /* jbra */
-                   the_ins.opcode[0] = 0x4EF1;
+                   the_ins.opcode[0] = 0x4EF9;
                  else if (the_ins.opcode[0] == 0x6100) /* jbsr */
-                   the_ins.opcode[0] = 0x4EB1;
+                   the_ins.opcode[0] = 0x4EB9;
                  else                                  /* jCC */
                    {
                      the_ins.opcode[0] ^= 0x0100;
                      the_ins.opcode[0] |= 0x0006;
-                     addword (0x4EF1);
+                     addword (0x4EF9);
                    }
                  add_fix ('l', &opP->disp, 0, 0);
                  addword (0);
@@ -3779,11 +3779,10 @@ md_begin ()
      my lord ghod hath spoken, so we do it this way.  Excuse the ugly var
      names.  */
 
-  register const struct m68k_opcode *ins;
-  register struct m68k_incant *hack, *slak;
-  register const char *retval = 0;     /* empty string, or error msg text */
-  register int i;
-  register char c;
+  const struct m68k_opcode *ins;
+  struct m68k_incant *hack, *slak;
+  const char *retval = 0;      /* empty string, or error msg text */
+  int i;
 
   if (flag_mri)
     {
@@ -4223,11 +4222,13 @@ md_number_to_chars (buf, val, n)
   number_to_chars_bigendian (buf, val, n);
 }
 
-static void
-md_apply_fix_2 (fixP, val)
+void
+md_apply_fix3 (fixP, valP, seg)
      fixS *fixP;
-     offsetT val;
+     valueT *valP;
+     segT seg ATTRIBUTE_UNUSED;
 {
+  offsetT val = *valP;
   addressT upper_limit;
   offsetT lower_limit;
 
@@ -4239,6 +4240,9 @@ md_apply_fix_2 (fixP, val)
 
   val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
 
+  if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
+    fixP->fx_done = 1;
+
 #ifdef OBJ_ELF
   if (fixP->fx_addsy)
     {
@@ -4261,8 +4265,8 @@ md_apply_fix_2 (fixP, val)
 
   switch (fixP->fx_size)
     {
-      /* The cast to offsetT below are necessary to make code correct for
-        machines where ints are smaller than offsetT */
+      /* The cast to offsetT below are necessary to make code
+        correct for machines where ints are smaller than offsetT.  */
     case 1:
       *buf++ = val;
       upper_limit = 0x7f;
@@ -4322,24 +4326,6 @@ md_apply_fix_2 (fixP, val)
     as_bad_where (fixP->fx_file, fixP->fx_line, _("invalid byte branch offset"));
 }
 
-#ifdef BFD_ASSEMBLER
-int
-md_apply_fix (fixP, valp)
-     fixS *fixP;
-     valueT *valp;
-{
-  md_apply_fix_2 (fixP, (addressT) *valp);
-  return 1;
-}
-#else
-void md_apply_fix (fixP, val)
-     fixS *fixP;
-     long val;
-{
-  md_apply_fix_2 (fixP, (addressT) val);
-}
-#endif
-
 /* *fragP has been relaxed to its final size, and now needs to have
    the bytes inside it modified to conform to the new size  There is UGLY
    MAGIC here. ..
@@ -4689,7 +4675,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)
@@ -5336,7 +5322,7 @@ opt_list_symbols (arg, on)
   if (on)
     listing |= LISTING_SYMBOLS;
   else
-    listing &=LISTING_SYMBOLS;
+    listing &= ~LISTING_SYMBOLS;
 }
 
 /* Handle the MRI REG pseudo-op.  */
@@ -5721,14 +5707,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;
@@ -5881,7 +5867,9 @@ build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
          temp = leftstop;
          leftstop = rightstop;
          rightstop = temp;
-       } else {
+       }
+      else
+       {
          cc = swap_mri_condition (cc);
        }
     }
@@ -6639,12 +6627,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')
@@ -6792,7 +6780,7 @@ md_parse_option (c, arg)
 
     case 'A':
       if (*arg == 'm')
-       arg++;
+       arg++;
       /* intentional fall-through */
     case 'm':
 
@@ -6930,16 +6918,40 @@ void
 md_show_usage (stream)
      FILE *stream;
 {
+  const char *default_cpu = TARGET_CPU;
+  int default_arch, i;
+
+  /* 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\
@@ -7127,10 +7139,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.028986 seconds and 4 git commands to generate.