bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: M68k gas bug


From: Nick Clifton
Subject: Re: M68k gas bug
Date: 05 Jul 2001 17:49:49 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Hi Pauli,

> I've located a problem in the branch relaxation code for the m68k
> target.  A jbra instruction which jumps to the next location through
> an intervening ".align 2" directive will generate an eight bit branch
> (not a sixteen bit one) which causes fatal errors later on.

I think that the patch below will fix this problem for you.  Please
could you try it out and let me know if it works.

The problem, as I understand it, is that the .align directive is
introducing a new frag between the JBRA instruction and the label.
This frag is empty, but, it has its fr_offset field set to 1 to
indicate a 2 byte alignment requirement.  The code in
md_estimate_size_before_relax misinterprets this frag as containing
real code, so it decides that there is no need to change the BRAS
instruction into the BRAW instruction.  The patch catches this case
and removes it from consideration.

Cheers
        Nick

2001-07-05  Nick Clifton  <address@hidden>

        * config/tc-m68k.c (md_estimate_size_before_relax): Ignore
        empty alignment frags that only align for two bytes when
        deciding if a short jump needs to be converted into a word
        jump.

Index: gas/config/tc-m68k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.c,v
retrieving revision 1.26
diff -w -p -r1.26 tc-m68k.c
*** tc-m68k.c   2001/06/21 06:12:11     1.26
--- tc-m68k.c   2001/07/05 16:48:00
*************** md_estimate_size_before_relax (fragP, se
*** 4694,4706 ****
          fragS *l;
  
          stop = symbol_get_frag (fragP->fr_symbol);
          for (l = fragP->fr_next; l != stop; l = l->fr_next)
            if (l->fr_fix + l->fr_var != 0)
              break;
          if (l == stop)
-           {
              fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
-           }
        }
        break;
      default:
--- 4694,4718 ----
          fragS *l;
  
          stop = symbol_get_frag (fragP->fr_symbol);
+ 
          for (l = fragP->fr_next; l != stop; l = l->fr_next)
+           {
+             /* Catch empty alignment frags whoes fr_offset field
+                is an alignment requirement of 2 bytes.  The check
+                below will misinterpret this as evidence that real
+                code exists between the symbol and the instruction
+                and so will not convert the short jump into a word
+                jump.  */
+             if (l->fr_fix == 0
+                 && l->fr_var == 1
+                 && (l->fr_type == rs_align || l->fr_type == rs_align_code))
+               continue;
+     
              if (l->fr_fix + l->fr_var != 0)
                break;
+           }
          if (l == stop)
            fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
        }
        break;
      default:






reply via email to

[Prev in Thread] Current Thread [Next in Thread]