This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: accept 64-bit constant addresses in mips n32
On Apr 8, 2003, Thiemo Seufer <ica2_ts at csv dot ica dot uni-stuttgart dot de> wrote:
> After thinking a bit about this, I'm still not sure if the 'fix' is ok.
> n32 normally guarantees properly sign-extended 32-bit addresses, and
> people may rely on it for pointer arithmethics (in broken code).
I believe the point is that, if you really know what you're doing to
the point of inserting a 64-bit address explicitly in your n32
assembly code, there's no reason for the assembler to not do it other
than just being picky.
> IMHO the assembler should complain about attempted 64-bit addressing
> in order to catch compiler bugs.
> For what actual usage scenario was this patch developed?
It's a trick from mips64 linux (the kernel) folks: they build the
kernel with -mabi=64, but assemble it as -n32 (-Wa,-n32), such that,
for some reasons I haven't really investigated, the resulting kernel
binary is far smaller and more efficient than assembling everything as
n64, linking as n64, then converting to an ELF32 format (as required
by a number of mips boot loaders) with objcopy.
That said, Chris came up with a follow-up patch, that addresses some
of your concerns and fixes a merge bug I unintentionally introduced,
but Eric still hasn't reviewed it.
Index: gas/ChangeLog
from Chris Demetriou <cgd at broadcom dot com>
* config/tc-mips.c (macro): Put back `+ 0x8000' in test for 64-bit
constant address that Alexandre took out by accident. Reject
64-bit addresses that are not sign extensions of 32 bits only if
we don't support 64-bit address constants.
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.200
diff -u -p -r1.200 tc-mips.c
--- gas/config/tc-mips.c 6 Apr 2003 03:16:20 -0000 1.200
+++ gas/config/tc-mips.c 8 Apr 2003 07:03:48 -0000
@@ -5849,7 +5849,7 @@ macro (ip)
*/
if ((offset_expr.X_op != O_constant && HAVE_64BIT_ADDRESSES)
|| (offset_expr.X_op == O_constant
- && !IS_SEXT_32BIT_NUM (offset_expr.X_add_number)
+ && !IS_SEXT_32BIT_NUM (offset_expr.X_add_number + 0x8000)
&& HAVE_64BIT_ADDRESS_CONSTANTS))
{
p = NULL;
@@ -5898,6 +5898,7 @@ macro (ip)
return;
}
else if (offset_expr.X_op == O_constant
+ && !HAVE_64BIT_ADDRESS_CONSTANTS
&& !IS_SEXT_32BIT_NUM (offset_expr.X_add_number))
as_bad (_("load/store address overflow (max 32 bits)"));
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva at {redhat dot com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva at {lsd dot ic dot unicamp dot br, gnu.org}
Free Software Evangelist Professional serial bug killer