This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] Add AT_SYSINFO_EHDR only support
- From: Steve Munroe <sjmunroe at us dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com, Benjamin Herrenschmidt <benh at kernel dot crashing dot org>, Dwayne McConnell <dgm69 at us dot ibm dot com>
- Date: Fri, 05 Nov 2004 17:30:09 -0600
- Subject: [PATCH] Add AT_SYSINFO_EHDR only support
- Organization: IBM LTC
- Reply-to: sjmunroe at vnet dot ibm dot com
This patch adds support for architectures that want to use VDSO as a
library but don't need all the (Intel specific) syscall mechanism.
Specifically for kernels that provide AT_SYSINFO_EHDR but not AT_SYSINFO.
The 1st patched defines the new macro NEED_DL_SYSINFO_EHDR and made the
parts that implement function specific AT_SYSINFO_EHDR conditional on:
#if defined NEED_DL_SYSINFO || NEED_DL_SYSINFO_EHDR
This means platforms that currently use AT_SYSINFO don't change and
platforms that only need AT_SYSINFO_EHDR can do so by defining only
NEED_DL_SYSINFO_EHDR.
The 2nd patch adds VDSO (AT_SYSINFO_EHDR only) support for Powerpc
Linuxthread.
The 3rd patch adds VDSO (AT_SYSINFO_EHDR only) support for Powerpc nptl.
2004-11-05 Steven Munroe <sjmunroe@us.ibm.com>
* elf/dl-support.c [NEED_DL_SYSINFO||NEED_DL_SYSINFO_EHDR]:
Declare _dl_sysinfo_dso.
* elf/rtld.c [NEED_DL_SYSINFO||NEED_DL_SYSINFO_EHDR]:
Load the VDSO map.
* sysdeps/generic/dl-sysdep.c [NEED_DL_SYSINFO||NEED_DL_SYSINFO_EHDR]:
Set _dl_sysinfo_dso from AT_SYSINFO_EHDR.
* sysdeps/generic/ldsodefs.h [NEED_DL_SYSINFO||NEED_DL_SYSINFO_EHDR]:
Declare _dl_sysinfo_dso extern.
diff -urN libc23-cvstip-20041105/elf/dl-support.c libc23/elf/dl-support.c
--- libc23-cvstip-20041105/elf/dl-support.c 2004-10-13 21:06:18.000000000 -0500
+++ libc23/elf/dl-support.c 2004-11-05 13:54:00.293452824 -0600
@@ -136,6 +136,8 @@
#ifdef NEED_DL_SYSINFO
/* Needed for improved syscall handling on at least x86/Linux. */
uintptr_t _dl_sysinfo = DL_SYSINFO_DEFAULT;
+#endif
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_EHDR
/* Address of the ELF headers in the vsyscall page. */
const ElfW(Ehdr) *_dl_sysinfo_dso;
#endif
diff -urN libc23-cvstip-20041105/elf/rtld.c libc23/elf/rtld.c
--- libc23-cvstip-20041105/elf/rtld.c 2004-10-14 04:23:31.000000000 -0500
+++ libc23/elf/rtld.c 2004-11-05 13:55:01.379484504 -0600
@@ -1274,7 +1274,7 @@
assert (i == npreloads);
}
-#ifdef NEED_DL_SYSINFO
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_EHDR
struct link_map *sysinfo_map = NULL;
if (GLRO(dl_sysinfo_dso) != NULL)
{
@@ -1336,10 +1336,11 @@
_dl_fatal_printf ("out of memory\n");
l->l_libname->name = memcpy (copy, dsoname, len);
}
-
+#ifdef NEED_DL_SYSINFO
/* We have a prelinked DSO preloaded by the system. */
if (GLRO(dl_sysinfo) == DL_SYSINFO_DEFAULT)
GLRO(dl_sysinfo) = GLRO(dl_sysinfo_dso)->e_entry + l->l_addr;
+#endif
sysinfo_map = l;
}
}
@@ -1389,7 +1390,7 @@
GL(dl_rtld_map).l_next = (i + 1 < main_map->l_searchlist.r_nlist
? main_map->l_searchlist.r_list[i + 1]
: NULL);
-#ifdef NEED_DL_SYSINFO
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_EHDR
if (sysinfo_map != NULL
&& GL(dl_rtld_map).l_prev->l_next == sysinfo_map
&& GL(dl_rtld_map).l_next != sysinfo_map)
diff -urN libc23-cvstip-20041105/sysdeps/generic/dl-sysdep.c libc23/sysdeps/generic/dl-sysdep.c
--- libc23-cvstip-20041105/sysdeps/generic/dl-sysdep.c 2004-04-01 02:55:15.000000000 -0600
+++ libc23/sysdeps/generic/dl-sysdep.c 2004-11-05 13:53:10.321460032 -0600
@@ -161,6 +161,8 @@
case AT_SYSINFO:
new_sysinfo = av->a_un.a_val;
break;
+#endif
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_EHDR
case AT_SYSINFO_EHDR:
GLRO(dl_sysinfo_dso) = av->a_un.a_ptr;
break;
@@ -289,6 +291,8 @@
[AT_SECURE - 2] = { "AT_SECURE: ", dec },
#ifdef NEED_DL_SYSINFO
[AT_SYSINFO - 2] = { "AT_SYSINFO: 0x", hex },
+#endif
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_EHDR
[AT_SYSINFO_EHDR - 2] = { "AT_SYSINFO_EHDR: 0x", hex },
#endif
};
diff -urN libc23-cvstip-20041105/sysdeps/generic/ldsodefs.h libc23/sysdeps/generic/ldsodefs.h
--- libc23-cvstip-20041105/sysdeps/generic/ldsodefs.h 2004-10-19 17:19:17.000000000 -0500
+++ libc23/sysdeps/generic/ldsodefs.h 2004-11-05 14:46:07.502445680 -0600
@@ -470,7 +470,8 @@
#ifdef NEED_DL_SYSINFO
/* Syscall handling improvements. This is very specific to x86. */
EXTERN uintptr_t _dl_sysinfo;
-
+#endif
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_EHDR
/* The vsyscall page is a virtual DSO pre-mapped by the kernel.
This points to its ELF header. */
EXTERN const ElfW(Ehdr) *_dl_sysinfo_dso;
2004-11-05 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h: New file.
diff -urN libc23-cvstip-20041105/linuxthreads/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h libc23/linuxthreads/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h
--- libc23-cvstip-20041105/linuxthreads/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h Wed Dec 31 18:00:00 1969
+++ libc23/linuxthreads/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h Fri Nov 05 16:39:41 2004
@@ -0,0 +1,41 @@
+/* System-specific settings for dynamic linker code. powerpc version.
+ Copyright (C) 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. */
+
+#ifndef _DL_SYSDEP_H
+#define _DL_SYSDEP_H 1
+
+/* Traditionally system calls have been used to access kernel services.
+ For some of these services the system call overhead is a significant
+ part of the total service time and Kernel privilege is not
+ required. Or the kernel knows detail of the processor implementation
+ that allow for critical optimizations not possible in generalized
+ libraries. Or the kernel needs to insert a fragment of code into
+ the application, like a signal trampoline.
+
+ All of this can be served by a mechanism that allows the kernel to
+ provide a DSO library without requiring explicit linking. Such a
+ is virtual (VDSO) because it may be wholly manufactured by the
+ kernel. To signal the presence a VDSO library, the kernel passes
+ an AT_SYSINFO_EHDR value in the auxiliary vector to the
+ application. This allows symbols from the VDSO library to be
+ merged with the applications symbols. */
+
+#define NEED_DL_SYSINFO_EHDR 1
+
+#endif /* dl-sysdep.h */
2004-11-05 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h: New file.
diff -urN libc23-cvstip-20041105/nptl/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h libc23/nptl/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h
--- libc23-cvstip-20041105/nptl/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h Wed Dec 31 18:00:00 1969
+++ libc23/nptl/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.h Fri Nov 05 16:39:27 2004
@@ -0,0 +1,41 @@
+/* System-specific settings for dynamic linker code. powerpc version.
+ Copyright (C) 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. */
+
+#ifndef _DL_SYSDEP_H
+#define _DL_SYSDEP_H 1
+
+/* Traditionally system calls have been used to access kernel services.
+ For some of these services the system call overhead is a significant
+ part of the total service time and Kernel privilege is not
+ required. Or the kernel knows detail of the processor implementation
+ that allow for critical optimizations not possible in generalized
+ libraries. Or the kernel needs to insert a fragment of code into
+ the application, like a signal trampoline.
+
+ All of this can be served by a mechanism that allows the kernel to
+ provide a DSO library without requiring explicit linking. Such a
+ is virtual (VDSO) because it may be wholly manufactured by the
+ kernel. To signal the presence a VDSO library, the kernel passes
+ an AT_SYSINFO_EHDR value in the auxiliary vector to the
+ application. This allows symbols from the VDSO library to be
+ merged with the applications symbols. */
+
+#define NEED_DL_SYSINFO_EHDR 1
+
+#endif /* dl-sysdep.h */