* [rfa] Fix ppc32 GNU/Linux (and AIX) struct convention
@ 2003-09-13 21:57 Andrew Cagney
2003-09-16 20:20 ` Kevin Buettner
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2003-09-13 21:57 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 498 bytes --]
Hello,
The attached patch fixes the 32 bit PPC GNU/Linux (and AIX) struct
return code. PowerOpen returns all structures via a pointer, not just
the odd sized ones (which is what the generic struct return method tests
for).
32 bit PPC GNU/Linux, for historic reasons, continues to use this
convention. Tested on 32 bit GNU/Linux where structs.exp and
callfuncs.exp stopped failing.
Note that for GNU/Linux I've made this 32 bit specific. PPC64 is going
to need a new method.
ok?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 4759 bytes --]
2003-09-13 Andrew Cagney <cagney@redhat.com>
* ppc-linux-tdep.c (ppc_linux_init_abi): Set the 32 bit
"use_struct_convention" to "rs6000_use_struct_convention".
* ppc-tdep.h (rs6000_use_struct_convention): Declare.
* rs6000-tdep.c (rs6000_use_struct_convention): New function.
(rs6000_gdbarch_init): For AIX, set "use_struct_convention" to
"rs6000_use_struct_convention".
* ppc-sysv-tdep.c (ppc_sysv_abi_broken_use_struct_convention):
Delete function.
* ppc-tdep.h (ppc_sysv_abi_broken_use_struct_convention): Delete.
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.39
diff -u -r1.39 ppc-linux-tdep.c
--- ppc-linux-tdep.c 9 Sep 2003 03:14:02 -0000 1.39
+++ ppc-linux-tdep.c 13 Sep 2003 21:34:36 -0000
@@ -1017,15 +1017,17 @@
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- /* 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. */
- set_gdbarch_use_struct_convention (gdbarch,
- ppc_sysv_abi_broken_use_struct_convention);
-
if (tdep->wordsize == 4)
{
+ /* Until November 2001, gcc did not comply with the SysV R4 ABI
+ requirement that structures less than or equal to 8 bytes
+ should be returned in registers. Instead GCC was using the
+ the AIX/PowerOpen ABI - everything returned in memory (well
+ ignoring vectors that is). When this was corrected, it
+ wasn't fixed for GNU/Linux native platform. Use the
+ PowerOpen struct convention. */
+ set_gdbarch_use_struct_convention (gdbarch, rs6000_use_struct_convention);
+
/* Note: kevinb/2002-04-12: See note in rs6000_gdbarch_init regarding
*_push_arguments(). The same remarks hold for the methods below. */
set_gdbarch_frameless_function_invocation (gdbarch,
Index: ppc-sysv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v
retrieving revision 1.10
diff -u -r1.10 ppc-sysv-tdep.c
--- ppc-sysv-tdep.c 12 Sep 2003 18:55:24 -0000 1.10
+++ ppc-sysv-tdep.c 13 Sep 2003 21:34:39 -0000
@@ -329,20 +329,6 @@
return sp;
}
-/* 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. */
-int
-ppc_sysv_abi_broken_use_struct_convention (int gcc_p, struct type *value_type)
-{
- if ((TYPE_LENGTH (value_type) == 16 || TYPE_LENGTH (value_type) == 8)
- && TYPE_VECTOR (value_type))
- return 0;
-
- return generic_use_struct_convention (gcc_p, value_type);
-}
-
/* Structures 8 bytes or less long are returned in the r3 & r4
registers, according to the SYSV ABI. */
int
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.17
diff -u -r1.17 ppc-tdep.h
--- ppc-tdep.h 9 Sep 2003 18:29:27 -0000 1.17
+++ ppc-tdep.h 13 Sep 2003 21:34:40 -0000
@@ -54,6 +54,7 @@
void rs6000_frame_init_saved_regs (struct frame_info *);
CORE_ADDR rs6000_frame_chain (struct frame_info *);
int altivec_register_p (int regno);
+extern int rs6000_use_struct_convention (int, struct type *);
/* Return non-zero when the architecture has an FPU (or at least when
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.157
diff -u -r1.157 rs6000-tdep.c
--- rs6000-tdep.c 12 Sep 2003 18:40:18 -0000 1.157
+++ rs6000-tdep.c 13 Sep 2003 21:35:09 -0000
@@ -1372,6 +1372,18 @@
}
}
+/* PowerOpen always puts structures in memory. Vectors, which were
+ added later, do get returned in a register though. */
+
+int
+rs6000_use_struct_convention (int gcc_p, struct type *value_type)
+{
+ if ((TYPE_LENGTH (value_type) == 16 || TYPE_LENGTH (value_type) == 8)
+ && TYPE_VECTOR (value_type))
+ return 0;
+ return 1;
+}
+
static void
rs6000_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
{
@@ -2957,7 +2969,7 @@
ppc_sysv_abi_use_struct_convention);
else
set_gdbarch_use_struct_convention (gdbarch,
- generic_use_struct_convention);
+ rs6000_use_struct_convention);
set_gdbarch_frameless_function_invocation (gdbarch,
rs6000_frameless_function_invocation);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [rfa] Fix ppc32 GNU/Linux (and AIX) struct convention
2003-09-13 21:57 [rfa] Fix ppc32 GNU/Linux (and AIX) struct convention Andrew Cagney
@ 2003-09-16 20:20 ` Kevin Buettner
2003-09-16 23:34 ` Andrew Cagney
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2003-09-16 20:20 UTC (permalink / raw)
To: Andrew Cagney, gdb-patches
On Sep 13, 5:57pm, Andrew Cagney wrote:
> * ppc-linux-tdep.c (ppc_linux_init_abi): Set the 32 bit
> "use_struct_convention" to "rs6000_use_struct_convention".
> * ppc-tdep.h (rs6000_use_struct_convention): Declare.
No. I would prefer that ppc-linux-tdep.c contain its own (suitably
named) "use_struct_convention" code even if it's identical to the code
needed by AIX. That way we can tweak one without having to worry
about breaking the other.
> * rs6000-tdep.c (rs6000_use_struct_convention): New function.
> (rs6000_gdbarch_init): For AIX, set "use_struct_convention" to
> "rs6000_use_struct_convention".
Okay.
> * ppc-sysv-tdep.c (ppc_sysv_abi_broken_use_struct_convention):
> Delete function.
> * ppc-tdep.h (ppc_sysv_abi_broken_use_struct_convention): Delete.
Okay.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfa] Fix ppc32 GNU/Linux (and AIX) struct convention
2003-09-16 20:20 ` Kevin Buettner
@ 2003-09-16 23:34 ` Andrew Cagney
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2003-09-16 23:34 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 902 bytes --]
> On Sep 13, 5:57pm, Andrew Cagney wrote:
>
>
>> * ppc-linux-tdep.c (ppc_linux_init_abi): Set the 32 bit
>> "use_struct_convention" to "rs6000_use_struct_convention".
>> * ppc-tdep.h (rs6000_use_struct_convention): Declare.
>
>
> No. I would prefer that ppc-linux-tdep.c contain its own (suitably
> named) "use_struct_convention" code even if it's identical to the code
> needed by AIX. That way we can tweak one without having to worry
> about breaking the other.
Done. This is what I've checked in.
Andrew
>
>> * rs6000-tdep.c (rs6000_use_struct_convention): New function.
>> (rs6000_gdbarch_init): For AIX, set "use_struct_convention" to
>> "rs6000_use_struct_convention".
>
>
> Okay.
>
>
>> * ppc-sysv-tdep.c (ppc_sysv_abi_broken_use_struct_convention):
>> Delete function.
>> * ppc-tdep.h (ppc_sysv_abi_broken_use_struct_convention): Delete.
>
>
> Okay.
>
> Kevin
>
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 4989 bytes --]
2003-09-16 Andrew Cagney <cagney@redhat.com>
* ppc-linux-tdep.c (ppc_linux_init_abi): Set the 32 bit
"use_struct_convention" to "ppc_linux_use_struct_convention".
(ppc_linux_use_struct_convention): New function.
* rs6000-tdep.c (rs6000_use_struct_convention): New function.
(rs6000_gdbarch_init): For AIX, set "use_struct_convention" to
"rs6000_use_struct_convention".
* ppc-tdep.h (ppc_sysv_abi_broken_use_struct_convention): Delete
declaration.
* ppc-sysv-tdep.c (ppc_sysv_abi_broken_use_struct_convention):
Delete function.
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.39
diff -u -r1.39 ppc-linux-tdep.c
--- ppc-linux-tdep.c 9 Sep 2003 03:14:02 -0000 1.39
+++ ppc-linux-tdep.c 16 Sep 2003 23:28:18 -0000
@@ -591,6 +591,20 @@
return val;
}
+/* For historic reasons, PPC 32 GNU/Linux follows PowerOpen rather
+ than the 32 bit SYSV R4 ABI structure return convention - all
+ structures, no matter their size, are put in memory. Vectors,
+ which were added later, do get returned in a register though. */
+
+static int
+ppc_linux_use_struct_convention (int gcc_p, struct type *value_type)
+{
+ if ((TYPE_LENGTH (value_type) == 16 || TYPE_LENGTH (value_type) == 8)
+ && TYPE_VECTOR (value_type))
+ return 0;
+ return 1;
+}
+
/* Fetch (and possibly build) an appropriate link_map_offsets
structure for GNU/Linux PPC targets using the struct offsets
defined in link.h (but without actual reference to that file).
@@ -1017,15 +1031,17 @@
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- /* 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. */
- set_gdbarch_use_struct_convention (gdbarch,
- ppc_sysv_abi_broken_use_struct_convention);
-
if (tdep->wordsize == 4)
{
+ /* Until November 2001, gcc did not comply with the 32 bit SysV
+ R4 ABI requirement that structures less than or equal to 8
+ bytes should be returned in registers. Instead GCC was using
+ the the AIX/PowerOpen ABI - everything returned in memory
+ (well ignoring vectors that is). When this was corrected, it
+ wasn't fixed for GNU/Linux native platform. Use the
+ PowerOpen struct convention. */
+ set_gdbarch_use_struct_convention (gdbarch, ppc_linux_use_struct_convention);
+
/* Note: kevinb/2002-04-12: See note in rs6000_gdbarch_init regarding
*_push_arguments(). The same remarks hold for the methods below. */
set_gdbarch_frameless_function_invocation (gdbarch,
Index: ppc-sysv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v
retrieving revision 1.10
diff -u -r1.10 ppc-sysv-tdep.c
--- ppc-sysv-tdep.c 12 Sep 2003 18:55:24 -0000 1.10
+++ ppc-sysv-tdep.c 16 Sep 2003 23:28:19 -0000
@@ -329,20 +329,6 @@
return sp;
}
-/* 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. */
-int
-ppc_sysv_abi_broken_use_struct_convention (int gcc_p, struct type *value_type)
-{
- if ((TYPE_LENGTH (value_type) == 16 || TYPE_LENGTH (value_type) == 8)
- && TYPE_VECTOR (value_type))
- return 0;
-
- return generic_use_struct_convention (gcc_p, value_type);
-}
-
/* Structures 8 bytes or less long are returned in the r3 & r4
registers, according to the SYSV ABI. */
int
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.159
diff -u -r1.159 rs6000-tdep.c
--- rs6000-tdep.c 14 Sep 2003 22:35:33 -0000 1.159
+++ rs6000-tdep.c 16 Sep 2003 23:28:19 -0000
@@ -1372,6 +1372,18 @@
}
}
+/* PowerOpen always puts structures in memory. Vectors, which were
+ added later, do get returned in a register though. */
+
+static int
+rs6000_use_struct_convention (int gcc_p, struct type *value_type)
+{
+ if ((TYPE_LENGTH (value_type) == 16 || TYPE_LENGTH (value_type) == 8)
+ && TYPE_VECTOR (value_type))
+ return 0;
+ return 1;
+}
+
static void
rs6000_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
{
@@ -2957,7 +2969,7 @@
ppc_sysv_abi_use_struct_convention);
else
set_gdbarch_use_struct_convention (gdbarch,
- generic_use_struct_convention);
+ rs6000_use_struct_convention);
set_gdbarch_frameless_function_invocation (gdbarch,
rs6000_frameless_function_invocation);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-09-16 23:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-13 21:57 [rfa] Fix ppc32 GNU/Linux (and AIX) struct convention Andrew Cagney
2003-09-16 20:20 ` Kevin Buettner
2003-09-16 23:34 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox