Blame SOURCES/glibc-aarch64-syscall-rewrite.patch

5de29b
From 9a7cb556eef7cb75b31d0bc05f73c6338dfd8e49 Mon Sep 17 00:00:00 2001
5de29b
From: Richard Henderson <rth@redhat.com>
5de29b
Date: Fri, 30 May 2014 13:57:04 -0400
5de29b
Subject: [PATCH] aarch64: Backport syscall rewrite
5de29b
5de29b
From commits:
5de29b
a60339aaff82beadea6f580e587d64052cb5e3b8 Fix handling of nocancel syscall...
5de29b
3612eb8f25d978e7e4ac536a34098091f737161c Merge rtld_errno offset w/ mem ref
5de29b
a6b3657be6bc5067aeec98d990f60765361c6557 Merge __local_multiple_threads ofs...
5de29b
c69abcee726a6f63d9e5e8f0d9dcc79374ee3ef8 Fix DO_CALL block comment
5de29b
6e6c2d01ebb1ef839675c7151d2a114f53663386 Remove DOARGS/UNDOARGS macros
5de29b
ca3cfa40c16ef34c74951a07a57cfcbcd58898b1 Tidy syscall error check
5de29b
af4e8ef9443e258ebeb0ddf3c5c9579f24dfacd5 Tabify sysdep-cancel.h
5de29b
a8b4f04ad7dff4f39797a7ab7f8babda54266026 Share code in sysdep-cancel.h
5de29b
645d44abe3ca6253a9d4762f092e4a1b9d294b11 Pass regno parameter to SINGLE_THREAD_P
5de29b
b5be4597716eff94149f5529c8eb2cd3b4296188 Improve syscall-cancel stack frame
5de29b
74f31c18593111725478a991b395ae45661985a3 Fix error return from __ioctl
5de29b
f0712b543eaddeca8fc6d7a8eb6b5b8d24105ce2 Remove PSEUDO_RET
5de29b
5de29b
And a not-yet-committed cleanup to clone.S.
5de29b
---
5de29b
 ports/sysdeps/unix/sysv/linux/aarch64/clone.S      |  51 +++---
5de29b
 ports/sysdeps/unix/sysv/linux/aarch64/ioctl.S      |  13 +-
5de29b
 .../unix/sysv/linux/aarch64/nptl/localplt.data     |   1 -
5de29b
 .../unix/sysv/linux/aarch64/nptl/sysdep-cancel.h   | 189 +++++++--------------
5de29b
 ports/sysdeps/unix/sysv/linux/aarch64/syscall.S    |   4 +-
5de29b
 ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h     |  84 ++-------
5de29b
 ports/sysdeps/unix/sysv/linux/aarch64/vfork.S      |   4 +-
5de29b
 7 files changed, 108 insertions(+), 238 deletions(-)
5de29b
12745e
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/clone.S glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/clone.S
5de29b
index 8be1464..d5c31f3 100644
12745e
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/clone.S
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/clone.S
5de29b
@@ -39,46 +39,43 @@
5de29b
  */
5de29b
         .text
5de29b
 ENTRY(__clone)
5de29b
+	/* Save args for the child.  */
5de29b
+	mov	x10, x0
5de29b
+	mov	x11, x2
5de29b
+	mov	x12, x3
5de29b
+	
5de29b
 	/* Sanity check args.  */
5de29b
-	cbz	x0, 1f
5de29b
-	cbz	x1, 1f
5de29b
-	/* Insert the args onto the new stack.  */
5de29b
-	stp	x0, x3, [x1, #-16]!	/* Fn, arg.  */
5de29b
+	mov	x0, #-EINVAL
5de29b
+	cbz	x10, .Lsyscall_error
5de29b
+	cbz	x1, .Lsyscall_error
5de29b
 
5de29b
 	/* Do the system call.  */
5de29b
+	/* X0:flags, x1:newsp, x2:parenttidptr, x3:newtls, x4:childtid.  */
5de29b
 	mov	x0, x2                  /* flags  */
5de29b
-
5de29b
 	/* New sp is already in x1.  */
5de29b
 	mov	x2, x4			/* ptid  */
5de29b
 	mov	x3, x5			/* tls  */
5de29b
 	mov	x4, x6			/* ctid  */
5de29b
 
5de29b
-#ifdef RESET_PID
5de29b
-	/* We rely on the kernel preserving the argument regsiters across a
5de29b
-	   each system call so that we can inspect the flags against after
5de29b
-	   the clone call.  */
5de29b
-	mov	x5, x0
5de29b
-#endif
5de29b
-
5de29b
 	mov	x8, #SYS_ify(clone)
5de29b
-	/* X0:flags, x1:newsp, x2:parenttidptr, x3:newtls, x4:childtid.  */
5de29b
 	svc	0x0
5de29b
-	cfi_endproc
5de29b
 	cmp	x0, #0
5de29b
-	beq	2f
5de29b
-	blt	C_SYMBOL_NAME(__syscall_error)
5de29b
+	beq	thread_start
5de29b
+	blt	.Lsyscall_error
5de29b
 	RET
5de29b
-1:	mov	x0, #-EINVAL
5de29b
-	b	syscall_error
5de29b
+PSEUDO_END (__clone)
5de29b
 
5de29b
-2:
5de29b
+	.align	4
5de29b
+	.type	thread_start, %function
5de29b
+thread_start:
5de29b
 	cfi_startproc
5de29b
 	cfi_undefined (x30)
5de29b
 	mov	x29, 0
5de29b
+
5de29b
 #ifdef RESET_PID
5de29b
-	tbnz	x5, #CLONE_THREAD_BIT, 3f
5de29b
+	tbnz	x11, #CLONE_THREAD_BIT, 3f
5de29b
 	mov	x0, #-1
5de29b
-	tbnz	x5, #CLONE_VM_BIT, 2f
5de29b
+	tbnz	x11, #CLONE_VM_BIT, 2f
5de29b
 	mov	x8, #SYS_ify(getpid)
5de29b
 	svc	0x0
5de29b
 2:
5de29b
@@ -86,18 +83,16 @@ ENTRY(__clone)
5de29b
 	sub	x1, x1, #PTHREAD_SIZEOF
5de29b
 	str	w0, [x1, #PTHREAD_PID_OFFSET]
5de29b
 	str	w0, [x1, #PTHREAD_TID_OFFSET]
5de29b
-
5de29b
 3:
5de29b
 #endif
5de29b
-	/* Pick the function arg and call address from the stack and
5de29b
-	   execute.  */
5de29b
-	ldp	x1, x0, [sp], #16
5de29b
-	blr	x1
5de29b
+
5de29b
+	/* Pick the function arg execute.  */
5de29b
+	mov	x0, x12
5de29b
+	blr	x10
5de29b
 
5de29b
 	/* We are done, pass the return value through x0.  */
5de29b
 	b	HIDDEN_JUMPTARGET(_exit)
5de29b
 	cfi_endproc
5de29b
-	cfi_startproc
5de29b
-PSEUDO_END (__clone)
5de29b
+	.size	thread_start, .-thread_start
5de29b
 
5de29b
 weak_alias (__clone, clone)
12745e
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/ioctl.S glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/ioctl.S
5de29b
index f01fb84..be6c026 100644
12745e
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/ioctl.S
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/ioctl.S
5de29b
@@ -20,13 +20,12 @@
5de29b
 
5de29b
 	.text
5de29b
 ENTRY(__ioctl)
5de29b
-	movz	x8, #__NR_ioctl
5de29b
-        sxtw	x0, w0
5de29b
-        svc	#0x0
5de29b
-	cmn	x0, #0x1, lsl #12
5de29b
-	b.hi	C_SYMBOL_NAME(__syscall_error)
5de29b
+	mov	x8, #__NR_ioctl
5de29b
+	sxtw	x0, w0
5de29b
+	svc	#0x0
5de29b
+	cmn	x0, #4095
5de29b
+	b.cs	.Lsyscall_error
5de29b
 	ret
5de29b
-
5de29b
-	PSEUDO_END (__ioctl)
5de29b
+PSEUDO_END (__ioctl)
5de29b
 
5de29b
 weak_alias (__ioctl, ioctl)
12745e
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/localplt.data glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/localplt.data
5de29b
index 84af95d..dfca9a7 100644
12745e
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/localplt.data
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/localplt.data
5de29b
@@ -12,4 +12,3 @@ libm.so: matherr
5de29b
 libm.so: __signbit
5de29b
 libm.so: __signbitf
5de29b
 libm.so: __signbitl
5de29b
-libpthread.so: __errno_location
12745e
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
5de29b
index e0e5cc0..a3b9284 100644
12745e
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/sysdep-cancel.h
5de29b
@@ -26,119 +26,60 @@
5de29b
 
5de29b
 # undef PSEUDO
5de29b
 # define PSEUDO(name, syscall_name, args)				\
5de29b
-  .section ".text";							\
5de29b
-  .type __##syscall_name##_nocancel,%function;				\
5de29b
-  .globl __##syscall_name##_nocancel;					\
5de29b
-  __##syscall_name##_nocancel:						\
5de29b
-    cfi_startproc;							\
5de29b
-    DO_CALL (syscall_name, args);					\
5de29b
-    PSEUDO_RET;								\
5de29b
-    cfi_endproc;							\
5de29b
-    .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;	\
5de29b
-  ENTRY (name);								\
5de29b
-    SINGLE_THREAD_P;							\
5de29b
-    DOARGS_##args;							\
5de29b
-    bne .Lpseudo_cancel;						\
5de29b
-    DO_CALL (syscall_name, 0);						\
5de29b
-    UNDOARGS_##args;							\
5de29b
-    cmn x0, 4095;							\
5de29b
-    PSEUDO_RET;								\
5de29b
-  .Lpseudo_cancel:							\
5de29b
-    DOCARGS_##args;	/* save syscall args etc. around CENABLE.  */	\
5de29b
-    CENABLE;								\
5de29b
-    mov x16, x0;	/* put mask in safe place.  */			\
5de29b
-    UNDOCARGS_##args;	/* restore syscall args.  */			\
5de29b
-    mov x8, SYS_ify (syscall_name);	/* do the call.  */		\
5de29b
-    svc	0;								\
5de29b
-    str x0, [sp, -16]!;	/* save syscall return value.  */		\
5de29b
-    cfi_adjust_cfa_offset (16);						\
5de29b
-    mov x0, x16;	 /* get mask back.  */				\
5de29b
-    CDISABLE;								\
5de29b
-    ldr x0, [sp], 16;							\
5de29b
-    cfi_adjust_cfa_offset (-16);					\
5de29b
-    ldr x30, [sp], 16;							\
5de29b
-    cfi_adjust_cfa_offset (-16);					\
5de29b
-    cfi_restore (x30);							\
5de29b
-    UNDOARGS_##args;							\
5de29b
-    cmn x0, 4095;
5de29b
-
5de29b
-# define DOCARGS_0							\
5de29b
-	str x30, [sp, -16]!;						\
5de29b
-	cfi_adjust_cfa_offset (16);					\
5de29b
-	cfi_rel_offset (x30, 0)
5de29b
+	.section ".text";						\
5de29b
+ENTRY (__##syscall_name##_nocancel);					\
5de29b
+.Lpseudo_nocancel:							\
5de29b
+	DO_CALL (syscall_name, args);					\
5de29b
+.Lpseudo_finish:							\
5de29b
+	cmn	x0, 4095;						\
5de29b
+	b.cs	.Lsyscall_error;					\
5de29b
+	.subsection 2;							\
5de29b
+	.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
5de29b
+ENTRY (name);								\
5de29b
+	SINGLE_THREAD_P(16);						\
5de29b
+	cbz	w16, .Lpseudo_nocancel;					\
5de29b
+	/* Setup common stack frame no matter the number of args.	\
5de29b
+	   Also save the first arg, since it's basically free.  */	\
5de29b
+	stp	x30, x0, [sp, -64]!;					\
5de29b
+	cfi_adjust_cfa_offset (64);					\
5de29b
+	cfi_rel_offset (x30, 0);					\
5de29b
+	DOCARGS_##args;		/* save syscall args around CENABLE.  */ \
5de29b
+	CENABLE;							\
5de29b
+	mov	x16, x0;	/* save mask around syscall.  */	\
5de29b
+	UNDOCARGS_##args;	/* restore syscall args.  */		\
5de29b
+	DO_CALL (syscall_name, args);					\
5de29b
+	str	x0, [sp, 8];	/* save result around CDISABLE.  */	\
5de29b
+	mov	x0, x16;	/* restore mask for CDISABLE.  */	\
5de29b
+	CDISABLE;							\
5de29b
+	/* Break down the stack frame, restoring result at once.  */	\
5de29b
+	ldp	x30, x0, [sp], 64;					\
5de29b
+	cfi_adjust_cfa_offset (-64);					\
5de29b
+	cfi_restore (x30);						\
5de29b
+	b	.Lpseudo_finish;					\
5de29b
+	cfi_endproc;							\
5de29b
+	.size	name, .-name;						\
5de29b
+	.previous
5de29b
+
5de29b
+# undef PSEUDO_END
5de29b
+# define PSEUDO_END(name)						\
5de29b
+	SYSCALL_ERROR_HANDLER;						\
5de29b
+	cfi_endproc
5de29b
+
5de29b
+# define DOCARGS_0
5de29b
+# define DOCARGS_1
5de29b
+# define DOCARGS_2	str x1, [sp, 16]
5de29b
+# define DOCARGS_3	stp x1, x2, [sp, 16]
5de29b
+# define DOCARGS_4	DOCARGS_3; str x3, [sp, 32]
5de29b
+# define DOCARGS_5	DOCARGS_3; stp x3, x4, [sp, 32]
5de29b
+# define DOCARGS_6	DOCARGS_5; str x5, [sp, 48]
5de29b
 
5de29b
 # define UNDOCARGS_0
5de29b
-
5de29b
-# define DOCARGS_1							\
5de29b
-	DOCARGS_0;							\
5de29b
-	str x0, [sp, -16]!;						\
5de29b
-	cfi_adjust_cfa_offset (16);					\
5de29b
-	cfi_rel_offset (x0, 0)
5de29b
-
5de29b
-# define UNDOCARGS_1							\
5de29b
-	ldr x0, [sp], 16;						\
5de29b
-	cfi_restore (x0);						\
5de29b
-	cfi_adjust_cfa_offset (-16);					\
5de29b
-
5de29b
-# define DOCARGS_2							\
5de29b
-	DOCARGS_1;							\
5de29b
-	str x1, [sp, -16]!;						\
5de29b
-	cfi_adjust_cfa_offset (16);					\
5de29b
-	cfi_rel_offset (x1, 0)
5de29b
-
5de29b
-# define UNDOCARGS_2							\
5de29b
-	ldr x1, [sp], 16;						\
5de29b
-	cfi_restore (x1);						\
5de29b
-	cfi_adjust_cfa_offset (-16);					\
5de29b
-	UNDOCARGS_1
5de29b
-
5de29b
-# define DOCARGS_3							\
5de29b
-	DOCARGS_2;							\
5de29b
-	str x2, [sp, -16]!;						\
5de29b
-	cfi_adjust_cfa_offset (16);					\
5de29b
-	cfi_rel_offset (x2, 0)
5de29b
-
5de29b
-# define UNDOCARGS_3							\
5de29b
-	ldr x2, [sp], 16;						\
5de29b
-	cfi_restore (x2);						\
5de29b
-	cfi_adjust_cfa_offset (-16);					\
5de29b
-	UNDOCARGS_2
5de29b
-
5de29b
-# define DOCARGS_4							\
5de29b
-	DOCARGS_3;							\
5de29b
-	str x3, [sp, -16]!;						\
5de29b
-	cfi_adjust_cfa_offset (16);					\
5de29b
-	cfi_rel_offset (x3, 0)
5de29b
-
5de29b
-# define UNDOCARGS_4							\
5de29b
-	ldr x3, [sp], 16;						\
5de29b
-	cfi_restore (x3);						\
5de29b
-	cfi_adjust_cfa_offset (-16);					\
5de29b
-	UNDOCARGS_3
5de29b
-
5de29b
-# define DOCARGS_5							\
5de29b
-	DOCARGS_4;							\
5de29b
-	str x4, [sp, -16]!;						\
5de29b
-	cfi_adjust_cfa_offset (16);					\
5de29b
-	cfi_rel_offset (x4, 0)
5de29b
-
5de29b
-# define UNDOCARGS_5							\
5de29b
-	ldr x4, [sp], 16;						\
5de29b
-	cfi_restore (x4);						\
5de29b
-	cfi_adjust_cfa_offset (-16);					\
5de29b
-	UNDOCARGS_4
5de29b
-
5de29b
-# define DOCARGS_6							\
5de29b
-	DOCARGS_5;							\
5de29b
-	str x5, [sp, -16]!;						\
5de29b
-	cfi_adjust_cfa_offset (16);					\
5de29b
-	cfi_rel_offset (x5, 0)
5de29b
-
5de29b
-# define UNDOCARGS_6							\
5de29b
-	ldr x5, [sp], 16;						\
5de29b
-	cfi_restore (x5);						\
5de29b
-	cfi_adjust_cfa_offset (-16);					\
5de29b
-	UNDOCARGS_5
5de29b
+# define UNDOCARGS_1	ldr x0, [sp, 8]
5de29b
+# define UNDOCARGS_2	ldp x0, x1, [sp, 8]
5de29b
+# define UNDOCARGS_3	UNDOCARGS_1; ldp x1, x2, [sp, 16]
5de29b
+# define UNDOCARGS_4	UNDOCARGS_2; ldp x2, x3, [sp, 24]
5de29b
+# define UNDOCARGS_5	UNDOCARGS_3; ldp x3, x4, [sp, 32]
5de29b
+# define UNDOCARGS_6	UNDOCARGS_4; ldp x4, x5, [sp, 40]
5de29b
 
5de29b
 # ifdef IS_IN_libpthread
5de29b
 #  define CENABLE	bl __pthread_enable_asynccancel
5de29b
@@ -160,11 +101,9 @@
5de29b
 extern int __local_multiple_threads attribute_hidden;
5de29b
 #   define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
5de29b
 #  else
5de29b
-#   define SINGLE_THREAD_P						\
5de29b
-  adrp	x16, __local_multiple_threads;					\
5de29b
-  add	x16, x16, #:lo12:__local_multiple_threads;			\
5de29b
-  ldr	x16, [x16];							\
5de29b
-  cmp	x16, 0;
5de29b
+#   define SINGLE_THREAD_P(R)						\
5de29b
+	adrp	x##R, __local_multiple_threads;				\
5de29b
+	ldr	w##R, [x##R, :lo12:__local_multiple_threads]
5de29b
 #  endif
5de29b
 # else
5de29b
 /*  There is no __local_multiple_threads for librt, so use the TCB.  */
5de29b
@@ -173,20 +112,10 @@ extern int __local_multiple_threads attribute_hidden;
5de29b
   __builtin_expect (THREAD_GETMEM (THREAD_SELF,				\
5de29b
 				   header.multiple_threads) == 0, 1)
5de29b
 #  else
5de29b
-#   define SINGLE_THREAD_P						\
5de29b
-  stp	x0, x30, [sp, -16]!;						\
5de29b
-  cfi_adjust_cfa_offset (16);						\
5de29b
-  cfi_rel_offset (x0, 0);						\
5de29b
-  cfi_rel_offset (x30, 8);						\
5de29b
-  bl	__read_tp;							\
5de29b
-  sub	x0, x0, PTHREAD_SIZEOF;						\
5de29b
-  ldr	x16, [x0, PTHREAD_MULTIPLE_THREADS_OFFSET];			\
5de29b
-  ldp	x0, x30, [sp], 16;						\
5de29b
-  cfi_restore (x0);							\
5de29b
-  cfi_restore (x30);							\
5de29b
-  cfi_adjust_cfa_offset (-16);						\
5de29b
-  cmp	x16, 0
5de29b
-#   define SINGLE_THREAD_P_PIC(x) SINGLE_THREAD_P
5de29b
+#   define SINGLE_THREAD_P(R)						\
5de29b
+	mrs	x##R, tpidr_el0;					\
5de29b
+	sub	x##R, x##R, PTHREAD_SIZEOF;				\
5de29b
+	ldr	w##R, [x##R, PTHREAD_MULTIPLE_THREADS_OFFSET]
5de29b
 #  endif
5de29b
 # endif
5de29b
 
12745e
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/syscall.S glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/syscall.S
5de29b
index 574fdf1..fac6416 100644
12745e
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/syscall.S
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/syscall.S
5de29b
@@ -37,8 +37,6 @@ ENTRY (syscall)
5de29b
 	mov	x6, x7
5de29b
 	svc	0x0
5de29b
 	cmn	x0, #4095
5de29b
-	b.cs	1f
5de29b
+	b.cs	.Lsyscall_error
5de29b
 	RET
5de29b
-1:
5de29b
-	b	SYSCALL_ERROR
5de29b
 PSEUDO_END (syscall)
12745e
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
5de29b
index 713bf7d..9961c03 100644
12745e
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/sysdep.h
5de29b
@@ -58,19 +58,8 @@
5de29b
   .text;								      \
5de29b
   ENTRY (name);								      \
5de29b
     DO_CALL (syscall_name, args);					      \
5de29b
-    cmn x0, #4095;
5de29b
-
5de29b
-/* Notice the use of 'RET' instead of 'ret' the assembler is case
5de29b
-   insensitive and eglibc already uses the preprocessor symbol 'ret'
5de29b
-   so we use the upper case 'RET' to force through a ret instruction
5de29b
-   to the assembler */
5de29b
-# define PSEUDO_RET							      \
5de29b
-    b.cs 1f;								      \
5de29b
-    RET;								      \
5de29b
-    1:                                                                        \
5de29b
-    b SYSCALL_ERROR
5de29b
-# undef ret
5de29b
-# define ret PSEUDO_RET
5de29b
+    cmn x0, #4095;							      \
5de29b
+    b.cs .Lsyscall_error
5de29b
 
5de29b
 # undef	PSEUDO_END
5de29b
 # define PSEUDO_END(name)						      \
5de29b
@@ -83,15 +72,7 @@
5de29b
   ENTRY (name);								      \
5de29b
     DO_CALL (syscall_name, args);
5de29b
 
5de29b
-/* Notice the use of 'RET' instead of 'ret' the assembler is case
5de29b
-   insensitive and eglibc already uses the preprocessor symbol 'ret'
5de29b
-   so we use the upper case 'RET' to force through a ret instruction
5de29b
-   to the assembler */
5de29b
-# define PSEUDO_RET_NOERRNO						      \
5de29b
-    RET;
5de29b
-
5de29b
-# undef ret_NOERRNO
5de29b
-# define ret_NOERRNO PSEUDO_RET_NOERRNO
5de29b
+# define ret_NOERRNO ret
5de29b
 
5de29b
 # undef	PSEUDO_END_NOERRNO
5de29b
 # define PSEUDO_END_NOERRNO(name)					      \
5de29b
@@ -109,47 +90,38 @@
5de29b
 # define PSEUDO_END_ERRVAL(name) \
5de29b
   END (name)
5de29b
 
5de29b
-# define ret_ERRVAL PSEUDO_RET_NOERRNO
5de29b
+# define ret_ERRVAL ret
5de29b
 
5de29b
+# define SYSCALL_ERROR  .Lsyscall_error
5de29b
 # if NOT_IN_libc
5de29b
-#  define SYSCALL_ERROR __local_syscall_error
5de29b
 #  if RTLD_PRIVATE_ERRNO
5de29b
 #   define SYSCALL_ERROR_HANDLER				\
5de29b
-__local_syscall_error:						\
5de29b
+.Lsyscall_error:						\
5de29b
 	adrp	x1, C_SYMBOL_NAME(rtld_errno);			\
5de29b
-	add	x1, x1, #:lo12:C_SYMBOL_NAME(rtld_errno);	\
5de29b
 	neg     w0, w0;						\
5de29b
-	str     w0, [x1];					\
5de29b
+	str     w0, [x1, :lo12:C_SYMBOL_NAME(rtld_errno)];	\
5de29b
 	mov	x0, -1;						\
5de29b
 	RET;
5de29b
 #  else
5de29b
 
5de29b
 #   define SYSCALL_ERROR_HANDLER				\
5de29b
-__local_syscall_error:						\
5de29b
-	stp     x29, x30, [sp, -32]!;				\
5de29b
-	cfi_adjust_cfa_offset (32);				\
5de29b
-	cfi_rel_offset (x29, 0);				\
5de29b
-	cfi_rel_offset (x30, 8);				\
5de29b
-        add     x29, sp, 0;					\
5de29b
-        str     x19, [sp,16];					\
5de29b
-	neg	x19, x0;					\
5de29b
-	bl	C_SYMBOL_NAME(__errno_location);		\
5de29b
-	str	x19, [x0];					\
5de29b
+.Lsyscall_error:						\
5de29b
+	adrp	x1, :gottprel:errno;				\
5de29b
+	neg	w2, w0;						\
5de29b
+	ldr	x1, [x1, :gottprel_lo12:errno];			\
5de29b
+	mrs	x3, tpidr_el0;					\
5de29b
 	mov	x0, -1;						\
5de29b
-        ldr     x19, [sp,16];					\
5de29b
-        ldp     x29, x30, [sp], 32;				\
5de29b
-	cfi_adjust_cfa_offset (-32);				\
5de29b
-	cfi_restore (x29);					\
5de29b
-	cfi_restore (x30);					\
5de29b
+	str	w2, [x1, x3];					\
5de29b
 	RET;
5de29b
 #  endif
5de29b
 # else
5de29b
-#  define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
5de29b
-#  define SYSCALL_ERROR __syscall_error
5de29b
+#  define SYSCALL_ERROR_HANDLER					\
5de29b
+.Lsyscall_error:						\
5de29b
+	b	__syscall_error;
5de29b
 # endif
5de29b
 
5de29b
 /* Linux takes system call args in registers:
5de29b
-	syscall number	in the SVC instruction
5de29b
+	syscall number	x8
5de29b
 	arg 1		x0
5de29b
 	arg 2		x1
5de29b
 	arg 3		x2
5de29b
@@ -177,28 +149,8 @@ __local_syscall_error:						\
5de29b
 
5de29b
 # undef	DO_CALL
5de29b
 # define DO_CALL(syscall_name, args)		\
5de29b
-    DOARGS_##args				\
5de29b
     mov x8, SYS_ify (syscall_name);		\
5de29b
-    svc 0;					\
5de29b
-    UNDOARGS_##args
5de29b
-
5de29b
-# define DOARGS_0 /* nothing */
5de29b
-# define DOARGS_1 /* nothing */
5de29b
-# define DOARGS_2 /* nothing */
5de29b
-# define DOARGS_3 /* nothing */
5de29b
-# define DOARGS_4 /* nothing */
5de29b
-# define DOARGS_5 /* nothing */
5de29b
-# define DOARGS_6 /* nothing */
5de29b
-# define DOARGS_7 /* nothing */
5de29b
-
5de29b
-# define UNDOARGS_0 /* nothing */
5de29b
-# define UNDOARGS_1 /* nothing */
5de29b
-# define UNDOARGS_2 /* nothing */
5de29b
-# define UNDOARGS_3 /* nothing */
5de29b
-# define UNDOARGS_4 /* nothing */
5de29b
-# define UNDOARGS_5 /* nothing */
5de29b
-# define UNDOARGS_6 /* nothing */
5de29b
-# define UNDOARGS_7 /* nothing */
5de29b
+    svc 0
5de29b
 
5de29b
 #else /* not __ASSEMBLER__ */
5de29b
 
12745e
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/vfork.S glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/vfork.S
5de29b
index f2dc49b..3fb68b9 100644
12745e
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/vfork.S
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/vfork.S
5de29b
@@ -38,10 +38,8 @@ ENTRY (__vfork)
5de29b
 	RESTORE_PID
5de29b
 #endif
5de29b
 	cmn	x0, #4095
5de29b
-	b.cs    1f
5de29b
+	b.cs    .Lsyscall_error
5de29b
 	RET
5de29b
-1:
5de29b
-	b	SYSCALL_ERROR
5de29b
 
5de29b
 PSEUDO_END (__vfork)
5de29b
 libc_hidden_def (__vfork)
5de29b
-- 
5de29b
1.8.3.1
5de29b