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

Give an error for an offset which is too large


I happened to run across a case which the assembler appeared to accept
but did not actually assemble correctly:
	dla	$4,bar+0x800000000($5)
for an object file format with 32-bit addresses.  The assembler would
try to include the offset in the relocation, but since the offset was
too large the full offset would not be in the object file.

It would be possible to handle this correctly, by loading the constant
into $at and adding it in, but I suspect that this code is incorrect
for an object file format with 32-bit addresses.  This patch gives an
error for this case.

I'm about to commit this patch.

Ian


2004-12-10  Ian Lance Taylor  <ian@wasabisystems.com>

	* config/tc-mips.c (macro) [M_LA_AB]: Give an error for a offset
	which is too large in the case of NO_PIC without 64-bit
	addresses.


Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.277
diff -u -r1.277 tc-mips.c
--- config/tc-mips.c	10 Dec 2004 19:48:18 -0000	1.277
+++ config/tc-mips.c	11 Dec 2004 03:37:08 -0000
@@ -4996,6 +4996,8 @@
 			       tempreg, mips_gp_register, BFD_RELOC_GPREL16);
 		  relax_switch ();
 		}
+	      if (!IS_SEXT_32BIT_NUM (offset_expr.X_add_number))
+		as_bad (_("offset too large"));
 	      macro_build_lui (&offset_expr, tempreg);
 	      macro_build (&offset_expr, ADDRESS_ADDI_INSN, "t,r,j",
 			   tempreg, tempreg, BFD_RELOC_LO16);


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