From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2920 invoked by alias); 21 Sep 2007 15:28:03 -0000 Received: (qmail 2906 invoked by uid 22791); 21 Sep 2007 15:28:02 -0000 X-Spam-Check-By: sourceware.org Received: from dmz.mips-uk.com (HELO dmz.mips-uk.com) (194.74.144.194) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 21 Sep 2007 15:27:54 +0000 Received: from internal-mx1 ([192.168.192.240] helo=ukservices1.mips.com) by dmz.mips-uk.com with esmtp (Exim 3.35 #1 (Debian)) id 1IYkQ3-0001wH-00; Fri, 21 Sep 2007 16:27:51 +0100 Received: from perivale.mips.com ([192.168.192.200]) by ukservices1.mips.com with esmtp (Exim 3.36 #1 (Debian)) id 1IYkPx-000783-00; Fri, 21 Sep 2007 16:27:45 +0100 Received: from macro (helo=localhost) by perivale.mips.com with local-esmtp (Exim 4.63) (envelope-from ) id 1IYkPx-0007AS-Bc; Fri, 21 Sep 2007 16:27:45 +0100 Date: Fri, 21 Sep 2007 15:28:00 -0000 From: "Maciej W. Rozycki" To: gdb-patches@sourceware.org cc: David Ung , "Maciej W. Rozycki" Subject: mips-tdep.c: Fix new-ABI handling of composite types Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MIPS-Technologies-UK-MailScanner: Found to be clean X-MIPS-Technologies-UK-MailScanner-From: macro@mips.com Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-09/txt/msg00278.txt.bz2 Hello, This patch fixes 2 new-ABI regressions in the test suite. Here's David's original comment attached to the change: "Currently if structs size is not a multiple of mips_abi_regsize(), they are put in both places (stack and argument registers). But the N32/N64 abi says that the caller does not reserve space for the register arguments, it's upto the callee to do that. Doing so inside gdb would cause the simulated program to incorrectly access fields of the struct if the size of the struct extends pass the argument registers onto the stack." The comment within the change provides a similar explanation. Tested for n32 using the mipsisa32-sde-elf target, with the mips-sim-sde64/-mips64/-EB and mips-sim-sde64/-mips64/-EL boards removing the following failures: (gdb) FAIL: gdb.base/call-ar-st.exp: print sum_array_print(10, *list1, *list2, *list3, *list4) (gdb) FAIL: gdb.base/call-rt-st.exp: print print_one_large_struct(*list1) 2007-09-21 David Ung Maciej W. Rozycki * mips-tdep.c (mips_n32n64_push_dummy_call): Per N32/N64 ABI rules do not treat composite types specially. OK to apply? Maciej 12430.diff Index: binutils-quilt/src/gdb/mips-tdep.c =================================================================== --- binutils-quilt.orig/src/gdb/mips-tdep.c 2007-08-28 16:16:55.000000000 +0100 +++ binutils-quilt/src/gdb/mips-tdep.c 2007-08-28 16:53:33.000000000 +0100 @@ -2928,12 +2928,14 @@ /* Copy the argument to general registers or the stack in register-sized pieces. Large arguments are split between registers and stack. */ - /* Note: structs whose size is not a multiple of MIPS64_REGSIZE - are treated specially: Irix cc passes them in registers - where gcc sometimes puts them on the stack. For maximum - compatibility, we will put them in both places. */ - int odd_sized_struct = (len > MIPS64_REGSIZE - && len % MIPS64_REGSIZE != 0); + /* For N32/N64, 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. + The caller does not reserve space for the register arguments; + the callee is responsible for reserving it if required. */ /* Note: Floating-point values that didn't fit into an FP register are only written to memory. */ while (len > 0) @@ -2950,8 +2952,7 @@ gdb_assert (argreg > MIPS_LAST_ARG_REGNUM); /* Write this portion of the argument to the stack. */ - if (argreg > MIPS_LAST_ARG_REGNUM - || odd_sized_struct) + if (argreg > MIPS_LAST_ARG_REGNUM) { /* Should shorter than int integer values be promoted to int before being stored? */