This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
MIPS HAVE_32BIT_ADDRESSES bogon ?
- To: binutils at sources dot redhat dot com
- Subject: MIPS HAVE_32BIT_ADDRESSES bogon ?
- From: cgd at broadcom dot com
- Date: 26 Oct 2001 16:49:11 -0700
So, I note the code:
/* We can only have 64bit addresses if the object file format
supports it. */
#define HAVE_32BIT_ADDRESSES \
(HAVE_32BIT_GPRS \
|| bfd_arch_bits_per_address (stdoutput) == 32 \
|| ! HAVE_64BIT_OBJECTS)
#define HAVE_64BIT_ADDRESSES (! HAVE_32BIT_ADDRESSES)
I'm not convinced that this is correct. I'm most definitely convinced
that it's _incorrect_ for "embedded PIC" code. 8-)
Embedded-PIC code performs operations like:
( to access data off GP )
macro_build ((char *) NULL, counter, ep,
HAVE_32BIT_ADDRESSES ? "addiu" : "daddiu",
"t,r,j", reg, GP, (int) BFD_RELOC_MIPS_GPREL);
(load difference of addresses + base reg)
macro_build ((char *) NULL, &icnt, &offset_expr, "lui", "t,u",
tempreg, (int) BFD_RELOC_PCREL_HI16_S);
macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
HAVE_32BIT_ADDRESSES ? "addu" : "daddu",
"d,v,t", tempreg, tempreg, breg);
macro_build ((char *)NULL, &icnt, &offset_expr,
HAVE_32BIT_ADDRESSES ? "addiu" : "daddiu",
"t,r,j", treg, tempreg, (int) BFD_RELOC_PCREL_LO16);
(OK, the latter isn't quite in the sources yet I don't think, but
similar examples are. 8-)
Note that if you compile with -membedded-pic -mlong64, the compiled
code will consider ptrs, etc., to be 64 bits. In general, the _only_
thing stopping GP or the code itself from being relocated to a 64-bit
address is this code which is caused by HAVE_32BIT_ADDRESSES being true.
I'm wondering if maybe HAVE_32BIT_ADDRESSES should be defined as:
(HAVE_32BIT_GPRS
|| ((bfd_arch_bits_per_address (stdoutput) == 32
|| ! HAVE_64BIT_OBJECTS)
&& mips_pic != EMBEDDED_PIC))
(Alternately, it looks like maybe all HAVE_32BIT_ADDRESSES tests are
within PIC-type tests anyway, but i'm not 100% sure of that. In that
case, I suppose it would be possible to just use HAVE_64BIT_GPRS or
similar... but then at each place it would be important to
differentiate the address size, and I think it'd be a maintenance
hassle in the long run.)
Thoughts?
chris