From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id 62B213851C38 for ; Wed, 3 Jun 2020 16:14:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 62B213851C38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dimitar@dinux.eu DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dinux.eu; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=03zjU0diM0Z1/qzVr/UFrzHWeOvrrd2I+Ivbg6ayovU=; b=e95SLLFyzzbKacQbPD3Qi9cbQK EruKaetkl42m4rcI2AT9mP4sursso8i30x3AM5XG9ULjt7sUv2yl540swPtaWuUXcNGERWsPGEaM2 zNhY1fvNOHlmtQb95d61/WPNePeDRLmUEjEAfs0RVSYwuB/ejy1Te+LuqmQjzl1LOMn579ZNs/wOO a7sZYfCfpc/SCo+DrPxH+yYeVYQmGA3zLHDiiyyNQUIohmOez1ExqxHPtV9TY4FrRNLPQ7NUkMpbg EYPCUYZbybZneDw0S1izu0aEhq90elXLXygaAAeyEnAb9oxKln+N45X5eb1i+t1VCGFKSVkxKLPxC 9TYix9jA==; Received: from [95.87.234.74] (port=36780 helo=localhost.localdomain) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1jgW28-000BLs-RF; Wed, 03 Jun 2020 19:14:30 +0300 From: Dimitar Dimitrov To: newlib@sourceware.org Subject: [PATCH] pru: Fix memory corruption on syscall return Date: Wed, 3 Jun 2020 19:14:22 +0300 Message-Id: <20200603161422.18902-1-dimitar@dinux.eu> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server28.superhosting.bg X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dinux.eu X-Get-Message-Sender-Via: server28.superhosting.bg: authenticated_id: dimitar@dinux.eu X-Authenticated-Sender: server28.superhosting.bg: dimitar@dinux.eu X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 16:14:35 -0000 In the initial code I missed one level of pointer indirection. Instead of storing errno in impure_data, _impure_ptr was corrupted. Only simulator is impacted. Real targets have no OS and no syscalls. This resolves a bunch of stdio cases from the GCC testsuite: FAIL->PASS: gcc.c-torture/execute/printf-2.c -O0 execution test Signed-off-by: Dimitar Dimitrov --- libgloss/pru/syscalls.S | 1 + 1 file changed, 1 insertion(+) diff --git a/libgloss/pru/syscalls.S b/libgloss/pru/syscalls.S index 8ed7601a4..3ad0d9215 100644 --- a/libgloss/pru/syscalls.S +++ b/libgloss/pru/syscalls.S @@ -42,6 +42,7 @@ __SC_ret: /* Invert return code and store to errno (first int in _impure_ptr). */ rsb r14, r14, 0 ldi32 r1, _impure_ptr + lbbo r1, r1, 0, 4 sbbo r14, r1, 0, 4 /* Return -1 (for both int32_t or int64_t). */ fill r14, 8 -- 2.20.1