From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9365 invoked by alias); 22 Mar 2002 19:28:51 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9314 invoked from network); 22 Mar 2002 19:28:47 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 22 Mar 2002 19:28:47 -0000 Received: from localhost.redhat.com (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id LAA24656 for ; Fri, 22 Mar 2002 11:28:46 -0800 (PST) Received: by localhost.redhat.com (Postfix, from userid 469) id 0145911429; Fri, 22 Mar 2002 14:28:18 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15515.34258.778318.466752@localhost.redhat.com> Date: Fri, 22 Mar 2002 11:28:00 -0000 To: gdb-patches@sources.redhat.com Subject: [RFA] PPC ABI compliance fix X-Mailer: VM 7.00 under Emacs 20.7.1 X-SW-Source: 2002-03/txt/msg00423.txt.bz2 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 * 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);