This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] mips_push_arguments(): Make O64 ABI test explicit
On Wed, Jul 31, 2002 at 06:30:04PM -0700, Kevin Buettner wrote:
> On Jul 31, 6:10pm, Kevin Buettner wrote:
>
> > So, it seems that cc wants small structs shifted, but that gcc does not.
> >
> > Time for me to dig into the ABI documents to find out which compiler's
> > right...
>
> It looks to me like the SGI (cc) compiler is right. The text below was
> obtained from:
>
> http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/srch3@n64/0650/bks/SGI_Developer/books/Mpro_n32_ABI/sgi_html/ch02.html
>
>
> * Structs, unions, or other composite types are treated as a
> sequence of doublewords, and are passed in integer or floating
> point registers as though they were simple scalar parameters to
> the extent that they fit, with any excess on the stack packed
> according to the normal memory layout of the object. More
> specifically:
>
> - Regardless of the struct field structure, it is treated as a
> sequence of 64-bit chunks. If a chunk consists solely of a
> double float field (but not a double, which is part of a
> union), it is passed in a floating point register. Any
> other chunk is passed in an integer register.
>
> - A union, either as the parameter itself or as a struct
> parameter field, is treated as a sequence of integer
> doublewords for purposes of assignment to integer parameter
> registers. No attempt is made to identify floating point
> components for passing in floating point registers.
>
> - Array fields of structs are passed like unions. Array
> parameters are passed by reference (unless the relevant
> language standard requires otherwise).
>
> - Right-justifying small scalar parameters in their save area
> slots notwithstanding, struct parameters are always
> left-justified. This applies both to the case of a struct
> smaller than 64 bits, and to the final chunk of a struct
> which is not an integral multiple of 64 bits in size. The
> implication of this rule is that the address of the first
> chunk's save area slot is the address of the struct, and the
> struct is laid out in the save area memory exactly as if it
> were allocated normally (once any part in registers has been
> stored to the save area). [These rules are analogous to the
> o32-bit ABI treatment - only the chunk size and the ability
> to pass double fields in floating point registers are
> different.]
>
> So, if I understand this correctly, gdb ought to be left shifting small
> struct parameters for the o32, n32, and n64 ABIs. I.e, I think my patch
> was correct, though I do agree with Michael that it might be better to
> list the ABIs that we want to do this struct shifting for instead of
> trying to list the ones that we don't want to shift.
GCC already has at least one known bug in this area on O32. I am
inclined to go with SGI CC's interpretation; you should complain at
Eric some more to get GCC fixed properly. Lord knows I haven't had
much luck :P
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer