alpha: Do signed promotion of 32-bit arguments to syscalls

This commit is contained in:
Richard Henderson 2012-02-15 16:06:17 -08:00
parent 64e65bc1ae
commit f0a81bf387
6 changed files with 85 additions and 244 deletions

View File

@ -1,6 +1,15 @@
2012-02-15 Richard Henderson <rth@twiddle.net> 2012-02-15 Richard Henderson <rth@twiddle.net>
* sysdeps/unux/alpha/sysdep.h: Don't include <tls.h> * sysdeps/unix/alpha/sysdep.h (syscall_promote): New.
(inline_syscall0, inline_syscall1, inline_syscall2,
inline_syscall3, inline_syscall4, inline_syscall5,
inline_syscall6): Use it.
* sysdeps/unix/sysv/linux/alpha/setregid.c: Remove.
* sysdeps/unix/sysv/linux/alpha/setreuid.c: Remove.
* sysdeps/unix/sysv/linux/alpha/setresgid.c: Remove.
* sysdeps/unix/sysv/linux/alpha/setresuid.c: Remove.
* sysdeps/unix/alpha/sysdep.h: Don't include <tls.h>
[PIC] (SYSCALL_ERROR_HANDLER): Emit nothing. [PIC] (SYSCALL_ERROR_HANDLER): Emit nothing.
[PIC] (SYSCALL_ERROR_LABEL): Add !samegp markup. [PIC] (SYSCALL_ERROR_LABEL): Add !samegp markup.

View File

@ -190,6 +190,12 @@ __LABEL(name) \
#define INTERNAL_SYSCALL_DECL(err) \ #define INTERNAL_SYSCALL_DECL(err) \
long int err __attribute__((unused)) long int err __attribute__((unused))
/* 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))
/* Make sure and "use" the variable that we're not returning, /* Make sure and "use" the variable that we're not returning,
in order to suppress unused variable warnings. */ in order to suppress unused variable warnings. */
#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void)val, err) #define INTERNAL_SYSCALL_ERROR_P(val, err) ((void)val, err)
@ -205,172 +211,126 @@ __LABEL(name) \
#define inline_syscall0(name, args...) \ #define inline_syscall0(name, args...) \
{ \ { \
register long _sc_0; \
register long _sc_19 __asm__("$19"); \ register long _sc_19 __asm__("$19"); \
\ register long _sc_0 = name; \
_sc_0 = name; \
__asm__ __volatile__ \ __asm__ __volatile__ \
("callsys # %0 %1 <= %2" \ ("callsys # %0 %1 <= %2" \
: "=v"(_sc_0), "=r"(_sc_19) \ : "+v"(_sc_0), "=r"(_sc_19) \
: "0"(_sc_0) \ : : inline_syscall_clobbers, \
: inline_syscall_clobbers, \
"$16", "$17", "$18", "$20", "$21"); \ "$16", "$17", "$18", "$20", "$21"); \
_sc_ret = _sc_0, _sc_err = _sc_19; \ _sc_ret = _sc_0, _sc_err = _sc_19; \
} }
#define inline_syscall1(name,arg1) \ #define inline_syscall1(name,arg1) \
{ \ { \
register long _sc_0; \ register long _tmp_16 = syscall_promote (arg1); \
register long _sc_16 __asm__("$16"); \ register long _sc_0 = name; \
register long _sc_16 __asm__("$16") = _tmp_16; \
register long _sc_19 __asm__("$19"); \ register long _sc_19 __asm__("$19"); \
register long _tmp_16 = (long) (arg1); \
\
_sc_0 = name; \
_sc_16 = _tmp_16; \
__asm__ __volatile__ \ __asm__ __volatile__ \
("callsys # %0 %1 <= %2 %3" \ ("callsys # %0 %1 <= %2 %3" \
: "=v"(_sc_0), "=r"(_sc_19), "=r"(_sc_16) \ : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16) \
: "0"(_sc_0), "2"(_sc_16) \ : : inline_syscall_clobbers, \
: inline_syscall_clobbers, \
"$17", "$18", "$20", "$21"); \ "$17", "$18", "$20", "$21"); \
_sc_ret = _sc_0, _sc_err = _sc_19; \ _sc_ret = _sc_0, _sc_err = _sc_19; \
} }
#define inline_syscall2(name,arg1,arg2) \ #define inline_syscall2(name,arg1,arg2) \
{ \ { \
register long _sc_0; \ register long _tmp_16 = syscall_promote (arg1); \
register long _sc_16 __asm__("$16"); \ register long _tmp_17 = syscall_promote (arg2); \
register long _sc_17 __asm__("$17"); \ register long _sc_0 = name; \
register long _sc_16 __asm__("$16") = _tmp_16; \
register long _sc_17 __asm__("$17") = _tmp_17; \
register long _sc_19 __asm__("$19"); \ register long _sc_19 __asm__("$19"); \
register long _tmp_16 = (long) (arg1); \
register long _tmp_17 = (long) (arg2); \
\
_sc_0 = name; \
_sc_16 = _tmp_16; \
_sc_17 = _tmp_17; \
__asm__ __volatile__ \ __asm__ __volatile__ \
("callsys # %0 %1 <= %2 %3 %4" \ ("callsys # %0 %1 <= %2 %3 %4" \
: "=v"(_sc_0), "=r"(_sc_19), \ : "+v"(_sc_0), "=r"(_sc_19), \
"=r"(_sc_16), "=r"(_sc_17) \ "+r"(_sc_16), "+r"(_sc_17) \
: "0"(_sc_0), "2"(_sc_16), "3"(_sc_17) \ : : inline_syscall_clobbers, \
: inline_syscall_clobbers, \
"$18", "$20", "$21"); \ "$18", "$20", "$21"); \
_sc_ret = _sc_0, _sc_err = _sc_19; \ _sc_ret = _sc_0, _sc_err = _sc_19; \
} }
#define inline_syscall3(name,arg1,arg2,arg3) \ #define inline_syscall3(name,arg1,arg2,arg3) \
{ \ { \
register long _sc_0; \ register long _tmp_16 = syscall_promote (arg1); \
register long _sc_16 __asm__("$16"); \ register long _tmp_17 = syscall_promote (arg2); \
register long _sc_17 __asm__("$17"); \ register long _tmp_18 = syscall_promote (arg3); \
register long _sc_18 __asm__("$18"); \ 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"); \ register long _sc_19 __asm__("$19"); \
register long _tmp_16 = (long) (arg1); \
register long _tmp_17 = (long) (arg2); \
register long _tmp_18 = (long) (arg3); \
\
_sc_0 = name; \
_sc_16 = _tmp_16; \
_sc_17 = _tmp_17; \
_sc_18 = _tmp_18; \
__asm__ __volatile__ \ __asm__ __volatile__ \
("callsys # %0 %1 <= %2 %3 %4 %5" \ ("callsys # %0 %1 <= %2 %3 %4 %5" \
: "=v"(_sc_0), "=r"(_sc_19), "=r"(_sc_16), \ : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16), \
"=r"(_sc_17), "=r"(_sc_18) \ "+r"(_sc_17), "+r"(_sc_18) \
: "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), \ : : inline_syscall_clobbers, "$20", "$21"); \
"4"(_sc_18) \
: inline_syscall_clobbers, "$20", "$21"); \
_sc_ret = _sc_0, _sc_err = _sc_19; \ _sc_ret = _sc_0, _sc_err = _sc_19; \
} }
#define inline_syscall4(name,arg1,arg2,arg3,arg4) \ #define inline_syscall4(name,arg1,arg2,arg3,arg4) \
{ \ { \
register long _sc_0; \ register long _tmp_16 = syscall_promote (arg1); \
register long _sc_16 __asm__("$16"); \ register long _tmp_17 = syscall_promote (arg2); \
register long _sc_17 __asm__("$17"); \ register long _tmp_18 = syscall_promote (arg3); \
register long _sc_18 __asm__("$18"); \ register long _tmp_19 = syscall_promote (arg4); \
register long _sc_19 __asm__("$19"); \ register long _sc_0 = name; \
register long _tmp_16 = (long) (arg1); \ register long _sc_16 __asm__("$16") = _tmp_16; \
register long _tmp_17 = (long) (arg2); \ register long _sc_17 __asm__("$17") = _tmp_17; \
register long _tmp_18 = (long) (arg3); \ register long _sc_18 __asm__("$18") = _tmp_18; \
register long _tmp_19 = (long) (arg4); \ register long _sc_19 __asm__("$19") = _tmp_19; \
\
_sc_0 = name; \
_sc_16 = _tmp_16; \
_sc_17 = _tmp_17; \
_sc_18 = _tmp_18; \
_sc_19 = _tmp_19; \
__asm__ __volatile__ \ __asm__ __volatile__ \
("callsys # %0 %1 <= %2 %3 %4 %5 %6" \ ("callsys # %0 %1 <= %2 %3 %4 %5 %6" \
: "=v"(_sc_0), "=r"(_sc_19), "=r"(_sc_16), \ : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
"=r"(_sc_17), "=r"(_sc_18) \ "+r"(_sc_17), "+r"(_sc_18) \
: "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), \ : : inline_syscall_clobbers, "$20", "$21"); \
"4"(_sc_18), "1"(_sc_19) \
: inline_syscall_clobbers, "$20", "$21"); \
_sc_ret = _sc_0, _sc_err = _sc_19; \ _sc_ret = _sc_0, _sc_err = _sc_19; \
} }
#define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \ #define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
{ \ { \
register long _sc_0; \ register long _tmp_16 = syscall_promote (arg1); \
register long _sc_16 __asm__("$16"); \ register long _tmp_17 = syscall_promote (arg2); \
register long _sc_17 __asm__("$17"); \ register long _tmp_18 = syscall_promote (arg3); \
register long _sc_18 __asm__("$18"); \ register long _tmp_19 = syscall_promote (arg4); \
register long _sc_19 __asm__("$19"); \ register long _tmp_20 = syscall_promote (arg5); \
register long _sc_20 __asm__("$20"); \ register long _sc_0 = name; \
register long _tmp_16 = (long) (arg1); \ register long _sc_16 __asm__("$16") = _tmp_16; \
register long _tmp_17 = (long) (arg2); \ register long _sc_17 __asm__("$17") = _tmp_17; \
register long _tmp_18 = (long) (arg3); \ register long _sc_18 __asm__("$18") = _tmp_18; \
register long _tmp_19 = (long) (arg4); \ register long _sc_19 __asm__("$19") = _tmp_19; \
register long _tmp_20 = (long) (arg5); \ register long _sc_20 __asm__("$20") = _tmp_20; \
\
_sc_0 = name; \
_sc_16 = _tmp_16; \
_sc_17 = _tmp_17; \
_sc_18 = _tmp_18; \
_sc_19 = _tmp_19; \
_sc_20 = _tmp_20; \
__asm__ __volatile__ \ __asm__ __volatile__ \
("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7" \ ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7" \
: "=v"(_sc_0), "=r"(_sc_19), "=r"(_sc_16), \ : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
"=r"(_sc_17), "=r"(_sc_18), "=r"(_sc_20) \ "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20) \
: "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), \ : : inline_syscall_clobbers, "$21"); \
"4"(_sc_18), "1"(_sc_19), "5"(_sc_20) \
: inline_syscall_clobbers, "$21"); \
_sc_ret = _sc_0, _sc_err = _sc_19; \ _sc_ret = _sc_0, _sc_err = _sc_19; \
} }
#define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \ #define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
{ \ { \
register long _sc_0; \ register long _tmp_16 = syscall_promote (arg1); \
register long _sc_16 __asm__("$16"); \ register long _tmp_17 = syscall_promote (arg2); \
register long _sc_17 __asm__("$17"); \ register long _tmp_18 = syscall_promote (arg3); \
register long _sc_18 __asm__("$18"); \ register long _tmp_19 = syscall_promote (arg4); \
register long _sc_19 __asm__("$19"); \ register long _tmp_20 = syscall_promote (arg5); \
register long _sc_20 __asm__("$20"); \ register long _tmp_21 = syscall_promote (arg6); \
register long _sc_21 __asm__("$21"); \ register long _sc_0 = name; \
register long _tmp_16 = (long) (arg1); \ register long _sc_16 __asm__("$16") = _tmp_16; \
register long _tmp_17 = (long) (arg2); \ register long _sc_17 __asm__("$17") = _tmp_17; \
register long _tmp_18 = (long) (arg3); \ register long _sc_18 __asm__("$18") = _tmp_18; \
register long _tmp_19 = (long) (arg4); \ register long _sc_19 __asm__("$19") = _tmp_19; \
register long _tmp_20 = (long) (arg5); \ register long _sc_20 __asm__("$20") = _tmp_20; \
register long _tmp_21 = (long) (arg6); \ register long _sc_21 __asm__("$21") = _tmp_21; \
\
_sc_0 = name; \
_sc_16 = _tmp_16; \
_sc_17 = _tmp_17; \
_sc_18 = _tmp_18; \
_sc_19 = _tmp_19; \
_sc_20 = _tmp_20; \
_sc_21 = _tmp_21; \
__asm__ __volatile__ \ __asm__ __volatile__ \
("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8" \ ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8" \
: "=v"(_sc_0), "=r"(_sc_19), "=r"(_sc_16), \ : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
"=r"(_sc_17), "=r"(_sc_18), "=r"(_sc_20), \ "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20), \
"=r"(_sc_21) \ "+r"(_sc_21) \
: "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), "4"(_sc_18), \ : : inline_syscall_clobbers); \
"1"(_sc_19), "5"(_sc_20), "6"(_sc_21) \
: inline_syscall_clobbers); \
_sc_ret = _sc_0, _sc_err = _sc_19; \ _sc_ret = _sc_0, _sc_err = _sc_19; \
} }

View File

@ -1,31 +0,0 @@
/* Copyright (C) 1998, 2000, 2003, 2004 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <errno.h>
#include <unistd.h>
#include <setxid.h>
int
__setregid (gid_t rgid, gid_t egid)
{
return INLINE_SETXID_SYSCALL (setregid, 2, (int) rgid, (int) egid);
}
#ifndef __setregid
weak_alias (__setregid, setregid)
#endif

View File

@ -1,33 +0,0 @@
/* Copyright (C) 1998, 2000, 2003, 2004 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <errno.h>
#include <unistd.h>
#include <setxid.h>
int
__setresgid (gid_t rgid, gid_t egid, gid_t sgid)
{
return INLINE_SETXID_SYSCALL (setresgid, 3, (int) rgid,
(int) egid, (int) sgid);
}
libc_hidden_def (__setresgid)
#ifndef __setresgid
weak_alias (__setresgid, setresgid)
#endif

View File

@ -1,33 +0,0 @@
/* Copyright (C) 1998, 2000, 2003, 2004 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <errno.h>
#include <unistd.h>
#include <setxid.h>
int
__setresuid (uid_t ruid, uid_t euid, uid_t suid)
{
return INLINE_SETXID_SYSCALL (setresuid, 3, (int) ruid,
(int) euid, (int) suid);
}
libc_hidden_def (__setresuid)
#ifndef __setresuid
weak_alias (__setresuid, setresuid)
#endif

View File

@ -1,31 +0,0 @@
/* Copyright (C) 1998, 2000, 2003, 2004 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <errno.h>
#include <unistd.h>
#include <setxid.h>
int
__setreuid (uid_t ruid, uid_t euid)
{
return INLINE_SETXID_SYSCALL (setreuid, 2, (int) ruid, (int) euid);
}
#ifndef __setreuid
weak_alias (__setreuid, setreuid)
#endif