This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fix an ancient x86 "I cannot see how to"


Hi Ian,
  This patch fixes any old kludge in the x86 assembler by passing a reloc
code in fr_var of a rs_machine_dependent frag.  The generic code doesn't
seem to use fr_var in these frags.  Can you, or anyone else, see a reason
why I shouldn't do this?

Regards, Alan Modra
-- 
Linuxcare.  Support for the Revolution.


Index: config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.50
diff -u -p -r1.50 tc-i386.c
--- tc-i386.c	2000/05/22 11:38:43	1.50
+++ tc-i386.c	2000/05/22 13:43:03
@@ -2264,10 +2264,10 @@ md_assemble (line)
 	if (prefix)
 	  *p++ = DATA_PREFIX_OPCODE;
 	*p = i.tm.base_opcode;
-	/* 1 possible extra opcode + displacement go in fr_var.  */
+	/* 1 possible extra opcode + displacement go in var part.  */
 	frag_var (rs_machine_dependent,
 		  1 + size,
-		  1,
+		  i.disp_reloc[0],
 		  ((unsigned char) *p == JUMP_PC_RELATIVE
 		   ? ENCODE_RELAX_STATE (UNCOND_JUMP, SMALL) | code16
 		   : ENCODE_RELAX_STATE (COND_JUMP, SMALL) | code16),
@@ -3758,11 +3758,6 @@ md_estimate_size_before_relax (fragP, se
      register fragS *fragP;
      register segT segment;
 {
-  register unsigned char *opcode;
-  register int old_fr_fix;
-
-  old_fr_fix = fragP->fr_fix;
-  opcode = (unsigned char *) fragP->fr_opcode;
   /* We've already got fragP->fr_subtype right;  all we have to do is
      check for un-relaxable symbols.  On an ELF system, we can't relax
      an externally visible symbol, because it may be overridden by a
@@ -3782,20 +3777,19 @@ md_estimate_size_before_relax (fragP, se
 #else
       int reloc_type;
 #endif
+      unsigned char *opcode;
+      int old_fr_fix;
 
-      if (GOT_symbol /* Not quite right - we should switch on presence of
-			@PLT, but I cannot see how to get to that from
-			here.  We should have done this in md_assemble to
-			really get it right all of the time, but I think it
-			does not matter that much, as this will be right
-			most of the time. ERY  */
-	  && S_GET_SEGMENT(fragP->fr_symbol) == undefined_section)
-	reloc_type = BFD_RELOC_386_PLT32;
+      if (fragP->fr_var != NO_RELOC)
+	reloc_type = fragP->fr_var;
       else if (size == 2)
 	reloc_type = BFD_RELOC_16_PCREL;
       else
 	reloc_type = BFD_RELOC_32_PCREL;
 
+      old_fr_fix = fragP->fr_fix;
+      opcode = (unsigned char *) fragP->fr_opcode;
+
       switch (opcode[0])
 	{
 	case JUMP_PC_RELATIVE:	/* make jmp (0xeb) a dword displacement jump */
@@ -3820,9 +3814,10 @@ md_estimate_size_before_relax (fragP, se
 	  break;
 	}
       frag_wane (fragP);
+      return fragP->fr_fix - old_fr_fix;
     }
-  return (fragP->fr_var + fragP->fr_fix - old_fr_fix);
-}				/* md_estimate_size_before_relax() */
+  return 1; /* Guess a short jump.  */
+}
 
 /*
  *			md_convert_frag();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]