* Thorsten Glaser <[email protected]>:
> > So, instead of adding and ifdef for hppa/syscall6_weak, simply
> > drop the weak function and call the normal __unified_syscall6.
> 
> Looking at the nm output of libc.a, it seems to use the 6 version
> for sendto but not recvfrom. Huh.
> 
> Maybe other 5/6-argument syscalls also need review…

Yes, and basically I tink it's stupid to try to distinguish syscalls
with 1-4 arguments from those which use 5 or 6 arguments.
With every added syscall someone needs to check again.

The patch below takes a much easier way. It simply pre-loads
the registers for the 5th and 6th arguement on every syscall,
independend if the syscalls has more than 4 arguments.
That way we don't need to distinguish and it will always work.
The downside is some small overhead for every syscall, but I
think this is neglectable.

The patch below worked for me.
Maybe you can apply it?
(btw, upstream dietlibc is dead?)

Helge

---

[PATCH] dietlibc/hppa: Always load registers for arg4 and arg5 syscall arguments

Signed-off-by: Helge Deller <[email protected]>

diff -up ./parisc/__getsockopt.S.org ./parisc/__getsockopt.S
--- ./parisc/__getsockopt.S.org 2024-07-09 11:05:53.892000000 +0000
+++ ./parisc/__getsockopt.S     2024-07-09 11:06:03.020000000 +0000
@@ -1,3 +1,3 @@
 #include "syscalls.h"
 
-syscall5_weak(getsockopt, getsockopt, __libc_getsockopt);
+syscall_weak(getsockopt, getsockopt, __libc_getsockopt);
diff -up ./parisc/__sendto.S.org ./parisc/__sendto.S
--- ./parisc/__sendto.S.org     2024-07-09 11:02:07.400000000 +0000
+++ ./parisc/__sendto.S 2024-07-09 11:02:16.324000000 +0000
@@ -1,3 +1,3 @@
 #include "syscalls.h"
 
-syscall6_weak(sendto, sendto, __libc_sendto);
+syscall_weak(sendto, sendto, __libc_sendto);
diff -up ./parisc/__setsockopt.S.org ./parisc/__setsockopt.S
--- ./parisc/__setsockopt.S.org 2024-07-09 11:09:10.900000000 +0000
+++ ./parisc/__setsockopt.S     2024-07-09 11:09:16.592000000 +0000
@@ -1,3 +1,3 @@
 #include "syscalls.h"
 
-syscall5_weak(setsockopt, setsockopt, __libc_setsockopt);
+syscall_weak(setsockopt, setsockopt, __libc_setsockopt);
diff -up ./parisc/_llseek.S.org ./parisc/_llseek.S
--- ./parisc/_llseek.S.org      2024-07-09 11:06:48.796000000 +0000
+++ ./parisc/_llseek.S  2024-07-09 11:06:58.424000000 +0000
@@ -1,3 +1,3 @@
 #include "syscalls.h"
 
-syscall5(llseek, llseek);
+syscall(llseek, llseek);
diff -up ./parisc/mmap.S.org ./parisc/mmap.S
--- ./parisc/mmap.S.org 2024-07-09 11:00:01.380000000 +0000
+++ ./parisc/mmap.S     2024-07-09 11:00:19.204000000 +0000
@@ -1,3 +1,3 @@
 #include "syscalls.h"
 
-syscall6(mmap, mmap);
+syscall(mmap, mmap);
diff -up ./parisc/mmap2.S.org ./parisc/mmap2.S
--- ./parisc/mmap2.S.org        2024-07-09 11:00:09.464000000 +0000
+++ ./parisc/mmap2.S    2024-07-09 11:00:27.452000000 +0000
@@ -1,6 +1,6 @@
 #include "syscalls.h"
 
 #ifdef __NR_mmap2
-syscall6(mmap2,__mmap2)
+syscall(mmap2,__mmap2)
 #endif
 
diff -up ./parisc/mount.S.org ./parisc/mount.S
--- ./parisc/mount.S.org        2024-07-09 11:07:19.104000000 +0000
+++ ./parisc/mount.S    2024-07-09 11:07:59.432000000 +0000
@@ -1,3 +1,3 @@
 #include "syscalls.h"
 
-syscall5(mount, mount);
+syscall(mount, mount);
diff -up ./parisc/parisc_fadvise.S.org ./parisc/parisc_fadvise.S
--- ./parisc/parisc_fadvise.S.org       2024-07-09 11:02:33.032000000 +0000
+++ ./parisc/parisc_fadvise.S   2024-07-09 11:02:41.516000000 +0000
@@ -1,5 +1,5 @@
 #include "syscalls.h"
 
 #ifdef __NR_parisc_fadvise64_64
-syscall6(parisc_fadvise64_64, __parisc_fadvise64_64);
+syscall(parisc_fadvise64_64, __parisc_fadvise64_64);
 #endif
diff -up ./parisc/recvfrom.S.org ./parisc/recvfrom.S
--- ./parisc/recvfrom.S.org     2024-07-09 11:02:58.844000000 +0000
+++ ./parisc/recvfrom.S 2024-07-09 11:03:06.612000000 +0000
@@ -1,3 +1,3 @@
 #include "syscalls.h"
 
-syscall6(recvfrom, recvfrom);
+syscall(recvfrom, recvfrom);
diff -up ./parisc/syscalls.h.org ./parisc/syscalls.h
diff -up ./parisc/unified.S.org ./parisc/unified.S
--- ./parisc/unified.S.org      2024-07-09 10:44:24.784000000 +0000
+++ ./parisc/unified.S  2024-07-09 11:49:41.464000000 +0000
@@ -21,14 +21,6 @@
 .global __unified_syscall
 .type __unified_syscall,@function
 
-.export __unified_syscall5
-.global __unified_syscall5
-.type __unified_syscall5,@function
-
-.export __unified_syscall6
-.global __unified_syscall6
-.type __unified_syscall6,@function
-
 .export __error_unified_syscall
 .global __error_unified_syscall
 
@@ -38,16 +30,32 @@
 _exit:
 exit:
         ldi 1, %r20
-       b __unified_syscall
-       nop
+       /* fall through */
 
-__unified_syscall6:
-       ldw -0x38(%sp), %r21
-__unified_syscall5:
-       ldw -0x34(%sp), %r22
 __unified_syscall:
+#ifndef __LP64__
+       /* 32bit: arg4 and arg5 are stored on stack */
+       stw %rp,-0x14(%sp)
+       ldo 0x40(%sp),%sp
+
+       /* save %r21 and %r22 on new stack */
+       stw %r21, -0x38(%sp)
+       stw %r22, -0x34(%sp)
+
+       /* get %r21 and %r22 from stack and do syscall */
+       ldw -0x38-0x40(%sp), %r21
+       be,l 0x100(%sr2, %r0), %sr0, %r31
+       ldw -0x34-0x40(%sp), %r22
+
+       /* restore original %r21 and %r22 */
+       stw %r21, -0x38(%sp)
+       stw %r22, -0x34(%sp)
+       ldo -0x40(%sp),%sp
+#else
+       /* 64bit: no need to get arg4 and arg5 from stack */
        be,l 0x100(%sr2, %r0), %sr0, %r31
        nop
+#endif
        ldi -0x100, %r1
        cmpb,>>=,n %r1, %ret0, .Lnoerr
        sub %r0, %ret0, %ret0

Reply via email to