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 0D5873858D37 for ; Sun, 3 Apr 2022 18:57:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D5873858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=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=thW4/+tMVQCP5qBchZIHo6sslnsF9AhhDXi9Py8yonE=; b=p02ngcyN56to9mhdOY6r/55g6+ T9HywFNUKOfpDZRHw+1Q0WPSv6fvUBYTSmxlwJ50q/DEDftyeZ2YGAhAHWQh1LMYzmw5HOJUZcIBq wS0vekD74BcByKrbMtbYWVRW1RQuasVAB6DJjVBRw9gbj8r0Vc7y4YJYjcU011OsnAipbiTe3zC2C 4WaWAp5SFbtLBrw0LUnlBT+VguIrBQKBy4B5RjogHW4J09k7bGudlHhXJWLkyZf+pEGKv6bLQTdKK h8OunM0Gk6uDZgHzjzGMi9aANDogrEoBS3OJC7iU7yQQeGzKFRjK4eEKfAQgaccDVSNu5KB5bDPvz S1i9MG+A==; Received: from [95.87.234.74] (port=53612 helo=kendros.lan) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nb5Q1-000Bfh-8a; Sun, 03 Apr 2022 21:57:47 +0300 From: Dimitar Dimitrov To: newlib@sourceware.org Subject: [PATCH] libgloss: pru: Fix _open syscal arguments Date: Sun, 3 Apr 2022 21:57:39 +0300 Message-Id: <20220403185739.2997679-1-dimitar@dinux.eu> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-OutGoing-Spam-Status: No, score=-2.9 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=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HAS_X_OUTGOING_SPAM_STAT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Sun, 03 Apr 2022 18:57:53 -0000 The _open() C function is declared as having variable arguments in newlib, so second and third arguments are passed on stack. Add code to move them into registers, since that's where the PRU simulator expects them. Issue was exposed by the GCC test gcc.c-torture/execute/fprintf-2.c, which relies on tmpnam implementation to pass correct flags to _open. Signed-off-by: Dimitar Dimitrov --- libgloss/pru/syscalls.S | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libgloss/pru/syscalls.S b/libgloss/pru/syscalls.S index 252231e90..80486d1f9 100644 --- a/libgloss/pru/syscalls.S +++ b/libgloss/pru/syscalls.S @@ -68,7 +68,6 @@ __SC_ret_skip_errno_set: users use other methods for communicating with the host - remoteproc, rpmsg, shared memory. */ SC _exit, SYS_exit - SC _open, SYS_open SC _close, SYS_close SC _read, SYS_read SC _write, SYS_write @@ -77,3 +76,20 @@ __SC_ret_skip_errno_set: SC _getpid, SYS_getpid SC _kill, SYS_kill SC _fstat, SYS_fstat + + + /* _open is special because it has VA declaration. */ + .section .text._open, "ax" + .global _open + .type _open,@function + .func +_open: + /* Pop the second and third argument from stack, per VA ABI. + Thus simulator can get all arguments from registers + for any supported syscall. */ + lbbo r16, sp, 4, 4 + lbbo r15, sp, 0, 4 + ldi r1, SYS_open + halt + jmp __SC_ret + .endfunc -- 2.35.1