diff mbox series

[v2,11/23] linux: Use generic __syscall_error for arm

Message ID 20201113165837.121629-12-adhemerval.zanella@linaro.org
State New
Headers show
Series Simplify internal Linux syscall | expand

Commit Message

Adhemerval Zanella Nov. 13, 2020, 4:58 p.m. UTC
The auto-generated syscalls issue the __syscall_erro and the ARM
resulting binary using inline __syscall_error results in a large
code size:
diff mbox series

Patch

--- sizes-arm-linux-gnueabihf.outline
+++ sizes-arm-linux-gnueabihf.inline
@@ -1,5 +1,5 @@ 
    text           data     bss     dec     hex filename
-1260061           9912    9256 1279229  1384fd libc.so
- 143107           4336     208  147651   240c3 elf/ld.so
-  97335            844    8352  106531   1a023 nptl/libpthread.so
-  22516            656     160   23332    5b24 rt/librt.so
+1265565           9912    9256 1284733  139a7d libc.so
+ 143491           4336     208  148035   24243 elf/ld.so
+  98103            844    8352  107299   1a323 nptl/libpthread.so
+  22996            656     160   23812    5d04 rt/librt.so

The assembly sysdep.S is replaced the by the generic syscall_error.c.

Checked on arm-linux-gnueabihf.
---
 sysdeps/unix/arm/sysdep.S                     | 62 -------------------
 .../linux/arm/{sysdep.S => syscall_error.h}   | 24 +++----
 2 files changed, 8 insertions(+), 78 deletions(-)
 delete mode 100644 sysdeps/unix/arm/sysdep.S
 rename sysdeps/unix/sysv/linux/arm/{sysdep.S => syscall_error.h} (55%)

diff --git a/sysdeps/unix/arm/sysdep.S b/sysdeps/unix/arm/sysdep.S
deleted file mode 100644
index 5c9022a869..0000000000
--- a/sysdeps/unix/arm/sysdep.S
+++ /dev/null
@@ -1,62 +0,0 @@ 
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <errno.h>
-
-#if IS_IN (rtld)
-# include <dl-sysdep.h>			/* Defines RTLD_PRIVATE_ERRNO.  */
-#endif
-
-#include <tls.h>
-
-#undef syscall_error
-__syscall_error:
-#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
-	/* We translate the system's EWOULDBLOCK error into EAGAIN.
-	   The GNU C library always defines EWOULDBLOCK==EAGAIN.
-	   EWOULDBLOCK_sys is the original number.  */
-	cmp	r0, $EWOULDBLOCK_sys /* Is it the old EWOULDBLOCK?  */
-	it	eq
-	moveq	r0, $EAGAIN	/* Yes; translate it to EAGAIN.  */
-#endif
-
-#if !IS_IN (rtld)
-	mov	r1, r0
-	GET_TLS (r2)
-	ldr	r2, 1f
-#ifdef __thumb__
-2:	add	r2, r2, pc
-	ldr	r2, [r2]
-#else
-2:	ldr	r2, [pc, r2]
-#endif
-	str	r1, [r0, r2]
-	mvn	r0, #0
-	DO_RET(lr)
-
-1:	.word errno(gottpoff) + (. - 2b - PC_OFS)
-#elif RTLD_PRIVATE_ERRNO
-	LDST_PCREL(str, r0, r1, C_SYMBOL_NAME(rtld_errno))
-	mvn	r0, #0
-	DO_RET(r14)
-#else
-#error "Unsupported non-TLS case"
-#endif
-
-#undef	__syscall_error
-END (__syscall_error)
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.S b/sysdeps/unix/sysv/linux/arm/syscall_error.h
similarity index 55%
rename from sysdeps/unix/sysv/linux/arm/sysdep.S
rename to sysdeps/unix/sysv/linux/arm/syscall_error.h
index 94c877b31d..71f74e2bd3 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.S
+++ b/sysdeps/unix/sysv/linux/arm/syscall_error.h
@@ -1,4 +1,5 @@ 
-/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
+/* Linux wrappers for setting errno.  ARM version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -12,22 +13,13 @@ 
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
+   License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
 
-	.text
+#define SYSCALL_ERROR_FUNC        1
+#define SYSCALL_ERROR_FUNC_ATTR
 
-/* The syscall stubs jump here when they detect an error.
-   The code for Linux is almost identical to the canonical Unix
-   code, except that the error number in R0 is negated.  */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0.  */
-
-ENTRY (__syscall_error)
-	rsb r0, r0, $0
-
-#define __syscall_error __syscall_error_1
-#include <sysdeps/unix/arm/sysdep.S>
+#endif