public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Give an error for an offset which is too large
@ 2004-12-11  3:41 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2004-12-11  3:41 UTC (permalink / raw)
  To: binutils

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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-12-11  3:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-11  3:41 Give an error for an offset which is too large Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).