From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id D05883858D34; Thu, 2 Jul 2020 09:00:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D05883858D34 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] pru: Fix memory corruption on syscall return X-Act-Checkin: newlib-cygwin X-Git-Author: Dimitar Dimitrov X-Git-Refname: refs/heads/master X-Git-Oldrev: 5266248285bb3d2d012abd8a73957a0368f252ff X-Git-Newrev: 70cd4cbe651388897539fe38d2610e9bb733c5a8 Message-Id: <20200702090049.D05883858D34@sourceware.org> Date: Thu, 2 Jul 2020 09:00:49 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jul 2020 09:00:49 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=70cd4cbe651388897539fe38d2610e9bb733c5a8 commit 70cd4cbe651388897539fe38d2610e9bb733c5a8 Author: Dimitar Dimitrov Date: Wed Jun 3 19:14:22 2020 +0300 pru: Fix memory corruption on syscall return 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 Diff: --- 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