2014-01-01 11:03:15 +00:00
|
|
|
/* Copyright (C) 1992-2014 Free Software Foundation, Inc.
|
1996-11-07 01:34:35 +00:00
|
|
|
This file is part of the GNU C Library.
|
1996-03-19 19:54:21 +00:00
|
|
|
Contributed by Brendan Kehoe (brendan@zen.org).
|
|
|
|
|
1996-11-07 01:34:35 +00:00
|
|
|
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.
|
1996-03-19 19:54:21 +00:00
|
|
|
|
1996-11-07 01:34:35 +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.
|
1996-03-19 19:54:21 +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
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1996-03-19 19:54:21 +00:00
|
|
|
|
|
|
|
#include <sysdeps/unix/sysdep.h>
|
|
|
|
|
1998-05-29 10:20:59 +00:00
|
|
|
#ifdef __ASSEMBLER__
|
1996-03-19 19:54:21 +00:00
|
|
|
|
1996-05-23 05:32:14 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
# include <alpha/regdef.h>
|
|
|
|
#else
|
|
|
|
# include <regdef.h>
|
|
|
|
#endif
|
|
|
|
|
2014-11-20 15:39:43 +00:00
|
|
|
#if IS_IN (rtld)
|
2002-11-08 02:18:48 +00:00
|
|
|
# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1996-11-07 01:34:35 +00:00
|
|
|
#define __LABEL(x) x##:
|
|
|
|
|
1996-05-23 05:32:14 +00:00
|
|
|
#define LEAF(name, framesize) \
|
|
|
|
.globl name; \
|
2004-09-26 17:40:31 +00:00
|
|
|
.align 4; \
|
1996-05-23 05:32:14 +00:00
|
|
|
.ent name, 0; \
|
1996-11-07 01:34:35 +00:00
|
|
|
__LABEL(name) \
|
1996-05-23 05:32:14 +00:00
|
|
|
.frame sp, framesize, ra
|
|
|
|
|
1996-03-19 19:54:21 +00:00
|
|
|
#define ENTRY(name) \
|
|
|
|
.globl name; \
|
2004-09-26 17:40:31 +00:00
|
|
|
.align 4; \
|
1996-05-23 05:32:14 +00:00
|
|
|
.ent name, 0; \
|
1996-11-07 01:34:35 +00:00
|
|
|
__LABEL(name) \
|
1996-05-23 05:32:14 +00:00
|
|
|
.frame sp, 0, ra
|
1996-03-19 19:54:21 +00:00
|
|
|
|
1996-06-19 06:37:57 +00:00
|
|
|
/* Mark the end of function SYM. */
|
|
|
|
#undef END
|
|
|
|
#define END(sym) .end sym
|
|
|
|
|
2012-09-28 17:51:01 +00:00
|
|
|
#ifdef PROF
|
|
|
|
# define PSEUDO_PROF \
|
|
|
|
.set noat; \
|
|
|
|
lda AT, _mcount; \
|
|
|
|
jsr AT, (AT), _mcount; \
|
|
|
|
.set at
|
|
|
|
#else
|
|
|
|
# define PSEUDO_PROF
|
|
|
|
#endif
|
|
|
|
|
1996-11-07 01:34:35 +00:00
|
|
|
#ifdef PROF
|
2002-11-08 02:18:48 +00:00
|
|
|
# define PSEUDO_PROLOGUE \
|
|
|
|
.frame sp, 0, ra; \
|
|
|
|
ldgp gp,0(pv); \
|
2012-09-28 17:51:01 +00:00
|
|
|
PSEUDO_PROF; \
|
2002-11-08 02:18:48 +00:00
|
|
|
.prologue 1
|
2003-01-12 19:25:52 +00:00
|
|
|
#elif defined PIC
|
2002-11-08 02:18:48 +00:00
|
|
|
# define PSEUDO_PROLOGUE \
|
|
|
|
.frame sp, 0, ra; \
|
|
|
|
.prologue 0
|
2003-01-12 19:25:52 +00:00
|
|
|
#else
|
|
|
|
# define PSEUDO_PROLOGUE \
|
|
|
|
.frame sp, 0, ra; \
|
|
|
|
ldgp gp,0(pv); \
|
|
|
|
.prologue 1
|
2002-11-08 02:18:48 +00:00
|
|
|
#endif /* PROF */
|
|
|
|
|
2012-06-06 21:35:00 +00:00
|
|
|
#ifdef PROF
|
|
|
|
# define USEPV_PROF std
|
|
|
|
#else
|
|
|
|
# define USEPV_PROF no
|
|
|
|
#endif
|
|
|
|
|
2002-11-08 02:18:48 +00:00
|
|
|
#if RTLD_PRIVATE_ERRNO
|
2003-01-12 19:25:52 +00:00
|
|
|
# define SYSCALL_ERROR_LABEL $syscall_error
|
2002-11-08 02:18:48 +00:00
|
|
|
# define SYSCALL_ERROR_HANDLER \
|
2012-09-28 17:51:01 +00:00
|
|
|
$syscall_error: \
|
2004-10-04 20:59:38 +00:00
|
|
|
stl v0, rtld_errno(gp) !gprel; \
|
2002-11-08 02:18:48 +00:00
|
|
|
lda v0, -1; \
|
|
|
|
ret
|
2012-09-28 17:51:01 +00:00
|
|
|
# define SYSCALL_ERROR_FALLTHRU
|
2003-01-12 19:25:52 +00:00
|
|
|
#elif defined(PIC)
|
2012-09-28 17:51:01 +00:00
|
|
|
# define SYSCALL_ERROR_LABEL __syscall_error !samegp
|
2012-02-15 21:51:58 +00:00
|
|
|
# define SYSCALL_ERROR_HANDLER
|
2012-09-28 17:51:01 +00:00
|
|
|
# define SYSCALL_ERROR_FALLTHRU br SYSCALL_ERROR_LABEL
|
2002-11-08 02:18:48 +00:00
|
|
|
#else
|
2012-09-28 17:51:01 +00:00
|
|
|
# define SYSCALL_ERROR_LABEL $syscall_error
|
|
|
|
# define SYSCALL_ERROR_HANDLER \
|
|
|
|
$syscall_error: \
|
|
|
|
jmp $31, __syscall_error
|
|
|
|
# define SYSCALL_ERROR_FALLTHRU
|
2002-11-08 02:18:48 +00:00
|
|
|
#endif /* RTLD_PRIVATE_ERRNO */
|
|
|
|
|
2003-01-12 19:25:52 +00:00
|
|
|
/* Overridden by specific syscalls. */
|
|
|
|
#undef PSEUDO_PREPARE_ARGS
|
|
|
|
#define PSEUDO_PREPARE_ARGS /* Nothing. */
|
|
|
|
|
|
|
|
#define PSEUDO(name, syscall_name, args) \
|
2002-11-08 02:18:48 +00:00
|
|
|
.globl name; \
|
|
|
|
.align 4; \
|
|
|
|
.ent name,0; \
|
1996-11-07 01:34:35 +00:00
|
|
|
__LABEL(name) \
|
2002-11-08 02:18:48 +00:00
|
|
|
PSEUDO_PROLOGUE; \
|
2003-01-07 00:47:52 +00:00
|
|
|
PSEUDO_PREPARE_ARGS \
|
2002-11-08 02:18:48 +00:00
|
|
|
lda v0, SYS_ify(syscall_name); \
|
|
|
|
call_pal PAL_callsys; \
|
2003-01-12 19:25:52 +00:00
|
|
|
bne a3, SYSCALL_ERROR_LABEL
|
|
|
|
|
|
|
|
#undef PSEUDO_END
|
2012-09-28 17:51:01 +00:00
|
|
|
#define PSEUDO_END(sym) \
|
2002-11-08 02:18:48 +00:00
|
|
|
SYSCALL_ERROR_HANDLER; \
|
|
|
|
END(sym)
|
2003-01-07 00:47:52 +00:00
|
|
|
|
2003-03-23 19:42:23 +00:00
|
|
|
#define PSEUDO_NOERRNO(name, syscall_name, args) \
|
|
|
|
.globl name; \
|
|
|
|
.align 4; \
|
|
|
|
.ent name,0; \
|
|
|
|
__LABEL(name) \
|
|
|
|
PSEUDO_PROLOGUE; \
|
|
|
|
PSEUDO_PREPARE_ARGS \
|
|
|
|
lda v0, SYS_ify(syscall_name); \
|
|
|
|
call_pal PAL_callsys;
|
|
|
|
|
|
|
|
#undef PSEUDO_END_NOERRNO
|
|
|
|
#define PSEUDO_END_NOERRNO(sym) END(sym)
|
|
|
|
|
|
|
|
#define ret_NOERRNO ret
|
|
|
|
|
2003-08-17 00:33:13 +00:00
|
|
|
#define PSEUDO_ERRVAL(name, syscall_name, args) \
|
|
|
|
.globl name; \
|
|
|
|
.align 4; \
|
|
|
|
.ent name,0; \
|
|
|
|
__LABEL(name) \
|
|
|
|
PSEUDO_PROLOGUE; \
|
|
|
|
PSEUDO_PREPARE_ARGS \
|
|
|
|
lda v0, SYS_ify(syscall_name); \
|
|
|
|
call_pal PAL_callsys;
|
|
|
|
|
|
|
|
#undef PSEUDO_END_ERRVAL
|
|
|
|
#define PSEUDO_END_ERRVAL(sym) END(sym)
|
|
|
|
|
|
|
|
#define ret_ERRVAL ret
|
|
|
|
|
1996-03-19 19:54:21 +00:00
|
|
|
#define r0 v0
|
|
|
|
#define r1 a4
|
|
|
|
|
|
|
|
#define MOVE(x,y) mov x,y
|
|
|
|
|
2003-01-12 19:25:52 +00:00
|
|
|
#else /* !ASSEMBLER */
|
|
|
|
|
2013-02-21 00:49:25 +00:00
|
|
|
/* In order to get __set_errno() definition in INLINE_SYSCALL. */
|
|
|
|
#include <errno.h>
|
|
|
|
|
2003-01-12 19:25:52 +00:00
|
|
|
/* ??? Linux needs to be able to override INLINE_SYSCALL for one
|
|
|
|
particular special case. Make this easy. */
|
|
|
|
|
2003-01-14 01:23:59 +00:00
|
|
|
#undef INLINE_SYSCALL
|
2003-01-12 19:25:52 +00:00
|
|
|
#define INLINE_SYSCALL(name, nr, args...) \
|
|
|
|
INLINE_SYSCALL1(name, nr, args)
|
|
|
|
|
|
|
|
#define INLINE_SYSCALL1(name, nr, args...) \
|
|
|
|
({ \
|
|
|
|
long _sc_ret, _sc_err; \
|
2004-09-23 05:15:41 +00:00
|
|
|
inline_syscall##nr(__NR_##name, args); \
|
2003-06-20 16:24:36 +00:00
|
|
|
if (__builtin_expect (_sc_err, 0)) \
|
2003-01-12 19:25:52 +00:00
|
|
|
{ \
|
|
|
|
__set_errno (_sc_ret); \
|
|
|
|
_sc_ret = -1L; \
|
|
|
|
} \
|
|
|
|
_sc_ret; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define INTERNAL_SYSCALL(name, err_out, nr, args...) \
|
|
|
|
INTERNAL_SYSCALL1(name, err_out, nr, args)
|
|
|
|
|
|
|
|
#define INTERNAL_SYSCALL1(name, err_out, nr, args...) \
|
2004-09-23 05:15:41 +00:00
|
|
|
INTERNAL_SYSCALL_NCS(__NR_##name, err_out, nr, args)
|
|
|
|
|
|
|
|
#define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
|
2003-01-12 19:25:52 +00:00
|
|
|
({ \
|
|
|
|
long _sc_ret, _sc_err; \
|
|
|
|
inline_syscall##nr(name, args); \
|
|
|
|
err_out = _sc_err; \
|
|
|
|
_sc_ret; \
|
|
|
|
})
|
|
|
|
|
2012-02-08 20:36:16 +00:00
|
|
|
#define INTERNAL_SYSCALL_DECL(err) \
|
|
|
|
long int err __attribute__((unused))
|
|
|
|
|
2012-02-16 00:06:17 +00:00
|
|
|
/* The normal Alpha calling convention sign-extends 32-bit quantties
|
|
|
|
no matter what the "real" sign of the 32-bit type. We want to
|
|
|
|
preserve that when filling in values for the kernel. */
|
|
|
|
#define syscall_promote(arg) \
|
|
|
|
(sizeof(arg) == 4 ? (long)(int)(long)(arg) : (long)(arg))
|
|
|
|
|
2010-03-26 17:29:42 +00:00
|
|
|
/* Make sure and "use" the variable that we're not returning,
|
|
|
|
in order to suppress unused variable warnings. */
|
|
|
|
#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void)val, err)
|
|
|
|
#define INTERNAL_SYSCALL_ERRNO(val, err) ((void)err, val)
|
2003-01-12 19:25:52 +00:00
|
|
|
|
|
|
|
#define inline_syscall_clobbers \
|
|
|
|
"$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
|
|
|
|
"$22", "$23", "$24", "$25", "$27", "$28", "memory"
|
|
|
|
|
|
|
|
/* It is moderately important optimization-wise to limit the lifetime
|
|
|
|
of the hard-register variables as much as possible. Thus we copy
|
|
|
|
in/out as close to the asm as possible. */
|
|
|
|
|
|
|
|
#define inline_syscall0(name, args...) \
|
|
|
|
{ \
|
|
|
|
register long _sc_19 __asm__("$19"); \
|
2012-02-16 00:06:17 +00:00
|
|
|
register long _sc_0 = name; \
|
2003-01-22 02:07:54 +00:00
|
|
|
__asm__ __volatile__ \
|
|
|
|
("callsys # %0 %1 <= %2" \
|
2012-02-16 00:06:17 +00:00
|
|
|
: "+v"(_sc_0), "=r"(_sc_19) \
|
|
|
|
: : inline_syscall_clobbers, \
|
2003-01-22 02:07:54 +00:00
|
|
|
"$16", "$17", "$18", "$20", "$21"); \
|
2003-01-12 19:25:52 +00:00
|
|
|
_sc_ret = _sc_0, _sc_err = _sc_19; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define inline_syscall1(name,arg1) \
|
|
|
|
{ \
|
2012-02-16 00:06:17 +00:00
|
|
|
register long _tmp_16 = syscall_promote (arg1); \
|
|
|
|
register long _sc_0 = name; \
|
|
|
|
register long _sc_16 __asm__("$16") = _tmp_16; \
|
2003-01-12 19:25:52 +00:00
|
|
|
register long _sc_19 __asm__("$19"); \
|
2003-01-22 02:07:54 +00:00
|
|
|
__asm__ __volatile__ \
|
|
|
|
("callsys # %0 %1 <= %2 %3" \
|
2012-02-16 00:06:17 +00:00
|
|
|
: "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16) \
|
|
|
|
: : inline_syscall_clobbers, \
|
2003-01-22 02:07:54 +00:00
|
|
|
"$17", "$18", "$20", "$21"); \
|
2003-01-12 19:25:52 +00:00
|
|
|
_sc_ret = _sc_0, _sc_err = _sc_19; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define inline_syscall2(name,arg1,arg2) \
|
|
|
|
{ \
|
2012-02-16 00:06:17 +00:00
|
|
|
register long _tmp_16 = syscall_promote (arg1); \
|
|
|
|
register long _tmp_17 = syscall_promote (arg2); \
|
|
|
|
register long _sc_0 = name; \
|
|
|
|
register long _sc_16 __asm__("$16") = _tmp_16; \
|
|
|
|
register long _sc_17 __asm__("$17") = _tmp_17; \
|
2003-01-12 19:25:52 +00:00
|
|
|
register long _sc_19 __asm__("$19"); \
|
2003-01-22 02:07:54 +00:00
|
|
|
__asm__ __volatile__ \
|
|
|
|
("callsys # %0 %1 <= %2 %3 %4" \
|
2012-02-16 00:06:17 +00:00
|
|
|
: "+v"(_sc_0), "=r"(_sc_19), \
|
|
|
|
"+r"(_sc_16), "+r"(_sc_17) \
|
|
|
|
: : inline_syscall_clobbers, \
|
2003-01-22 02:07:54 +00:00
|
|
|
"$18", "$20", "$21"); \
|
2003-01-12 19:25:52 +00:00
|
|
|
_sc_ret = _sc_0, _sc_err = _sc_19; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define inline_syscall3(name,arg1,arg2,arg3) \
|
|
|
|
{ \
|
2012-02-16 00:06:17 +00:00
|
|
|
register long _tmp_16 = syscall_promote (arg1); \
|
|
|
|
register long _tmp_17 = syscall_promote (arg2); \
|
|
|
|
register long _tmp_18 = syscall_promote (arg3); \
|
|
|
|
register long _sc_0 = name; \
|
|
|
|
register long _sc_16 __asm__("$16") = _tmp_16; \
|
|
|
|
register long _sc_17 __asm__("$17") = _tmp_17; \
|
|
|
|
register long _sc_18 __asm__("$18") = _tmp_18; \
|
2003-01-12 19:25:52 +00:00
|
|
|
register long _sc_19 __asm__("$19"); \
|
2003-01-22 02:07:54 +00:00
|
|
|
__asm__ __volatile__ \
|
|
|
|
("callsys # %0 %1 <= %2 %3 %4 %5" \
|
2012-02-16 00:06:17 +00:00
|
|
|
: "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16), \
|
|
|
|
"+r"(_sc_17), "+r"(_sc_18) \
|
|
|
|
: : inline_syscall_clobbers, "$20", "$21"); \
|
2003-01-12 19:25:52 +00:00
|
|
|
_sc_ret = _sc_0, _sc_err = _sc_19; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define inline_syscall4(name,arg1,arg2,arg3,arg4) \
|
|
|
|
{ \
|
2012-02-16 00:06:17 +00:00
|
|
|
register long _tmp_16 = syscall_promote (arg1); \
|
|
|
|
register long _tmp_17 = syscall_promote (arg2); \
|
|
|
|
register long _tmp_18 = syscall_promote (arg3); \
|
|
|
|
register long _tmp_19 = syscall_promote (arg4); \
|
|
|
|
register long _sc_0 = name; \
|
|
|
|
register long _sc_16 __asm__("$16") = _tmp_16; \
|
|
|
|
register long _sc_17 __asm__("$17") = _tmp_17; \
|
|
|
|
register long _sc_18 __asm__("$18") = _tmp_18; \
|
|
|
|
register long _sc_19 __asm__("$19") = _tmp_19; \
|
2003-01-22 02:07:54 +00:00
|
|
|
__asm__ __volatile__ \
|
|
|
|
("callsys # %0 %1 <= %2 %3 %4 %5 %6" \
|
2012-02-16 00:06:17 +00:00
|
|
|
: "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
|
|
|
|
"+r"(_sc_17), "+r"(_sc_18) \
|
|
|
|
: : inline_syscall_clobbers, "$20", "$21"); \
|
2003-01-12 19:25:52 +00:00
|
|
|
_sc_ret = _sc_0, _sc_err = _sc_19; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
|
|
|
|
{ \
|
2012-02-16 00:06:17 +00:00
|
|
|
register long _tmp_16 = syscall_promote (arg1); \
|
|
|
|
register long _tmp_17 = syscall_promote (arg2); \
|
|
|
|
register long _tmp_18 = syscall_promote (arg3); \
|
|
|
|
register long _tmp_19 = syscall_promote (arg4); \
|
|
|
|
register long _tmp_20 = syscall_promote (arg5); \
|
|
|
|
register long _sc_0 = name; \
|
|
|
|
register long _sc_16 __asm__("$16") = _tmp_16; \
|
|
|
|
register long _sc_17 __asm__("$17") = _tmp_17; \
|
|
|
|
register long _sc_18 __asm__("$18") = _tmp_18; \
|
|
|
|
register long _sc_19 __asm__("$19") = _tmp_19; \
|
|
|
|
register long _sc_20 __asm__("$20") = _tmp_20; \
|
2003-01-22 02:07:54 +00:00
|
|
|
__asm__ __volatile__ \
|
|
|
|
("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7" \
|
2012-02-16 00:06:17 +00:00
|
|
|
: "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
|
|
|
|
"+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20) \
|
|
|
|
: : inline_syscall_clobbers, "$21"); \
|
2003-01-12 19:25:52 +00:00
|
|
|
_sc_ret = _sc_0, _sc_err = _sc_19; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
|
|
|
|
{ \
|
2012-02-16 00:06:17 +00:00
|
|
|
register long _tmp_16 = syscall_promote (arg1); \
|
|
|
|
register long _tmp_17 = syscall_promote (arg2); \
|
|
|
|
register long _tmp_18 = syscall_promote (arg3); \
|
|
|
|
register long _tmp_19 = syscall_promote (arg4); \
|
|
|
|
register long _tmp_20 = syscall_promote (arg5); \
|
|
|
|
register long _tmp_21 = syscall_promote (arg6); \
|
|
|
|
register long _sc_0 = name; \
|
|
|
|
register long _sc_16 __asm__("$16") = _tmp_16; \
|
|
|
|
register long _sc_17 __asm__("$17") = _tmp_17; \
|
|
|
|
register long _sc_18 __asm__("$18") = _tmp_18; \
|
|
|
|
register long _sc_19 __asm__("$19") = _tmp_19; \
|
|
|
|
register long _sc_20 __asm__("$20") = _tmp_20; \
|
|
|
|
register long _sc_21 __asm__("$21") = _tmp_21; \
|
2003-01-22 02:07:54 +00:00
|
|
|
__asm__ __volatile__ \
|
|
|
|
("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8" \
|
2012-02-16 00:06:17 +00:00
|
|
|
: "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
|
|
|
|
"+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20), \
|
|
|
|
"+r"(_sc_21) \
|
|
|
|
: : inline_syscall_clobbers); \
|
2003-01-12 19:25:52 +00:00
|
|
|
_sc_ret = _sc_0, _sc_err = _sc_19; \
|
|
|
|
}
|
2013-10-01 14:45:11 +00:00
|
|
|
#endif /* ASSEMBLER */
|
2003-01-12 19:25:52 +00:00
|
|
|
|
2006-01-13 21:46:29 +00:00
|
|
|
/* Pointer mangling support. Note that tls access is slow enough that
|
|
|
|
we don't deoptimize things by placing the pointer check value there. */
|
|
|
|
|
2013-10-01 14:45:11 +00:00
|
|
|
#ifdef __ASSEMBLER__
|
2014-11-20 15:39:43 +00:00
|
|
|
# if IS_IN (rtld)
|
2006-01-13 21:46:29 +00:00
|
|
|
# define PTR_MANGLE(dst, src, tmp) \
|
|
|
|
ldah tmp, __pointer_chk_guard_local($29) !gprelhigh; \
|
|
|
|
ldq tmp, __pointer_chk_guard_local(tmp) !gprellow; \
|
|
|
|
xor src, tmp, dst
|
|
|
|
# define PTR_MANGLE2(dst, src, tmp) \
|
|
|
|
xor src, tmp, dst
|
2013-10-01 14:45:11 +00:00
|
|
|
# elif defined SHARED
|
2006-01-13 21:46:29 +00:00
|
|
|
# define PTR_MANGLE(dst, src, tmp) \
|
|
|
|
ldq tmp, __pointer_chk_guard; \
|
|
|
|
xor src, tmp, dst
|
2013-10-01 14:45:11 +00:00
|
|
|
# else
|
|
|
|
# define PTR_MANGLE(dst, src, tmp) \
|
|
|
|
ldq tmp, __pointer_chk_guard_local; \
|
2006-01-13 21:46:29 +00:00
|
|
|
xor src, tmp, dst
|
2013-10-01 14:45:11 +00:00
|
|
|
# endif
|
|
|
|
# define PTR_MANGLE2(dst, src, tmp) \
|
|
|
|
xor src, tmp, dst
|
|
|
|
# define PTR_DEMANGLE(dst, tmp) PTR_MANGLE(dst, dst, tmp)
|
|
|
|
# define PTR_DEMANGLE2(dst, tmp) PTR_MANGLE2(dst, dst, tmp)
|
|
|
|
#else
|
|
|
|
# include <stdint.h>
|
2014-11-20 15:39:43 +00:00
|
|
|
# if (IS_IN (rtld) \
|
2014-11-24 09:33:45 +00:00
|
|
|
|| (!defined SHARED && (IS_IN (libc) \
|
2014-11-20 08:52:40 +00:00
|
|
|
|| IS_IN (libpthread))))
|
2013-10-01 14:45:11 +00:00
|
|
|
extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
|
|
|
|
# define PTR_MANGLE(var) \
|
|
|
|
(var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
|
2006-01-13 21:46:29 +00:00
|
|
|
# else
|
2014-04-17 04:28:50 +00:00
|
|
|
extern uintptr_t __pointer_chk_guard attribute_relro;
|
2013-10-01 14:45:11 +00:00
|
|
|
# define PTR_MANGLE(var) \
|
2010-03-26 17:30:25 +00:00
|
|
|
(var) = (__typeof(var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
|
2006-01-13 21:46:29 +00:00
|
|
|
# endif
|
2013-10-01 14:45:11 +00:00
|
|
|
# define PTR_DEMANGLE(var) PTR_MANGLE(var)
|
1998-10-31 23:37:54 +00:00
|
|
|
#endif /* ASSEMBLER */
|