about summary refs log tree commit diff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-05-26 11:07:54 -0700
committerH.J. Lu <hjl.tools@gmail.com>2012-05-27 07:30:58 -0700
commit3a9b3bda44435152f22d46bea48fcc415a0c7eb9 (patch)
treeb6c8e73d57555cdb5253c68d662f5cbd9018eb83
parent20c66bdf49542974de36cf3a45de58b449c5681f (diff)
downloadglibc-3a9b3bda44435152f22d46bea48fcc415a0c7eb9.tar.gz
glibc-3a9b3bda44435152f22d46bea48fcc415a0c7eb9.tar.xz
glibc-3a9b3bda44435152f22d46bea48fcc415a0c7eb9.zip
Add x32 arch_prctl.c
-rw-r--r--ChangeLog.x326
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/x32/Makefile4
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/x32/arch_prctl.c64
3 files changed, 74 insertions, 0 deletions
diff --git a/ChangeLog.x32 b/ChangeLog.x32
index e6aaf5ece9..441a9c6f94 100644
--- a/ChangeLog.x32
+++ b/ChangeLog.x32
@@ -1,3 +1,9 @@
+2012-05-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* sysdeps/unix/sysv/linux/x86_64/x32/Makefile (sysdep_routines):
+	Add arch_prctl.
+	* sysdeps/unix/sysv/linux/x86_64/x32/arch_prctl.c: New file.
+
 2012-03-20  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* sysdeps/x86_64/bits/setjmp.h: Include <bits/wordsize.h>.
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/Makefile b/sysdeps/unix/sysv/linux/x86_64/x32/Makefile
index 5f77df7c7a..aa78238a0d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/Makefile
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/Makefile
@@ -1,3 +1,7 @@
+ifeq ($(subdir),misc)
+sysdep_routines += arch_prctl
+endif
+
 ifeq ($(subdir),posix)
 sysdep_routines += getcpu sched_getcpu-static
 endif
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/arch_prctl.c b/sysdeps/unix/sysv/linux/x86_64/x32/arch_prctl.c
new file mode 100644
index 0000000000..a4079af555
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/arch_prctl.c
@@ -0,0 +1,64 @@
+/* arch_prctl call for Linux/x32.
+   Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/prctl.h>
+#include <sys/syscall.h>
+#include <sysdep.h>
+
+/* Since x32 arch_prctl stores 32bit base address of segment register %fs
+   and %gs as unsigned 64bit value via ARCH_GET_FS and ARCH_GET_GS, we
+   use a local unsigned 64bit variable to hold the base address and copy
+   it to ADDR after arch_prctl return.  */
+
+int
+__arch_prctl (int code, unsigned long *addr)
+{
+  int res;
+  unsigned long long base_addr;
+  unsigned long *addr_saved;
+
+  switch (code)
+    {
+    case ARCH_GET_FS:
+    case ARCH_GET_GS:
+      addr_saved = addr;
+      addr = &base_addr;
+      break;
+
+    default:
+      break;
+    }
+
+  res = INLINE_SYSCALL (arch_prctl, 2, code, addr);
+  if (res == 0)
+    switch (code)
+      {
+      case ARCH_GET_FS:
+      case ARCH_GET_GS:
+	*addr_saved = (unsigned long) base_addr;
+	break;
+
+      default:
+	break;
+      }
+
+  return res;
+}
+
+weak_alias (__arch_prctl, arch_prctl);