2000-10-15 03:28:47 +00:00
|
|
|
/* Assembler macros for PA-RISC.
|
2020-01-01 00:14:33 +00:00
|
|
|
Copyright (C) 1999-2020 Free Software Foundation, Inc.
|
2000-10-15 03:28:47 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
|
|
|
|
Linux/PA-RISC changes by Philipp Rumpf, <prumpf@tux.org>, March 2000.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:56:23 +00:00
|
|
|
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.
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
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
|
2001-07-06 04:56:23 +00:00
|
|
|
Lesser General Public License for more details.
|
2000-10-15 03:28:47 +00:00
|
|
|
|
2001-07-06 04:56:23 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-03-09 23:56:38 +00:00
|
|
|
License along with the GNU C Library. If not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2000-10-15 03:28:47 +00:00
|
|
|
|
2015-07-30 02:55:43 +00:00
|
|
|
#ifndef _LINUX_HPPA_SYSDEP_H
|
|
|
|
#define _LINUX_HPPA_SYSDEP_H 1
|
|
|
|
|
|
|
|
#include <sysdeps/unix/sysdep.h>
|
Add INLINE_SYSCALL_ERROR_RETURN_VALUE
For ia32 PIC, the first thing of many syscalls does is to call
__x86.get_pc_thunk.reg to load PC into reg in case there is an error,
which is required for setting errno. In most cases, there are no
errors. But we still call __x86.get_pc_thunk.reg. This patch adds
INLINE_SYSCALL_ERROR_RETURN_VALUE so that i386 can optimize setting
errno by branching to the internal __syscall_error without PLT.
With i386 INLINE_SYSCALL_ERROR_RETURN_VALUE and i386 syscall inlining
optimization for GCC 5, for sysdeps/unix/sysv/linux/fchmodat.c with
-O2 -march=i686 -mtune=generic, GCC 5.2 now generates:
<fchmodat>:
0: push %ebx
1: mov 0x14(%esp),%eax
5: mov 0x8(%esp),%ebx
9: mov 0xc(%esp),%ecx
d: mov 0x10(%esp),%edx
11: test $0xfffffeff,%eax
16: jne 38 <fchmodat+0x38>
18: test $0x1,%ah
1b: jne 48 <fchmodat+0x48>
1d: mov $0x132,%eax
22: call *%gs:0x10
29: cmp $0xfffff000,%eax
2e: ja 58 <fchmodat+0x58>
30: pop %ebx
31: ret
32: lea 0x0(%esi),%esi
38: pop %ebx
39: mov $0xffffffea,%eax
3e: jmp 3f <fchmodat+0x3f> 3f: R_386_PC32 __syscall_error
43: nop
44: lea 0x0(%esi,%eiz,1),%esi
48: pop %ebx
49: mov $0xffffffa1,%eax
4e: jmp 4f <fchmodat+0x4f> 4f: R_386_PC32 __syscall_error
53: nop
54: lea 0x0(%esi,%eiz,1),%esi
58: pop %ebx
59: jmp 5a <fchmodat+0x5a> 5a: R_386_PC32 __syscall_error
instead of
<fchmodat>:
0: sub $0x8,%esp
3: mov 0x18(%esp),%eax
7: mov %ebx,(%esp)
a: call b <fchmodat+0xb> b: R_386_PC32 __x86.get_pc_thunk.bx
f: add $0x2,%ebx 11: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
15: mov %edi,0x4(%esp)
19: test $0xfffffeff,%eax
1e: jne 70 <fchmodat+0x70>
20: test $0x1,%ah
23: jne 88 <fchmodat+0x88>
25: mov 0x14(%esp),%edx
29: mov 0x10(%esp),%ecx
2d: mov 0xc(%esp),%edi
31: xchg %ebx,%edi
33: mov $0x132,%eax
38: call *%gs:0x10
3f: xchg %edi,%ebx
41: cmp $0xfffff000,%eax
46: ja 58 <fchmodat+0x58>
48: mov (%esp),%ebx
4b: mov 0x4(%esp),%edi
4f: add $0x8,%esp
52: ret
53: nop
54: lea 0x0(%esi,%eiz,1),%esi
58: mov 0x0(%ebx),%edx 5a: R_386_TLS_GOTIE __libc_errno
5e: neg %eax
60: mov %eax,%gs:(%edx)
63: mov $0xffffffff,%eax
68: jmp 48 <fchmodat+0x48>
6a: lea 0x0(%esi),%esi
70: mov 0x0(%ebx),%eax 72: R_386_TLS_GOTIE __libc_errno
76: movl $0x16,%gs:(%eax)
7d: mov $0xffffffff,%eax
82: jmp 48 <fchmodat+0x48>
84: lea 0x0(%esi,%eiz,1),%esi
88: mov 0x0(%ebx),%eax 8a: R_386_TLS_GOTIE __libc_errno
8e: movl $0x5f,%gs:(%eax)
95: mov $0xffffffff,%eax
9a: jmp 48 <fchmodat+0x48>
* sysdeps/unix/sysv/linux/sysdep.h: New file.
* sysdeps/unix/sysv/linux/i386/sysdep.c: Likewise.
* sysdeps/unix/sysv/linux/alpha/sysdep.h: Include
<sysdeps/unix/sysv/linux/sysdep.h>.
* sysdeps/unix/sysv/linux/arm/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/generic/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/m68k/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/microblaze/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/sh/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) == csu]
(sysdep-dl-routines): Add sysdep.
[$(subdir) == nptl] (libpthread-routines): Likewise.
[$(subdir) == rt] (librt-routines): Likewise.
* sysdeps/unix/sysv/linux/i386/clone.S (__clone): Don't check
PIC when branching to SYSCALL_ERROR_LABEL.
* sysdeps/unix/sysv/linux/i386/sysdep.S: Removed.
* sysdeps/unix/sysv/linux/i386/sysdep.h: Include
<sysdeps/unix/sysv/linux/sysdep.h>.
(SYSCALL_ERROR_LABEL): Changed to __syscall_error.
(SYSCALL_ERROR_ERRNO): Removed.
(SYSCALL_ERROR_HANDLER): Changed to empty.
(SYSCALL_ERROR_HANDLER_TLS_STORE): Likewise.
(__syscall_error): New prototype.
[IS_IN (libc)] (INLINE_SYSCALL): New macro.
(INLINE_SYSCALL_ERROR_RETURN_VALUE): Likewise.
2015-10-13 18:58:53 +00:00
|
|
|
#include <sysdeps/unix/sysv/linux/sysdep.h>
|
2015-07-30 02:55:43 +00:00
|
|
|
#include <sysdeps/hppa/sysdep.h>
|
2000-10-15 03:28:47 +00:00
|
|
|
|
2015-02-24 05:10:42 +00:00
|
|
|
/* Defines RTLD_PRIVATE_ERRNO. */
|
|
|
|
#include <dl-sysdep.h>
|
|
|
|
|
2020-02-04 13:29:04 +00:00
|
|
|
#include <tls.h>
|
|
|
|
|
2009-04-24 02:48:15 +00:00
|
|
|
/* In order to get __set_errno() definition in INLINE_SYSCALL. */
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
|
|
|
|
2006-05-15 00:44:14 +00:00
|
|
|
#undef ASM_LINE_SEP
|
2012-10-30 02:05:36 +00:00
|
|
|
#define ASM_LINE_SEP !
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
#undef SYS_ify
|
|
|
|
#define SYS_ify(syscall_name) (__NR_##syscall_name)
|
|
|
|
|
2012-10-30 03:16:44 +00:00
|
|
|
/* The vfork, fork, and clone syscalls clobber r19
|
|
|
|
* and r21. We list r21 as either clobbered or as an
|
|
|
|
* input to a 6-argument syscall. We must save and
|
|
|
|
* restore r19 in both PIC and non-PIC cases.
|
|
|
|
*/
|
2012-10-30 02:05:36 +00:00
|
|
|
/* WARNING: TREG must be a callee saves register so
|
|
|
|
that it doesn't have to be restored after a call
|
2006-05-15 00:44:14 +00:00
|
|
|
to another function */
|
2012-10-30 03:16:44 +00:00
|
|
|
#define TREG 4
|
|
|
|
#define SAVE_PIC(SREG) \
|
2017-07-16 15:58:01 +00:00
|
|
|
copy %r19, SREG
|
2012-10-30 03:16:44 +00:00
|
|
|
#define LOAD_PIC(LREG) \
|
2017-07-16 15:58:01 +00:00
|
|
|
copy LREG , %r19
|
2006-05-15 00:44:14 +00:00
|
|
|
/* Inline assembly defines */
|
2012-10-30 03:16:44 +00:00
|
|
|
#define TREG_ASM "%r4" /* Cant clobber r3, it holds framemarker */
|
|
|
|
#define SAVE_ASM_PIC " copy %%r19, %" TREG_ASM "\n"
|
|
|
|
#define LOAD_ASM_PIC " copy %" TREG_ASM ", %%r19\n"
|
|
|
|
#define CLOB_TREG TREG_ASM ,
|
|
|
|
#define PIC_REG_DEF register unsigned long __r19 asm("r19");
|
|
|
|
#define PIC_REG_USE , "r" (__r19)
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
#ifdef __ASSEMBLER__
|
|
|
|
|
|
|
|
/* Syntactic details of assembler. */
|
|
|
|
|
|
|
|
#define ALIGNARG(log2) log2
|
|
|
|
|
|
|
|
/* For Linux we can use the system call table in the header file
|
|
|
|
/usr/include/asm/unistd.h
|
|
|
|
of the kernel. But these symbols do not follow the SYS_* syntax
|
|
|
|
so we have to redefine the `SYS_ify' macro here. */
|
|
|
|
#undef SYS_ify
|
|
|
|
#define SYS_ify(syscall_name) __NR_##syscall_name
|
|
|
|
|
|
|
|
/* ELF-like local names start with `.L'. */
|
|
|
|
#undef L
|
|
|
|
#define L(name) .L##name
|
|
|
|
|
|
|
|
/* Linux uses a negative return value to indicate syscall errors,
|
|
|
|
unlike most Unices, which use the condition codes' carry flag.
|
|
|
|
|
|
|
|
Since version 2.1 the return value of a system call might be
|
|
|
|
negative even if the call succeeded. E.g., the `lseek' system call
|
|
|
|
might return a large offset. Therefore we must not anymore test
|
|
|
|
for < 0, but test for a real error by making sure the value in %eax
|
|
|
|
is a real error number. Linus said he will make sure the no syscall
|
|
|
|
returns a value in -1 .. -4095 as a valid result so we can safely
|
|
|
|
test with -4095. */
|
|
|
|
|
|
|
|
/* We don't want the label for the error handle to be global when we define
|
|
|
|
it here. */
|
2006-05-15 00:44:14 +00:00
|
|
|
/*#ifdef PIC
|
2000-10-15 03:28:47 +00:00
|
|
|
# define SYSCALL_ERROR_LABEL 0f
|
|
|
|
#else
|
|
|
|
# define SYSCALL_ERROR_LABEL syscall_error
|
2006-05-15 00:44:14 +00:00
|
|
|
#endif*/
|
|
|
|
|
|
|
|
/* Argument manipulation from the stack for preparing to
|
|
|
|
make a syscall */
|
|
|
|
|
|
|
|
#define DOARGS_0 /* nothing */
|
|
|
|
#define DOARGS_1 /* nothing */
|
|
|
|
#define DOARGS_2 /* nothing */
|
|
|
|
#define DOARGS_3 /* nothing */
|
|
|
|
#define DOARGS_4 /* nothing */
|
|
|
|
#define DOARGS_5 ldw -52(%sp), %r22 ASM_LINE_SEP
|
|
|
|
#define DOARGS_6 DOARGS_5 ldw -56(%sp), %r21 ASM_LINE_SEP
|
|
|
|
|
|
|
|
#define UNDOARGS_0 /* nothing */
|
|
|
|
#define UNDOARGS_1 /* nothing */
|
|
|
|
#define UNDOARGS_2 /* nothing */
|
|
|
|
#define UNDOARGS_3 /* nothing */
|
|
|
|
#define UNDOARGS_4 /* nothing */
|
|
|
|
#define UNDOARGS_5 /* nothing */
|
|
|
|
#define UNDOARGS_6 /* nothing */
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
/* Define an entry point visible from C.
|
|
|
|
|
|
|
|
There is currently a bug in gdb which prevents us from specifying
|
|
|
|
incomplete stabs information. Fake some entries here which specify
|
|
|
|
the current source file. */
|
2015-07-30 02:55:43 +00:00
|
|
|
#undef ENTRY
|
2006-05-15 00:44:14 +00:00
|
|
|
#define ENTRY(name) \
|
|
|
|
.text ASM_LINE_SEP \
|
|
|
|
.align ALIGNARG(4) ASM_LINE_SEP \
|
|
|
|
.export C_SYMBOL_NAME(name) ASM_LINE_SEP \
|
|
|
|
.type C_SYMBOL_NAME(name),@function ASM_LINE_SEP \
|
2012-10-30 03:31:55 +00:00
|
|
|
cfi_startproc ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
C_LABEL(name) ASM_LINE_SEP \
|
|
|
|
.PROC ASM_LINE_SEP \
|
|
|
|
.CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=3 ASM_LINE_SEP \
|
|
|
|
.ENTRY ASM_LINE_SEP \
|
|
|
|
/* SAVE_RP says we do */ ASM_LINE_SEP \
|
|
|
|
stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
|
2012-10-30 03:31:55 +00:00
|
|
|
.cfi_offset 2, -20 ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
/*FIXME: Call mcount? (carefull with stack!) */
|
|
|
|
|
|
|
|
/* Some syscall wrappers do not call other functions, and
|
|
|
|
hence are classified as leaf, so add NO_CALLS for gdb */
|
|
|
|
#define ENTRY_LEAF(name) \
|
|
|
|
.text ASM_LINE_SEP \
|
|
|
|
.align ALIGNARG(4) ASM_LINE_SEP \
|
|
|
|
.export C_SYMBOL_NAME(name) ASM_LINE_SEP \
|
|
|
|
.type C_SYMBOL_NAME(name),@function ASM_LINE_SEP \
|
2012-10-30 03:31:55 +00:00
|
|
|
cfi_startproc ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
C_LABEL(name) ASM_LINE_SEP \
|
|
|
|
.PROC ASM_LINE_SEP \
|
|
|
|
.CALLINFO FRAME=64,NO_CALLS,SAVE_RP,ENTRY_GR=3 ASM_LINE_SEP \
|
|
|
|
.ENTRY ASM_LINE_SEP \
|
|
|
|
/* SAVE_RP says we do */ ASM_LINE_SEP \
|
|
|
|
stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
|
2012-10-30 03:31:55 +00:00
|
|
|
.cfi_offset 2, -20 ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
/*FIXME: Call mcount? (carefull with stack!) */
|
2003-03-23 19:42:23 +00:00
|
|
|
|
2000-10-15 03:28:47 +00:00
|
|
|
#undef END
|
2003-10-15 05:46:00 +00:00
|
|
|
#define END(name) \
|
2014-04-29 07:08:48 +00:00
|
|
|
.EXIT ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
.PROCEND ASM_LINE_SEP \
|
2012-10-30 03:31:55 +00:00
|
|
|
cfi_endproc ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
.size C_SYMBOL_NAME(name), .-C_SYMBOL_NAME(name) ASM_LINE_SEP
|
2000-10-15 03:28:47 +00:00
|
|
|
|
2012-10-30 02:05:36 +00:00
|
|
|
/* If compiled for profiling, call `mcount' at the start
|
|
|
|
of each function. No, don't bother. gcc will put the
|
2006-05-15 00:44:14 +00:00
|
|
|
call in for us. */
|
2000-10-15 03:28:47 +00:00
|
|
|
#define CALL_MCOUNT /* Do nothing. */
|
|
|
|
|
|
|
|
/* syscall wrappers consist of
|
|
|
|
#include <sysdep.h>
|
|
|
|
PSEUDO(...)
|
|
|
|
ret
|
|
|
|
PSEUDO_END(...)
|
|
|
|
|
|
|
|
which means
|
|
|
|
ENTRY(name)
|
|
|
|
DO_CALL(...)
|
2012-10-30 03:04:43 +00:00
|
|
|
bv,n 0(2)
|
2000-10-15 03:28:47 +00:00
|
|
|
*/
|
|
|
|
|
2015-07-30 02:55:43 +00:00
|
|
|
#undef PSEUDO
|
2003-10-15 05:46:00 +00:00
|
|
|
#define PSEUDO(name, syscall_name, args) \
|
2006-05-15 00:44:14 +00:00
|
|
|
ENTRY (name) ASM_LINE_SEP \
|
|
|
|
/* If necc. load args from stack */ ASM_LINE_SEP \
|
|
|
|
DOARGS_##args ASM_LINE_SEP \
|
|
|
|
DO_CALL (syscall_name, args) ASM_LINE_SEP \
|
2012-10-30 03:04:43 +00:00
|
|
|
UNDOARGS_##args ASM_LINE_SEP
|
2003-10-15 05:46:00 +00:00
|
|
|
|
|
|
|
#define ret \
|
2006-05-15 00:44:14 +00:00
|
|
|
/* Return value set by ERRNO code */ ASM_LINE_SEP \
|
|
|
|
bv,n 0(2) ASM_LINE_SEP
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
#undef PSEUDO_END
|
2003-10-15 05:46:00 +00:00
|
|
|
#define PSEUDO_END(name) \
|
2000-10-15 03:28:47 +00:00
|
|
|
END (name)
|
|
|
|
|
2003-10-15 05:46:00 +00:00
|
|
|
/* We don't set the errno on the return from the syscall */
|
|
|
|
#define PSEUDO_NOERRNO(name, syscall_name, args) \
|
2006-05-15 00:44:14 +00:00
|
|
|
ENTRY_LEAF (name) ASM_LINE_SEP \
|
|
|
|
DOARGS_##args ASM_LINE_SEP \
|
|
|
|
DO_CALL_NOERRNO (syscall_name, args) ASM_LINE_SEP \
|
2012-10-30 03:04:43 +00:00
|
|
|
UNDOARGS_##args ASM_LINE_SEP
|
2003-10-15 05:46:00 +00:00
|
|
|
|
|
|
|
#define ret_NOERRNO ret
|
2003-03-23 19:42:23 +00:00
|
|
|
|
|
|
|
#undef PSEUDO_END_NOERRNO
|
2003-10-15 05:46:00 +00:00
|
|
|
#define PSEUDO_END_NOERRNO(name) \
|
2003-03-23 19:42:23 +00:00
|
|
|
END (name)
|
|
|
|
|
2003-10-15 05:46:00 +00:00
|
|
|
/* This has to return the error value */
|
|
|
|
#undef PSEUDO_ERRVAL
|
|
|
|
#define PSEUDO_ERRVAL(name, syscall_name, args) \
|
2006-05-15 00:44:14 +00:00
|
|
|
ENTRY_LEAF (name) ASM_LINE_SEP \
|
|
|
|
DOARGS_##args ASM_LINE_SEP \
|
|
|
|
DO_CALL_ERRVAL (syscall_name, args) ASM_LINE_SEP \
|
2012-10-30 03:04:43 +00:00
|
|
|
UNDOARGS_##args ASM_LINE_SEP
|
2003-10-15 05:46:00 +00:00
|
|
|
|
|
|
|
#define ret_ERRVAL ret
|
|
|
|
|
|
|
|
#undef PSEUDO_END_ERRVAL
|
|
|
|
#define PSEUDO_END_ERRVAL(name) \
|
|
|
|
END(name)
|
|
|
|
|
|
|
|
#undef JUMPTARGET
|
2000-10-15 03:28:47 +00:00
|
|
|
#define JUMPTARGET(name) name
|
|
|
|
#define SYSCALL_PIC_SETUP /* Nothing. */
|
|
|
|
|
2003-10-15 05:46:00 +00:00
|
|
|
|
2006-05-15 00:44:14 +00:00
|
|
|
/* FIXME: This comment is not true.
|
2013-08-21 17:48:48 +00:00
|
|
|
* All the syscall assembly macros rely on finding the appropriate
|
2003-10-15 05:46:00 +00:00
|
|
|
SYSCALL_ERROR_LABEL or rather HANDLER. */
|
|
|
|
|
|
|
|
/* int * __errno_location(void) so you have to store your value
|
|
|
|
into the return address! */
|
2014-04-29 07:08:48 +00:00
|
|
|
#define DEFAULT_SYSCALL_ERROR_HANDLER \
|
2003-10-15 05:46:00 +00:00
|
|
|
.import __errno_location,code ASM_LINE_SEP \
|
|
|
|
/* branch to errno handler */ ASM_LINE_SEP \
|
|
|
|
bl __errno_location,%rp ASM_LINE_SEP
|
|
|
|
|
|
|
|
/* Here are the myriad of configuration options that the above can
|
|
|
|
work for... what we've done is provide the framework for future
|
|
|
|
changes if required to each section */
|
|
|
|
|
|
|
|
#ifdef PIC
|
|
|
|
# if RTLD_PRIVATE_ERRNO
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# else /* !RTLD_PRIVATE_ERRNO */
|
|
|
|
# if defined _LIBC_REENTRANT
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# else /* !_LIBC_REENTRANT */
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# endif /* _LIBC_REENTRANT */
|
|
|
|
# endif /* RTLD_PRIVATE_ERRNO */
|
|
|
|
#else
|
|
|
|
# ifndef _LIBC_REENTRANT
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# else
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-10-15 03:28:47 +00:00
|
|
|
/* Linux takes system call arguments in registers:
|
|
|
|
syscall number gr20
|
|
|
|
arg 1 gr26
|
|
|
|
arg 2 gr25
|
|
|
|
arg 3 gr24
|
|
|
|
arg 4 gr23
|
|
|
|
arg 5 gr22
|
|
|
|
arg 6 gr21
|
|
|
|
|
|
|
|
The compiler calls us by the C convention:
|
|
|
|
syscall number in the DO_CALL macro
|
|
|
|
arg 1 gr26
|
|
|
|
arg 2 gr25
|
|
|
|
arg 3 gr24
|
|
|
|
arg 4 gr23
|
2006-05-15 00:44:14 +00:00
|
|
|
arg 5 -52(sp)
|
|
|
|
arg 6 -56(sp)
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
gr22 and gr21 are caller-saves, so we can just load the arguments
|
|
|
|
there and generally be happy. */
|
|
|
|
|
|
|
|
/* the cmpb...no_error code below inside DO_CALL
|
|
|
|
* is intended to mimic the if (__sys_res...)
|
|
|
|
* code inside INLINE_SYSCALL
|
|
|
|
*/
|
2006-05-15 00:44:14 +00:00
|
|
|
#define NO_ERROR -0x1000
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
#undef DO_CALL
|
2002-08-26 11:37:24 +00:00
|
|
|
#define DO_CALL(syscall_name, args) \
|
2006-05-15 00:44:14 +00:00
|
|
|
/* Create a frame */ ASM_LINE_SEP \
|
2006-09-07 16:34:43 +00:00
|
|
|
stwm TREG, 64(%sp) ASM_LINE_SEP \
|
2017-07-16 15:58:01 +00:00
|
|
|
.cfi_def_cfa_offset -64 ASM_LINE_SEP \
|
2012-10-30 03:31:55 +00:00
|
|
|
.cfi_offset TREG, 0 ASM_LINE_SEP \
|
2006-09-07 16:34:43 +00:00
|
|
|
stw %sp, -4(%sp) ASM_LINE_SEP \
|
|
|
|
stw %r19, -32(%sp) ASM_LINE_SEP \
|
2017-07-16 15:58:01 +00:00
|
|
|
.cfi_offset 19, 32 ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
/* Save r19 */ ASM_LINE_SEP \
|
|
|
|
SAVE_PIC(TREG) ASM_LINE_SEP \
|
2003-10-15 05:46:00 +00:00
|
|
|
/* Do syscall, delay loads # */ ASM_LINE_SEP \
|
2000-10-15 03:28:47 +00:00
|
|
|
ble 0x100(%sr2,%r0) ASM_LINE_SEP \
|
|
|
|
ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
ldi NO_ERROR,%r1 ASM_LINE_SEP \
|
|
|
|
cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
|
|
|
|
/* Restore r19 from TREG */ ASM_LINE_SEP \
|
|
|
|
LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \
|
2003-10-15 05:46:00 +00:00
|
|
|
SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
/* Use TREG for temp storage */ ASM_LINE_SEP \
|
|
|
|
copy %ret0, TREG /* delay */ ASM_LINE_SEP \
|
2003-10-15 05:46:00 +00:00
|
|
|
/* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
|
|
|
|
/* do a -1*syscall_ret0 */ ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
sub %r0, TREG, TREG ASM_LINE_SEP \
|
2003-10-15 05:46:00 +00:00
|
|
|
/* Store into errno location */ ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
|
2003-10-15 05:46:00 +00:00
|
|
|
/* return -1 as error */ ASM_LINE_SEP \
|
2000-10-15 03:28:47 +00:00
|
|
|
ldo -1(%r0), %ret0 ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
L(pre_end): ASM_LINE_SEP \
|
|
|
|
/* Restore our frame, restoring TREG */ ASM_LINE_SEP \
|
2006-09-07 16:34:43 +00:00
|
|
|
ldwm -64(%sp), TREG ASM_LINE_SEP \
|
|
|
|
/* Restore return pointer */ ASM_LINE_SEP \
|
2017-07-16 15:58:01 +00:00
|
|
|
ldw -20(%sp),%rp ASM_LINE_SEP
|
2003-10-15 05:46:00 +00:00
|
|
|
|
|
|
|
/* We do nothing with the return, except hand it back to someone else */
|
|
|
|
#undef DO_CALL_NOERRNO
|
|
|
|
#define DO_CALL_NOERRNO(syscall_name, args) \
|
|
|
|
/* No need to store r19 */ ASM_LINE_SEP \
|
|
|
|
ble 0x100(%sr2,%r0) ASM_LINE_SEP \
|
|
|
|
ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
/* Caller will restore r19 */ ASM_LINE_SEP
|
2000-10-15 03:28:47 +00:00
|
|
|
|
2003-10-15 05:46:00 +00:00
|
|
|
/* Here, we return the ERRVAL in assembly, note we don't call the
|
|
|
|
error handler function, but we do 'negate' the return _IF_
|
|
|
|
it's an error. Not sure if this is the right semantic. */
|
|
|
|
|
|
|
|
#undef DO_CALL_ERRVAL
|
|
|
|
#define DO_CALL_ERRVAL(syscall_name, args) \
|
|
|
|
/* No need to store r19 */ ASM_LINE_SEP \
|
|
|
|
ble 0x100(%sr2,%r0) ASM_LINE_SEP \
|
|
|
|
ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
|
|
|
|
/* Caller will restore r19 */ ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
ldi NO_ERROR,%r1 ASM_LINE_SEP \
|
2003-10-15 05:46:00 +00:00
|
|
|
cmpb,>>=,n %r1,%ret0,0f ASM_LINE_SEP \
|
|
|
|
sub %r0, %ret0, %ret0 ASM_LINE_SEP \
|
2006-05-15 00:44:14 +00:00
|
|
|
0: ASM_LINE_SEP
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2003-10-15 05:46:00 +00:00
|
|
|
/* GCC has to be warned that a syscall may clobber all the ABI
|
|
|
|
registers listed as "caller-saves", see page 8, Table 2
|
|
|
|
in section 2.2.6 of the PA-RISC RUN-TIME architecture
|
|
|
|
document. However! r28 is the result and will conflict with
|
|
|
|
the clobber list so it is left out. Also the input arguments
|
|
|
|
registers r20 -> r26 will conflict with the list so they
|
|
|
|
are treated specially. Although r19 is clobbered by the syscall
|
|
|
|
we cannot say this because it would violate ABI, thus we say
|
2006-05-15 00:44:14 +00:00
|
|
|
TREG is clobbered and use that register to save/restore r19
|
2003-10-15 05:46:00 +00:00
|
|
|
across the syscall. */
|
|
|
|
|
2007-05-18 01:59:52 +00:00
|
|
|
#define CALL_CLOB_REGS "%r1", "%r2", CLOB_TREG \
|
2014-04-29 07:08:48 +00:00
|
|
|
"%r20", "%r29", "%r31"
|
2003-10-15 05:46:00 +00:00
|
|
|
|
|
|
|
/* Similar to INLINE_SYSCALL but we don't set errno */
|
|
|
|
#undef INTERNAL_SYSCALL
|
2020-01-29 20:38:36 +00:00
|
|
|
#define INTERNAL_SYSCALL(name, nr, args...) \
|
2006-05-15 00:44:14 +00:00
|
|
|
({ \
|
|
|
|
long __sys_res; \
|
|
|
|
{ \
|
2015-08-07 15:54:19 +00:00
|
|
|
LOAD_ARGS_##nr(args) \
|
2006-05-15 00:44:14 +00:00
|
|
|
register unsigned long __res asm("r28"); \
|
2007-05-18 01:59:52 +00:00
|
|
|
PIC_REG_DEF \
|
2015-08-07 15:54:19 +00:00
|
|
|
LOAD_REGS_##nr \
|
2006-05-15 00:44:14 +00:00
|
|
|
/* FIXME: HACK save/load r19 around syscall */ \
|
|
|
|
asm volatile( \
|
|
|
|
SAVE_ASM_PIC \
|
|
|
|
" ble 0x100(%%sr2, %%r0)\n" \
|
|
|
|
" ldi %1, %%r20\n" \
|
|
|
|
LOAD_ASM_PIC \
|
|
|
|
: "=r" (__res) \
|
2007-05-18 01:59:52 +00:00
|
|
|
: "i" (SYS_ify(name)) PIC_REG_USE ASM_ARGS_##nr \
|
2006-05-15 00:44:14 +00:00
|
|
|
: "memory", CALL_CLOB_REGS CLOB_ARGS_##nr \
|
|
|
|
); \
|
|
|
|
__sys_res = (long)__res; \
|
|
|
|
} \
|
|
|
|
__sys_res; \
|
2003-10-15 05:46:00 +00:00
|
|
|
})
|
2000-10-15 03:28:47 +00:00
|
|
|
|
2006-05-15 00:44:14 +00:00
|
|
|
|
|
|
|
/* The _NCS variant allows non-constant syscall numbers. */
|
|
|
|
#undef INTERNAL_SYSCALL_NCS
|
2020-01-29 20:38:36 +00:00
|
|
|
#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
|
2006-05-15 00:44:14 +00:00
|
|
|
({ \
|
|
|
|
long __sys_res; \
|
|
|
|
{ \
|
2015-08-07 15:54:19 +00:00
|
|
|
LOAD_ARGS_##nr(args) \
|
2006-05-15 00:44:14 +00:00
|
|
|
register unsigned long __res asm("r28"); \
|
2007-05-18 01:59:52 +00:00
|
|
|
PIC_REG_DEF \
|
2015-08-07 15:54:19 +00:00
|
|
|
LOAD_REGS_##nr \
|
2006-05-15 00:44:14 +00:00
|
|
|
/* FIXME: HACK save/load r19 around syscall */ \
|
|
|
|
asm volatile( \
|
|
|
|
SAVE_ASM_PIC \
|
|
|
|
" ble 0x100(%%sr2, %%r0)\n" \
|
|
|
|
" copy %1, %%r20\n" \
|
|
|
|
LOAD_ASM_PIC \
|
|
|
|
: "=r" (__res) \
|
2007-05-18 01:59:52 +00:00
|
|
|
: "r" (name) PIC_REG_USE ASM_ARGS_##nr \
|
2006-05-15 00:44:14 +00:00
|
|
|
: "memory", CALL_CLOB_REGS CLOB_ARGS_##nr \
|
|
|
|
); \
|
|
|
|
__sys_res = (long)__res; \
|
|
|
|
} \
|
|
|
|
__sys_res; \
|
|
|
|
})
|
|
|
|
|
2000-10-15 03:28:47 +00:00
|
|
|
#define LOAD_ARGS_0()
|
2015-08-07 15:54:19 +00:00
|
|
|
#define LOAD_REGS_0
|
|
|
|
#define LOAD_ARGS_1(a1) \
|
|
|
|
register unsigned long __x26 = (unsigned long)(a1); \
|
2006-05-15 00:44:14 +00:00
|
|
|
LOAD_ARGS_0()
|
2015-08-07 15:54:19 +00:00
|
|
|
#define LOAD_REGS_1 \
|
|
|
|
register unsigned long __r26 __asm__("r26") = __x26; \
|
|
|
|
LOAD_REGS_0
|
|
|
|
#define LOAD_ARGS_2(a1,a2) \
|
|
|
|
register unsigned long __x25 = (unsigned long)(a2); \
|
|
|
|
LOAD_ARGS_1(a1)
|
|
|
|
#define LOAD_REGS_2 \
|
|
|
|
register unsigned long __r25 __asm__("r25") = __x25; \
|
|
|
|
LOAD_REGS_1
|
|
|
|
#define LOAD_ARGS_3(a1,a2,a3) \
|
|
|
|
register unsigned long __x24 = (unsigned long)(a3); \
|
|
|
|
LOAD_ARGS_2(a1,a2)
|
|
|
|
#define LOAD_REGS_3 \
|
|
|
|
register unsigned long __r24 __asm__("r24") = __x24; \
|
|
|
|
LOAD_REGS_2
|
|
|
|
#define LOAD_ARGS_4(a1,a2,a3,a4) \
|
|
|
|
register unsigned long __x23 = (unsigned long)(a4); \
|
|
|
|
LOAD_ARGS_3(a1,a2,a3)
|
|
|
|
#define LOAD_REGS_4 \
|
|
|
|
register unsigned long __r23 __asm__("r23") = __x23; \
|
|
|
|
LOAD_REGS_3
|
|
|
|
#define LOAD_ARGS_5(a1,a2,a3,a4,a5) \
|
|
|
|
register unsigned long __x22 = (unsigned long)(a5); \
|
|
|
|
LOAD_ARGS_4(a1,a2,a3,a4)
|
|
|
|
#define LOAD_REGS_5 \
|
|
|
|
register unsigned long __r22 __asm__("r22") = __x22; \
|
|
|
|
LOAD_REGS_4
|
|
|
|
#define LOAD_ARGS_6(a1,a2,a3,a4,a5,a6) \
|
|
|
|
register unsigned long __x21 = (unsigned long)(a6); \
|
|
|
|
LOAD_ARGS_5(a1,a2,a3,a4,a5)
|
|
|
|
#define LOAD_REGS_6 \
|
|
|
|
register unsigned long __r21 __asm__("r21") = __x21; \
|
|
|
|
LOAD_REGS_5
|
2000-10-15 03:28:47 +00:00
|
|
|
|
2003-10-15 05:46:00 +00:00
|
|
|
/* Even with zero args we use r20 for the syscall number */
|
2001-04-20 06:05:04 +00:00
|
|
|
#define ASM_ARGS_0
|
2003-10-15 05:46:00 +00:00
|
|
|
#define ASM_ARGS_1 ASM_ARGS_0, "r" (__r26)
|
|
|
|
#define ASM_ARGS_2 ASM_ARGS_1, "r" (__r25)
|
|
|
|
#define ASM_ARGS_3 ASM_ARGS_2, "r" (__r24)
|
|
|
|
#define ASM_ARGS_4 ASM_ARGS_3, "r" (__r23)
|
|
|
|
#define ASM_ARGS_5 ASM_ARGS_4, "r" (__r22)
|
|
|
|
#define ASM_ARGS_6 ASM_ARGS_5, "r" (__r21)
|
|
|
|
|
|
|
|
/* The registers not listed as inputs but clobbered */
|
|
|
|
#define CLOB_ARGS_6
|
|
|
|
#define CLOB_ARGS_5 CLOB_ARGS_6, "%r21"
|
|
|
|
#define CLOB_ARGS_4 CLOB_ARGS_5, "%r22"
|
|
|
|
#define CLOB_ARGS_3 CLOB_ARGS_4, "%r23"
|
|
|
|
#define CLOB_ARGS_2 CLOB_ARGS_3, "%r24"
|
|
|
|
#define CLOB_ARGS_1 CLOB_ARGS_2, "%r25"
|
|
|
|
#define CLOB_ARGS_0 CLOB_ARGS_1, "%r26"
|
2000-10-15 03:28:47 +00:00
|
|
|
|
|
|
|
#endif /* __ASSEMBLER__ */
|
2007-02-02 21:52:32 +00:00
|
|
|
|
|
|
|
/* Pointer mangling is not yet supported for HPPA. */
|
|
|
|
#define PTR_MANGLE(var) (void) (var)
|
|
|
|
#define PTR_DEMANGLE(var) (void) (var)
|
2015-07-30 02:55:43 +00:00
|
|
|
|
Linux: Consolidate {RTLD_}SINGLE_THREAD_P definition
Current GLIBC has two ways to implement the single thread optimization
on syscalls to avoid calling the cancellation path: either by using
global variables (__{libc,pthread}_multiple_thread) or by accessing
the TCB field (defined by TLS_MULTIPLE_THREADS_IN_TCB). Both the
variables and the macros to acces its value are defined in the
architecture sysdep-cancel.h header.
This patch consolidates its definition on only one header,
sysdeps/unix/sysv/linux/sysdep-cancel.h, and adds a new define
(SINGLE_THREAD_BY_GLOBAL) which the architecture defines if it prefer
to use the global variables instead of the TCB field. This is an
optimization, so if the architecture does not define it, the TCB
method will be used as default.
Checked on x86_64-linux-gnu and on a build with major touched
ABIs (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf,
hppa-linux-gnu, i686-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu,
mips-linux-gnu, mips64-linux-gnu, powerpc-linux-gnu,
powerpc64le-linux-gnu, s390-linux-gnu, s390x-linux-gnu, sh4-linux-gnu,
sparcv9-linux-gnu, sparc64-linux-gnu, tilegx-linux-gnu).
* sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h: Remove file.
* sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/arm/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/tile/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
(SINGLE_THREAD_BY_GLOBAL): Define.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h (SINGLE_THREAD_BY_GLOBAL):
Likewise.
* sysdeps/unix/sysv/linux/alpha/sysdep.h (SINGLE_THREAD_BY_GLOBAL):
Likewise.
* sysdeps/unix/sysv/linux/arm/sysdep.h (SINGLE_THREAD_BY_GLOBAL):
Likewise.
* sysdeps/unix/sysv/linux/hppa/sysdep.h (SINGLE_THREAD_BY_GLOBAL):
Likewise.
* sysdeps/unix/sysv/linux/microblaze/sysdep.h
(SINGLE_THREAD_BY_GLOBAL): Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (SINGLE_THREAD_BY_GLOBAL):
Likewise.
2017-08-03 22:27:27 +00:00
|
|
|
#define SINGLE_THREAD_BY_GLOBAL 1
|
|
|
|
|
2015-07-30 02:55:43 +00:00
|
|
|
#endif /* _LINUX_HPPA_SYSDEP_H */
|