fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT); fragP->fr_var += 2;
fragS *l;  for (l = fragP->fr_next; l != fragP->fr_symbol->sy_frag; l = l->fr_next) if (l->fr_fix + l->fr_var != 0) break; if (l == fragP->fr_symbol->sy_frag) { fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT); fragP->fr_var += 2; }
md_estimate_size_before_relax (fragP, segment)     register fragS *fragP;     segT segment;{  int old_fix;  register char *buffer_address = fragP->fr_fix + fragP->fr_literal;  old_fix = fragP->fr_fix;  /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */  switch (fragP->fr_subtype)    {    case TAB (ABRANCH, SZ_UNDEF):      {	if ((fragP->fr_symbol != NULL)	/* Not absolute */	    && S_GET_SEGMENT (fragP->fr_symbol) == segment)	  {	    fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), BYTE);	    break;	  }	else if ((fragP->fr_symbol == 0) || (cpu_of_arch (current_architecture) < m68020))	  {	    /* On 68000, or for absolute value, switch to abs long */	    /* FIXME, we should check abs val, pick short or long */	    if (fragP->fr_opcode[0] == 0x61)	      {		fragP->fr_opcode[0] = 0x4E;		fragP->fr_opcode[1] = (char) 0xB9; /* JBSR with ABSL LONG offset */		fix_new (fragP, fragP->fr_fix, 4,			 fragP->fr_symbol, fragP->fr_offset, 0, NO_RELOC);		fragP->fr_fix += 4;		frag_wane (fragP);	      }	    else if (fragP->fr_opcode[0] == 0x60)	      {		fragP->fr_opcode[0] = 0x4E;		fragP->fr_opcode[1] = (char) 0xF9; /* JMP  with ABSL LONG offset */		fix_new (fragP, fragP->fr_fix, 4,			 fragP->fr_symbol, fragP->fr_offset, 0, NO_RELOC);		fragP->fr_fix += 4;		frag_wane (fragP);	      }	    else	      {		as_warn ("Long branch offset to extern symbol not supported.");	      }	  }	else	  {			/* Symbol is still undefined.  Make it simple */	    fix_new (fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol,		     fragP->fr_offset, 1, NO_RELOC);	    fragP->fr_fix += 4;	    fragP->fr_opcode[1] = (char) 0xff;	    frag_wane (fragP);	    break;	  }	break;      }				/* case TAB(ABRANCH,SZ_UNDEF) */    case TAB (FBRANCH, SZ_UNDEF):      {	if (S_GET_SEGMENT (fragP->fr_symbol) == segment || flag_short_refs)	  {	    fragP->fr_subtype = TAB (FBRANCH, SHORT);	    fragP->fr_var += 2;	  }	else	  {	    fix_new (fragP, (int) fragP->fr_fix, 4, fragP->fr_symbol,		     fragP->fr_offset, 1, NO_RELOC);	    fragP->fr_fix += 4;	    fragP->fr_opcode[1] |= 0x40; /* Turn on LONG bit */	    frag_wane (fragP);	  }	break;      }				/* TAB(FBRANCH,SZ_UNDEF) */    case TAB (PCREL, SZ_UNDEF):      {	if (S_GET_SEGMENT (fragP->fr_symbol) == segment	    || flag_short_refs	    || cpu_of_arch (current_architecture) < m68020)	  {	    fragP->fr_subtype = TAB (PCREL, SHORT);	    fragP->fr_var += 2;	  }	else	  {	    fragP->fr_subtype = TAB (PCREL, LONG);	    fragP->fr_var += 4;	  }	break;      }				/* TAB(PCREL,SZ_UNDEF) */    case TAB (BCC68000, SZ_UNDEF):      {	if ((fragP->fr_symbol != NULL)	    && S_GET_SEGMENT (fragP->fr_symbol) == segment)	  {	    fragP->fr_subtype = TAB (BCC68000, BYTE);	    break;	  }	/* only Bcc 68000 instructions can come here */	/* change bcc into b!cc/jmp absl long */	fragP->fr_opcode[0] ^= 0x01;	/* invert bcc */	if (flag_short_refs)	  {	    fragP->fr_opcode[1] = 0x04;	/* branch offset = 6 */	    /* JF: these were fr_opcode[2,3] */	    buffer_address[0] = 0x4e;	/* put in jmp long (0x4ef9) */	    buffer_address[1] = (char) 0xf8;	    fragP->fr_fix += 2;	/* account for jmp instruction */	    fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol,		     fragP->fr_offset, 0, NO_RELOC);	    fragP->fr_fix += 2;	  }	else	  {	    fragP->fr_opcode[1] = 0x06;	/* branch offset = 6 */	    /* JF: these were fr_opcode[2,3] */	    buffer_address[0] = 0x4e;	/* put in jmp long (0x4ef9) */	    buffer_address[1] = (char) 0xf9;	    fragP->fr_fix += 2;	/* account for jmp instruction */	    fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,		     fragP->fr_offset, 0, NO_RELOC);	    fragP->fr_fix += 4;	  }	frag_wane (fragP);	break;      }				/* case TAB(BCC68000,SZ_UNDEF) */    case TAB (DBCC, SZ_UNDEF):      {	if (fragP->fr_symbol != NULL && S_GET_SEGMENT (fragP->fr_symbol) == segment)	  {	    fragP->fr_subtype = TAB (DBCC, SHORT);	    fragP->fr_var += 2;	    break;	  }	/* only DBcc 68000 instructions can come here */	/* change dbcc into dbcc/jmp absl long */	/* JF: these used to be fr_opcode[2-4], which is wrong. */	buffer_address[0] = 0x00;	/* branch offset = 4 */	buffer_address[1] = 0x04;	buffer_address[2] = 0x60;	/* put in bra pc + ... */	if (flag_short_refs)	  {	    /* JF: these were fr_opcode[5-7] */	    buffer_address[3] = 0x04;	/* plus 4 */	    buffer_address[4] = 0x4e;	/* Put in Jump Word */	    buffer_address[5] = (char) 0xf8;	    fragP->fr_fix += 6;	/* account for bra/jmp instruction */	    fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol,		     fragP->fr_offset, 0, NO_RELOC);	    fragP->fr_fix += 2;	  }	else	  {	    /* JF: these were fr_opcode[5-7] */	    buffer_address[3] = 0x06;	/* Plus 6 */	    buffer_address[4] = 0x4e;	/* put in jmp long (0x4ef9) */	    buffer_address[5] = (char) 0xf9;	    fragP->fr_fix += 6;	/* account for bra/jmp instruction */	    fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,		     fragP->fr_offset, 0, NO_RELOC);	    fragP->fr_fix += 4;	  }	frag_wane (fragP);	break;      }				/* case TAB(DBCC,SZ_UNDEF) */    case TAB (PCLEA, SZ_UNDEF):      {	if ((S_GET_SEGMENT (fragP->fr_symbol)) == segment	    || flag_short_refs	    || cpu_of_arch (current_architecture) < m68020)	  {	    fragP->fr_subtype = TAB (PCLEA, SHORT);	    fragP->fr_var += 2;	  }	else	  {	    fragP->fr_subtype = TAB (PCLEA, LONG);	    fragP->fr_var += 6;	  }	break;      }				/* TAB(PCLEA,SZ_UNDEF) */    case TAB (PCINDEX, SZ_UNDEF):      if (S_GET_SEGMENT (fragP->fr_symbol) == segment	  || cpu_of_arch (current_architecture) < m68020)	{	  fragP->fr_subtype = TAB (PCINDEX, BYTE);	}      else	{	  fragP->fr_subtype = TAB (PCINDEX, LONG);	  fragP->fr_var += 4;	}      break;    default:      break;    }  /* now that SZ_UNDEF are taken care of, check others */  switch (fragP->fr_subtype)    {    case TAB (BCC68000, BYTE):    case TAB (ABRANCH, BYTE):      /* We can't do a short jump to the next instruction,	   so we force word mode.  */      if (fragP->fr_symbol && S_GET_VALUE (fragP->fr_symbol) == 0 &&	  fragP->fr_symbol->sy_frag == fragP->fr_next)	{	  fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);	  fragP->fr_var += 2;	}      break;    default:      break;    }  return fragP->fr_var + fragP->fr_fix - old_fix;}