* [RFA] PPC ABI compliance fix
@ 2002-03-22 11:28 Elena Zannoni
2002-03-22 11:52 ` Andrew Cagney
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Elena Zannoni @ 2002-03-22 11:28 UTC (permalink / raw)
To: gdb-patches
Back in November, gcc changed the way structures <= 8 bytes are
returned on the PPC. The change was made to be compliant with the
SVR4 ABI.
http://gcc.gnu.org/ml/gcc-patches/2001-11/msg01468.html
The abi specifies that such structures are passed in r3 and r4.
Bigger structures are passed in memory.
Gcc was passing every structure in memory. The change was made for
embedded targets, but not for natives (PowerPC Linux, NetBSD, and
FreeBSD).
Of course this change breaks binary compatibility with older gcc's.
Not sure what to do about that, if anything, the case it covers is a
corner case, anyway.
Elena
2002-03-21 Elena Zannoni <ezannoni@redhat.com>
* ppc-linux-tdep.c (ppc_sysv_abi_use_struct_convention): New
function.
* ppc-tdep.h (ppc_sysv_abi_use_struct_convention): Export.
* rs6000-tdep.c (rs6000_gdbarch_init): Use different
structure returning convention for SYSV ABI case, but not
for GNU/Linux, FreeBSD, or NetBSD.
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/uberbaum/gdb/rs6000-tdep.c,v
retrieving revision 1.38
diff -u -r1.38 rs6000-tdep.c
--- rs6000-tdep.c 2002/02/14 15:13:53 1.38
+++ rs6000-tdep.c 2002/03/22 18:46:53
@@ -2563,8 +2563,6 @@
set_gdbarch_store_struct_return (gdbarch, rs6000_store_struct_return);
set_gdbarch_store_return_value (gdbarch, rs6000_store_return_value);
set_gdbarch_extract_struct_value_address (gdbarch, rs6000_extract_struct_value_address);
- set_gdbarch_use_struct_convention (gdbarch, generic_use_struct_convention);
-
set_gdbarch_pop_frame (gdbarch, rs6000_pop_frame);
set_gdbarch_skip_prologue (gdbarch, rs6000_skip_prologue);
@@ -2576,6 +2574,27 @@
/* Not sure on this. FIXMEmgo */
set_gdbarch_frame_args_skip (gdbarch, 8);
+ /* Until November 2001, gcc was not complying to the SYSV ABI for
+ returning structures less than or equal to 8 bytes in size. It was
+ returning everything in memory. When this was corrected, it wasn't
+ fixed for native platforms. */
+ if (sysv_abi)
+ {
+ if (osabi == ELFOSABI_LINUX
+ || osabi == ELFOSABI_NETBSD
+ || osabi == ELFOSABI_FREEBSD)
+ set_gdbarch_use_struct_convention (gdbarch,
+ generic_use_struct_convention);
+ else
+ set_gdbarch_use_struct_convention (gdbarch,
+ ppc_sysv_abi_use_struct_convention);
+ }
+ else
+ {
+ set_gdbarch_use_struct_convention (gdbarch,
+ generic_use_struct_convention);
+ }
+
set_gdbarch_frame_chain_valid (gdbarch, file_frame_chain_valid);
if (osabi == ELFOSABI_LINUX)
{
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/uberbaum/gdb/ppc-linux-tdep.c,v
retrieving revision 1.13
diff -u -r1.13 ppc-linux-tdep.c
--- ppc-linux-tdep.c 2002/02/24 22:31:19 1.13
+++ ppc-linux-tdep.c 2002/03/22 18:48:39
@@ -414,6 +414,14 @@
it may be used generically by ports which use either the SysV ABI or
the EABI */
+/* Structures 8 bytes or less long are returned in the r3 & r4
+ registers, according to the SYSV ABI. */
+int
+ppc_sysv_abi_use_struct_convention (int gcc_p, struct type *value_type)
+{
+ return (TYPE_LENGTH (value_type) > 8);
+}
+
/* round2 rounds x up to the nearest multiple of s assuming that s is a
power of 2 */
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/uberbaum/gdb/ppc-tdep.h,v
retrieving revision 1.6
diff -u -r1.6 ppc-tdep.h
--- ppc-tdep.h 2001/12/30 00:14:50 1.6
+++ ppc-tdep.h 2002/03/22 18:49:05
@@ -31,6 +31,7 @@
int ppc_linux_frameless_function_invocation (struct frame_info *);
void ppc_linux_frame_init_saved_regs (struct frame_info *);
CORE_ADDR ppc_linux_frame_chain (struct frame_info *);
+int ppc_sysv_abi_use_struct_convention (int, struct type *);
CORE_ADDR ppc_sysv_abi_push_arguments (int, struct value **, CORE_ADDR, int,
CORE_ADDR);
int ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache);
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [RFA] PPC ABI compliance fix
2002-03-22 11:28 [RFA] PPC ABI compliance fix Elena Zannoni
@ 2002-03-22 11:52 ` Andrew Cagney
2002-03-22 12:06 ` Elena Zannoni
2002-03-22 12:47 ` Kevin Buettner
2002-03-22 14:01 ` Elena Zannoni
2 siblings, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2002-03-22 11:52 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches
> Index: ppc-linux-tdep.c
> ===================================================================
> RCS file: /cvs/uberbaum/gdb/ppc-linux-tdep.c,v
> retrieving revision 1.13
> diff -u -r1.13 ppc-linux-tdep.c
> --- ppc-linux-tdep.c 2002/02/24 22:31:19 1.13
> +++ ppc-linux-tdep.c 2002/03/22 18:48:39
> @@ -414,6 +414,14 @@
> it may be used generically by ports which use either the SysV ABI or
> the EABI */
>
> +/* Structures 8 bytes or less long are returned in the r3 & r4
> + registers, according to the SYSV ABI. */
> +int
> +ppc_sysv_abi_use_struct_convention (int gcc_p, struct type *value_type)
> +{
> + return (TYPE_LENGTH (value_type) > 8);
> +}
> +
> /* round2 rounds x up to the nearest multiple of s assuming that s is a
> power of 2 */
Should this live in rs6000-tdep.c?
enjoy,
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [RFA] PPC ABI compliance fix
2002-03-22 11:52 ` Andrew Cagney
@ 2002-03-22 12:06 ` Elena Zannoni
2002-03-22 12:37 ` Kevin Buettner
0 siblings, 1 reply; 7+ messages in thread
From: Elena Zannoni @ 2002-03-22 12:06 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Elena Zannoni, gdb-patches
Andrew Cagney writes:
> > Index: ppc-linux-tdep.c
> > ===================================================================
> > RCS file: /cvs/uberbaum/gdb/ppc-linux-tdep.c,v
> > retrieving revision 1.13
> > diff -u -r1.13 ppc-linux-tdep.c
> > --- ppc-linux-tdep.c 2002/02/24 22:31:19 1.13
> > +++ ppc-linux-tdep.c 2002/03/22 18:48:39
> > @@ -414,6 +414,14 @@
> > it may be used generically by ports which use either the SysV ABI or
> > the EABI */
> >
> > +/* Structures 8 bytes or less long are returned in the r3 & r4
> > + registers, according to the SYSV ABI. */
> > +int
> > +ppc_sysv_abi_use_struct_convention (int gcc_p, struct type *value_type)
> > +{
> > + return (TYPE_LENGTH (value_type) > 8);
> > +}
> > +
> > /* round2 rounds x up to the nearest multiple of s assuming that s is a
> > power of 2 */
>
> Should this live in rs6000-tdep.c?
Yes, There is a FIXME about that in the file. I am not sure why
sysv_push_arguments is in that file as well. I didn't want to change
it in case there was some real technical problem.
Maybe Kevin knows why?
Elena
>
> enjoy,
> Andrew
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [RFA] PPC ABI compliance fix
2002-03-22 12:06 ` Elena Zannoni
@ 2002-03-22 12:37 ` Kevin Buettner
0 siblings, 0 replies; 7+ messages in thread
From: Kevin Buettner @ 2002-03-22 12:37 UTC (permalink / raw)
To: Elena Zannoni, Andrew Cagney; +Cc: gdb-patches
On Mar 22, 3:06pm, Elena Zannoni wrote:
> > > +ppc_sysv_abi_use_struct_convention (int gcc_p, struct type *value_type)
> > > +{
> > > + return (TYPE_LENGTH (value_type) > 8);
> > > +}
> > > +
> > > /* round2 rounds x up to the nearest multiple of s assuming that s is a
> > > power of 2 */
> >
> > Should this live in rs6000-tdep.c?
>
> Yes, There is a FIXME about that in the file. I am not sure why
> sysv_push_arguments is in that file as well. I didn't want to change
> it in case there was some real technical problem.
>
> Maybe Kevin knows why?
There's no real technical problem. I wrote
ppc_sysv_abi_push_arguments() for Linux, so it ended up in the Linux
file. I don't think there would be any real problem with moving it to
rs6000-tdep.c, but I would prefer not to since rs6000-tdep.c deals
more with the PowerOpen ABI (in addition to generic arch considerations).
In my opinion, they probably belong in a ppc-sysv-abi-tdep.c file.
But at the moment, there's no real incentive for creating this file
(aside from making things somewhat more tidy) because ppc-linux-tdep.c
needs to be a part of all GDB builds that target Power / PowerPC.
I've been thinking about Andrew's comments from a week or so ago in
the discussion regarding x86-64-linux-tdep.c. As Andrew noted at the
time, the gdbarch machinery that we now have isn't set up to do
inheritance, and so as a consequence, we end up with the situation
that we have with the ppc*-tdep.c files in which you need include
linux support in a native build for AIX. It would be nice if we could
restructure things so that there'd be a generic ppc-tdep.c file which
knows nothing about ABIs or OS considerations. Under that, you'd have
ppc-poweropen-abi.c (or whatever IBM is calling their ABI these days)
and ppc-sysv-abi-tdep.c and perhaps even ppc-sysv-eabi-tdep.c. Below
that you'd have the various OS specific tdep files. Unfortunately,
we can't do it yet because the gdbarch machinery won't allow it.
Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] PPC ABI compliance fix
2002-03-22 11:28 [RFA] PPC ABI compliance fix Elena Zannoni
2002-03-22 11:52 ` Andrew Cagney
@ 2002-03-22 12:47 ` Kevin Buettner
2002-03-22 13:41 ` Elena Zannoni
2002-03-22 14:01 ` Elena Zannoni
2 siblings, 1 reply; 7+ messages in thread
From: Kevin Buettner @ 2002-03-22 12:47 UTC (permalink / raw)
To: Elena Zannoni, gdb-patches
On Mar 22, 2:28pm, Elena Zannoni wrote:
> Back in November, gcc changed the way structures <= 8 bytes are
> returned on the PPC. The change was made to be compliant with the
> SVR4 ABI.
>
> http://gcc.gnu.org/ml/gcc-patches/2001-11/msg01468.html
>
> The abi specifies that such structures are passed in r3 and r4.
> Bigger structures are passed in memory.
>
> Gcc was passing every structure in memory. The change was made for
> embedded targets, but not for natives (PowerPC Linux, NetBSD, and
> FreeBSD).
>
> Of course this change breaks binary compatibility with older gcc's.
> Not sure what to do about that, if anything, the case it covers is a
> corner case, anyway.
Hmm... I have a hunch that, eventually, the natives will need to
change too.
For now though, your change is okay.
(Alternately, we could take a really hard nosed stance and implement
the ABI exactly as written and just put up with the failures.)
Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] PPC ABI compliance fix
2002-03-22 12:47 ` Kevin Buettner
@ 2002-03-22 13:41 ` Elena Zannoni
0 siblings, 0 replies; 7+ messages in thread
From: Elena Zannoni @ 2002-03-22 13:41 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
Kevin Buettner writes:
> On Mar 22, 2:28pm, Elena Zannoni wrote:
>
> > Back in November, gcc changed the way structures <= 8 bytes are
> > returned on the PPC. The change was made to be compliant with the
> > SVR4 ABI.
> >
> > http://gcc.gnu.org/ml/gcc-patches/2001-11/msg01468.html
> >
> > The abi specifies that such structures are passed in r3 and r4.
> > Bigger structures are passed in memory.
> >
> > Gcc was passing every structure in memory. The change was made for
> > embedded targets, but not for natives (PowerPC Linux, NetBSD, and
> > FreeBSD).
> >
> > Of course this change breaks binary compatibility with older gcc's.
> > Not sure what to do about that, if anything, the case it covers is a
> > corner case, anyway.
>
> Hmm... I have a hunch that, eventually, the natives will need to
> change too.
>
Gcc is explicitly disabling ABI compliance for the natives. I think
Aldy asked to the gcc mailing list if he could change at least Linux,
and there was a loud 'No'.
> For now though, your change is okay.
>
> (Alternately, we could take a really hard nosed stance and implement
> the ABI exactly as written and just put up with the failures.)
>
Ironically enough the gcc implementation is not correct, yet. It
screws up where exactly in r3 and r4 it puts the structure if the
structure is strictly less than 8 bytes. :-(
For instances 5 characters are stored like
R3 R4
. . . h e l l o
Instead of
R3 R4
h e l l o . . .
I thought Aldy was taking care of this, but he has gone on vacation.
Elena
> Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA] PPC ABI compliance fix
2002-03-22 11:28 [RFA] PPC ABI compliance fix Elena Zannoni
2002-03-22 11:52 ` Andrew Cagney
2002-03-22 12:47 ` Kevin Buettner
@ 2002-03-22 14:01 ` Elena Zannoni
2 siblings, 0 replies; 7+ messages in thread
From: Elena Zannoni @ 2002-03-22 14:01 UTC (permalink / raw)
To: gdb-patches
Elena Zannoni writes:
>
> Back in November, gcc changed the way structures <= 8 bytes are
> returned on the PPC. The change was made to be compliant with the
> SVR4 ABI.
>
> http://gcc.gnu.org/ml/gcc-patches/2001-11/msg01468.html
>
> The abi specifies that such structures are passed in r3 and r4.
> Bigger structures are passed in memory.
>
> Gcc was passing every structure in memory. The change was made for
> embedded targets, but not for natives (PowerPC Linux, NetBSD, and
> FreeBSD).
>
> Of course this change breaks binary compatibility with older gcc's.
> Not sure what to do about that, if anything, the case it covers is a
> corner case, anyway.
>
>
> Elena
>
>
> 2002-03-21 Elena Zannoni <ezannoni@redhat.com>
>
> * ppc-linux-tdep.c (ppc_sysv_abi_use_struct_convention): New
> function.
> * ppc-tdep.h (ppc_sysv_abi_use_struct_convention): Export.
> * rs6000-tdep.c (rs6000_gdbarch_init): Use different
> structure returning convention for SYSV ABI case, but not
> for GNU/Linux, FreeBSD, or NetBSD.
>
Committed.
Elena
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-03-22 22:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-22 11:28 [RFA] PPC ABI compliance fix Elena Zannoni
2002-03-22 11:52 ` Andrew Cagney
2002-03-22 12:06 ` Elena Zannoni
2002-03-22 12:37 ` Kevin Buettner
2002-03-22 12:47 ` Kevin Buettner
2002-03-22 13:41 ` Elena Zannoni
2002-03-22 14:01 ` Elena Zannoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox