From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fGHtBNIbnGAhYwAAWB0awg (envelope-from ) for ; Wed, 12 May 2021 14:17:54 -0400 Received: by simark.ca (Postfix, from userid 112) id 074261F11C; Wed, 12 May 2021 14:17:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4591D1E783 for ; Wed, 12 May 2021 14:17:53 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 005773853816; Wed, 12 May 2021 18:17:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 005773853816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620843473; bh=3v5faNP/juVYIz7fx98PXrxWvJepjDVCEn7khO6HUT0=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=aw2+MQ07vN9UAmJabi9tB1R/rr7nuBmLHiTZnCeJawFwGKno/XlOoeYA6UKuCy86G 7QAiqtEhXD7zH4MZuA8FsvpJojWCh3utAfkx9D4o1EesM0wuFQZzQewFXyKVVaFBAZ dW911oko09sVPiX/Yege4+Zh/Fpa8PCtjQVRxQto= Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 182D73853801 for ; Wed, 12 May 2021 18:17:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 182D73853801 Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2607D335C8C; Wed, 12 May 2021 18:17:47 +0000 (UTC) Date: Wed, 12 May 2021 14:17:46 -0400 To: Faraz Shahbazker Subject: Re: [PATCH 1/2] [pr gdb/19447] sim: mips: Only truncate sign extension bits for 32-bit target models Message-ID: Mail-Followup-To: Faraz Shahbazker , gdb-patches@sourceware.org, "Maciej W . Rozycki" , Chao-ying Fu References: <20210504232117.896136-1-fshahbazker@wavecomp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210504232117.896136-1-fshahbazker@wavecomp.com> X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Cc: Chao-ying Fu , gdb-patches@sourceware.org, "Maciej W . Rozycki" Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 05 May 2021 04:51, Faraz Shahbazker wrote: > 64-bit BFD for MIPS applies a standard sign extension on all addresses > assuming 64-bit target. These bits are required for 64-bit and can only be > safely truncated for 32-bit target models. This partially reverts commit > b36d953bced0a4fecdde1823abac70ed7038ee95 can you verify there are no regressions in `make check` for the various mips targets & build configs ? if the tests pass, then i'm fine with the patch. > --- > > Notes: these notes should be part of the commit message for posterity > sim_cpu *cpu = STATE_CPU (sd, cpu_nr); > - sim_cia pc = bfd_get_start_address (abfd); > - > - /* We need to undo brain-dead bfd behavior where it sign-extends > - addresses that are supposed to be unsigned. See the mips bfd > - sign_extend_vma setting. We have to check the ELF data itself > - in order to handle o32 & n32 ABIs. */ > - if (abfd->tdata.elf_obj_data->elf_header->e_ident[EI_CLASS] == > - ELFCLASS32) > - pc = (unsigned32) pc; > - > - CPU_PC_SET (cpu, pc); > + /* The 64-bit BFD sign-extends MIPS addresses to model > + 32-bit compatibility segments with 64-bit addressing. > + These addresses work as is on 64-bit targets but > + can be truncated for 32-bit targets. */ > + if (WITH_TARGET_WORD_BITSIZE == 32) > + CPU_PC_SET (cpu, (unsigned32) bfd_get_start_address (abfd)); > + else > + CPU_PC_SET (cpu, bfd_get_start_address (abfd)); style-wise, it seems like you should have just changed the if() statement and left the rest of the code alone. it avoids duplicating the rest of the logic. -mike