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]

Re: Improvements and fixes for mips n32/n64 relocations


Alexandre Oliva wrote:
[snip]
> > Some more parentheses might look better.
> 
> I couldn't find any parenthesizing that would look good.
> 
> HAVE_32BIT_ADDRESSES ? (HAVE_NEWABI
>                         ? "add" : "addu" : "daddu")
> 
> looked ugly, whereas
> 
> HAVE_32BIT_ADDRESSES
> ? (HAVE_NEWABI ? "add" : "addu")
> : "daddu"
> 
> looked wasteful.  I could go either way, it's not like any of the
> alternatives is really pleasing.  Perhaps we should have some global
> variable holding the kind of add and addi instruction to use for
> address arithmetic?

Or just one more macro ADDRESS_ADD_INSN.

> > And if I read the n64 draft right, n64 also prefers 'dadd'.
> 
> Hmm...  Irix 6's /usr/include/sys/asm.h seems to disagree.  But then,
> it doesn't use add for N32 either.
> 
> I see the elf64 spec uses both daddiu and dadd, so I'm a bit confused
> as to why one would be preferred over the other.  It doesn't seem to
> me like it would make any difference.  What am I missing?

The difference is the overflow checking, I guess. o32 assumes 32bit wide
hardware registers. Overflows would just wrap around, and likely trip
over the kernel space protection due to the way the MIPS memory layout
works.

For CPUs with 64bit wide registers, this assumption fails. Unchecked
overflows would silently corrupt the proper sign extension, which
leads to undefined CPU behaviour.

I think SGI took just the chance to catch such errors in their new ABI.

Hm, AFAICS we could use such overflow checking for all ABIs in order
to catch code generation bugs.


Thiemo


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