This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

[committed 2/3] MIPS/GAS: Use frag symbol/offset directly in fixup creation


There is no need to use a helper expression in the creation of fixups 
made from a frag's symbol and offset, because a simple `symbol+offset' 
expression can be handled directly, with the use of a `fix_new' rather 
than a `fix_new_exp' call.  Rewrite `md_convert_frag' using `fix_new' 
then and remove all the unneeded helper expressions, simplifying code.

	gas/
	* config/tc-mips.c (md_convert_frag): Rewrite `fix_new_exp' 
	calls in terms of `fix_new'.
---
binutils-mips-gas-fix-new.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c	2017-06-30 02:47:01.456214369 +0100
+++ binutils/gas/config/tc-mips.c	2017-06-30 02:47:05.459654372 +0100
@@ -18135,7 +18135,6 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
     {
       char *buf;
       unsigned long insn;
-      expressionS exp;
       fixS *fixp;
 
       buf = fragp->fr_literal + fragp->fr_fix;
@@ -18146,12 +18145,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	  /* We generate a fixup instead of applying it right now
 	     because, if there are linker relaxations, we're going to
 	     need the relocations.  */
-	  exp.X_op = O_symbol;
-	  exp.X_add_symbol = fragp->fr_symbol;
-	  exp.X_add_number = fragp->fr_offset;
-
-	  fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, TRUE,
-			      BFD_RELOC_16_PCREL_S2);
+	  fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+			  fragp->fr_symbol, fragp->fr_offset,
+			  TRUE, BFD_RELOC_16_PCREL_S2);
 	  fixp->fx_file = fragp->fr_file;
 	  fixp->fx_line = fragp->fr_line;
 
@@ -18267,12 +18263,10 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	      /* j or jal.  */
 	      insn = (RELAX_BRANCH_LINK (fragp->fr_subtype)
 		      ? 0x0c000000 : 0x08000000);
-	      exp.X_op = O_symbol;
-	      exp.X_add_symbol = fragp->fr_symbol;
-	      exp.X_add_number = fragp->fr_offset;
 
-	      fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp,
-				  FALSE, BFD_RELOC_MIPS_JMP);
+	      fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+			      fragp->fr_symbol, fragp->fr_offset,
+			      FALSE, BFD_RELOC_MIPS_JMP);
 	      fixp->fx_file = fragp->fr_file;
 	      fixp->fx_line = fragp->fr_line;
 
@@ -18285,12 +18279,10 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	      /* lw/ld $at, <sym>($gp)  R_MIPS_GOT16 */
 	      insn = HAVE_64BIT_ADDRESSES ? 0xdf800000 : 0x8f800000;
 	      insn |= at << OP_SH_RT;
-	      exp.X_op = O_symbol;
-	      exp.X_add_symbol = fragp->fr_symbol;
-	      exp.X_add_number = fragp->fr_offset;
 
-	      fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp,
-				  FALSE, BFD_RELOC_MIPS_GOT16);
+	      fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+			      fragp->fr_symbol, fragp->fr_offset,
+			      FALSE, BFD_RELOC_MIPS_GOT16);
 	      fixp->fx_file = fragp->fr_file;
 	      fixp->fx_line = fragp->fr_line;
 
@@ -18304,8 +18296,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	      insn = HAVE_64BIT_ADDRESSES ? 0x64000000 : 0x24000000;
 	      insn |= at << OP_SH_RS | at << OP_SH_RT;
 
-	      fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp,
-				  FALSE, BFD_RELOC_LO16);
+	      fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+			      fragp->fr_symbol, fragp->fr_offset,
+			      FALSE, BFD_RELOC_LO16);
 	      fixp->fx_file = fragp->fr_file;
 	      fixp->fx_line = fragp->fr_line;
 
@@ -18339,13 +18332,8 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
       int type = RELAX_MICROMIPS_TYPE (fragp->fr_subtype);
       bfd_boolean short_ds;
       unsigned long insn;
-      expressionS exp;
       fixS *fixp;
 
-      exp.X_op = O_symbol;
-      exp.X_add_symbol = fragp->fr_symbol;
-      exp.X_add_number = fragp->fr_offset;
-
       fragp->fr_fix += fragp->fr_var;
 
       /* Handle 16-bit branches that fit or are forced to fit.  */
@@ -18355,11 +18343,13 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	     because if there is linker relaxation, we're going to
 	     need the relocations.  */
 	  if (type == 'D')
-	    fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 2, &exp, TRUE,
-				BFD_RELOC_MICROMIPS_10_PCREL_S1);
+	    fixp = fix_new (fragp, buf - fragp->fr_literal, 2,
+			    fragp->fr_symbol, fragp->fr_offset,
+			    TRUE, BFD_RELOC_MICROMIPS_10_PCREL_S1);
 	  else if (type == 'E')
-	    fixp = fix_new_exp (fragp, buf - fragp->fr_literal,	2, &exp, TRUE,
-				BFD_RELOC_MICROMIPS_7_PCREL_S1);
+	    fixp = fix_new (fragp, buf - fragp->fr_literal, 2,
+			    fragp->fr_symbol, fragp->fr_offset,
+			    TRUE, BFD_RELOC_MICROMIPS_7_PCREL_S1);
 	  else
 	    abort ();
 
@@ -18380,8 +18370,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	  /* We generate a fixup instead of applying it right now,
 	     because if there is linker relaxation, we're going to
 	     need the relocations.  */
-	  fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, TRUE,
-			      BFD_RELOC_MICROMIPS_16_PCREL_S1);
+	  fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+			  fragp->fr_symbol, fragp->fr_offset,
+			  TRUE, BFD_RELOC_MICROMIPS_16_PCREL_S1);
 	  fixp->fx_file = fragp->fr_file;
 	  fixp->fx_line = fragp->fr_line;
 
@@ -18518,8 +18509,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	  /* j/jal/jals <sym>  R_MICROMIPS_26_S1  */
 	  insn = al ? jal : 0xd4000000;
 
-	  fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, FALSE,
-			      BFD_RELOC_MICROMIPS_JMP);
+	  fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+			  fragp->fr_symbol, fragp->fr_offset,
+			  FALSE, BFD_RELOC_MICROMIPS_JMP);
 	  fixp->fx_file = fragp->fr_file;
 	  fixp->fx_line = fragp->fr_line;
 
@@ -18542,8 +18534,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	  insn = HAVE_64BIT_ADDRESSES ? 0xdc1c0000 : 0xfc1c0000;
 	  insn |= at << MICROMIPSOP_SH_RT;
 
-	  fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, FALSE,
-			      BFD_RELOC_MICROMIPS_GOT16);
+	  fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+			  fragp->fr_symbol, fragp->fr_offset,
+			  FALSE, BFD_RELOC_MICROMIPS_GOT16);
 	  fixp->fx_file = fragp->fr_file;
 	  fixp->fx_line = fragp->fr_line;
 
@@ -18553,8 +18546,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	  insn = HAVE_64BIT_ADDRESSES ? 0x5c000000 : 0x30000000;
 	  insn |= at << MICROMIPSOP_SH_RT | at << MICROMIPSOP_SH_RS;
 
-	  fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp, FALSE,
-			      BFD_RELOC_MICROMIPS_LO16);
+	  fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+			  fragp->fr_symbol, fragp->fr_offset,
+			  FALSE, BFD_RELOC_MICROMIPS_LO16);
 	  fixp->fx_file = fragp->fr_file;
 	  fixp->fx_line = fragp->fr_line;
 
@@ -18758,7 +18752,6 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 	  if (need_reloc)
 	    {
 	      bfd_reloc_code_real_type reloc = BFD_RELOC_NONE;
-	      expressionS exp;
 	      fixS *fixp;
 
 	      switch (type)
@@ -18775,13 +18768,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 			      _("unsupported relocation"));
 	      else if (ext)
 		{
-		  exp.X_op = O_symbol;
-		  exp.X_add_symbol = fragp->fr_symbol;
-		  exp.X_add_number = fragp->fr_offset;
-
-		  fixp = fix_new_exp (fragp, buf - fragp->fr_literal, 4, &exp,
-				      TRUE, reloc);
-
+		  fixp = fix_new (fragp, buf - fragp->fr_literal, 4,
+				  fragp->fr_symbol, fragp->fr_offset,
+				  TRUE, reloc);
 		  fixp->fx_file = fragp->fr_file;
 		  fixp->fx_line = fragp->fr_line;
 		}


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