diff options
author | Dimitar Dimitrov <dimitar@dinux.eu> | 2022-04-03 21:57:39 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2022-04-27 11:43:08 +0200 |
commit | 21f0edbf9f0efd3d96a83191630eac0eb52726d2 (patch) | |
tree | b492e3b3f887bf4256939c0c37946a8fea6f2099 | |
parent | 23a3ec33928b780981626721c93a4f1fcb92bf02 (diff) | |
download | newlib-21f0edbf9f0efd3d96a83191630eac0eb52726d2.zip newlib-21f0edbf9f0efd3d96a83191630eac0eb52726d2.tar.gz newlib-21f0edbf9f0efd3d96a83191630eac0eb52726d2.tar.bz2 |
libgloss: pru: Fix _open syscal arguments
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 <dimitar@dinux.eu>
-rw-r--r-- | libgloss/pru/syscalls.S | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libgloss/pru/syscalls.S b/libgloss/pru/syscalls.S index 252231e..80486d1 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 |