public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Only pass the minimum number of syscall arguments (RISC-V)
@ 2020-02-10 20:20 Georg Sauthoff
  2020-02-10 20:20 ` [PATCH 1/1] Only pass the minimum number of syscall arguments Georg Sauthoff
  2020-02-11  8:43 ` [PATCH 0/1] Only pass the minimum number of syscall arguments (RISC-V) Corinna Vinschen
  0 siblings, 2 replies; 4+ messages in thread
From: Georg Sauthoff @ 2020-02-10 20:20 UTC (permalink / raw)
  To: newlib; +Cc: Georg Sauthoff

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-11  8:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-10 20:20 [PATCH 0/1] Only pass the minimum number of syscall arguments (RISC-V) Georg Sauthoff
2020-02-10 20:20 ` [PATCH 1/1] Only pass the minimum number of syscall arguments Georg Sauthoff
2020-02-11  6:55   ` Kito Cheng
2020-02-11  8:43 ` [PATCH 0/1] Only pass the minimum number of syscall arguments (RISC-V) Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).