From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21621 invoked by alias); 19 Dec 2007 15:20:39 -0000 Received: (qmail 21611 invoked by uid 22791); 19 Dec 2007 15:20:39 -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; Wed, 19 Dec 2007 15:20:30 +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 1J50ig-0008TK-00; Wed, 19 Dec 2007 15:20:26 +0000 Received: from perivale.mips.com ([192.168.192.200]) by ukservices1.mips.com with esmtp (Exim 3.36 #1 (Debian)) id 1J50ia-0003YE-00; Wed, 19 Dec 2007 15:20:20 +0000 Received: from macro (helo=localhost) by perivale.mips.com with local-esmtp (Exim 4.63) (envelope-from ) id 1J50ia-0000aR-Ls; Wed, 19 Dec 2007 15:20:20 +0000 Date: Wed, 19 Dec 2007 15:27:00 -0000 From: "Maciej W. Rozycki" To: Daniel Jacobowitz cc: gdb-patches@sourceware.org, David Ung , "Maciej W. Rozycki" Subject: Re: mips-tdep.c: Sign-extend pointers for n32 In-Reply-To: <20071216184625.GA22905@caradoc.them.org> Message-ID: References: <20071216184625.GA22905@caradoc.them.org> 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-12/txt/msg00315.txt.bz2 On Sun, 16 Dec 2007, Daniel Jacobowitz wrote: > Why just pointers? I'm not entirely sure what's going on above in the > float case, but in the integer case this seems clearly wrong. Zero > extension is probably "right" for trailing bits of structures but what > about negative integers? You are quite right here -- I have checked the N32 ABI document and it says: "32-bit integer (int) parameters are always sign-extended when passed in registers, whether of signed or unsigned type. [This issue does not arise in the o32-bit ABI.]" It does not actually say anything about pointers beyond: "All pointers and addresses are 32-bit objects. [Under 64, pointers and addresses are 64bits.]" but I gather this is because the document was meant to specify a user mode ABI for programs run under IRIX only, so addresses with the bit #31 set were not expected to be relevant. I have regression-tested the following rewrite of the original patch using the mipsisa32-sde-elf target, with the mips-sim-sde64/-mips64/-EB and mips-sim-sde64/-mips64/-EL boards, with the results the same as the original. 2007-12-19 David Ung Maciej W. Rozycki * mips-tdep.c (mips_n32n64_push_dummy_call): Sign-extend 32-bit pointers and integers as required by the ABI. OK to apply? Maciej 12741-0.diff Index: binutils-quilt/src/gdb/mips-tdep.c =================================================================== --- binutils-quilt.orig/src/gdb/mips-tdep.c 2007-12-19 15:09:31.000000000 +0000 +++ binutils-quilt/src/gdb/mips-tdep.c 2007-12-19 15:10:13.000000000 +0000 @@ -3184,8 +3184,17 @@ purpose register. */ if (argreg <= MIPS_LAST_ARG_REGNUM) { - LONGEST regval = - extract_unsigned_integer (val, partial_len); + LONGEST regval; + + /* Sign extend pointers and 32-bit integers; + everything else is taken as is. */ + + if (partial_len == 4 && + (typecode == TYPE_CODE_PTR + || typecode == TYPE_CODE_INT)) + regval = extract_signed_integer (val, partial_len); + else + regval = extract_unsigned_integer (val, partial_len); /* A non-floating-point argument being passed in a general register. If a struct or union, and if