From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29287 invoked by alias); 10 Feb 2020 20:20:04 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 29275 invoked by uid 89); 10 Feb 2020 20:20:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=H*Ad:U*mail, HContent-Transfer-Encoding:8bit X-HELO: georg.so Received: from georg.so (HELO georg.so) (89.238.75.224) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Feb 2020 20:20:03 +0000 Received: from dell12.lru.li (unknown [IPv6:2001:1a80:303a:0:b7b8:54b2:7463:9136]) (Authenticated sender: georg) by georg.so (Postfix) with ESMTPSA id 10FAC4AE900; Mon, 10 Feb 2020 21:20:01 +0100 (CET) Received: by dell12.lru.li (Postfix, from userid 1000) id B67FC15A72C; Mon, 10 Feb 2020 21:20:00 +0100 (CET) From: Georg Sauthoff To: newlib@sourceware.org Cc: Georg Sauthoff Subject: [PATCH 0/1] Only pass the minimum number of syscall arguments (RISC-V) Date: Mon, 10 Feb 2020 20:20:00 -0000 Message-Id: <20200210201958.352384-1-mail@gms.tf> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2020/txt/msg00079.txt As is, the RISC-V syscall code unconditionally sets all possible syscall arguments even if the syscall requires fewer. For example, the instruction sequence for a exit syscall looked like this: li a0, 1 # in ther caller of exit() # ... # in newlib: li a1, 0 # unused arguments li a2, 0 li a3, 0 li a4, 0 li a5, 0 li a7, 93 # exit syscall number (i.e. the binary contains then 5 superfluous instructions for this one argument syscall) This patch changes the RISC-V syscall code such that only the required syscall argument registers are set. Georg Sauthoff (1): Only pass the minimum number of syscall arguments libgloss/riscv/internal_syscall.h | 41 ++++++++++++++++++++++--------- libgloss/riscv/sys_access.c | 2 +- libgloss/riscv/sys_close.c | 2 +- libgloss/riscv/sys_exit.c | 2 +- libgloss/riscv/sys_faccessat.c | 2 +- libgloss/riscv/sys_fstat.c | 2 +- libgloss/riscv/sys_fstatat.c | 2 +- libgloss/riscv/sys_gettimeofday.c | 2 +- libgloss/riscv/sys_link.c | 2 +- libgloss/riscv/sys_lseek.c | 2 +- libgloss/riscv/sys_lstat.c | 2 +- libgloss/riscv/sys_open.c | 2 +- libgloss/riscv/sys_openat.c | 2 +- libgloss/riscv/sys_read.c | 2 +- libgloss/riscv/sys_sbrk.c | 4 +-- libgloss/riscv/sys_stat.c | 2 +- libgloss/riscv/sys_unlink.c | 2 +- libgloss/riscv/sys_write.c | 2 +- 18 files changed, 48 insertions(+), 29 deletions(-) -- 2.24.1