Enable VDSO on statically linked programs.

Message ID Mnfuf10vYFqVF0Eler6YFBrQwLrnv8yCwWaN1VWlKDeEY3nFphfncM39FnGZfOj1N9YRaYw9Uo2LwF5TbOo6qZV1G6sKp046CcetAtIQ1xQ=@espindo.la
State New, archived
Headers

Commit Message

Rafael Avila de Espindola Sept. 5, 2018, 2:04 a.m. UTC
  All the required code already existed, and some of it was already
running.

AT_SYSINFO_EHDR is processed if NEED_DL_SYSINFO_DSO is defined, but it
looks like it always is. The call to setup_vdso is also unconditional,
so all that was left to do was setup the function pointers and use
them. This patch just deletes some #ifdef to enable that.
---

Any ideas on how to test this would be appreciated. Locally I have used
strace to check that the vdso is used, but it is not clear if I can use
strace in an automated test.

Is the copyright paperwork required when deleting code? :-)

2018-09-04  Rafael Ávila de Espíndola  <rafael@espindo.la>

	* sysdeps/unix/sysv/linux/sysdep-vdso.h: remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/x86_64/init-first.c: remove #ifdef SHARED.

sysdeps/unix/sysv/linux/sysdep-vdso.h       | 11 -----------
 sysdeps/unix/sysv/linux/x86/libc-vdso.h     |  4 ----
 sysdeps/unix/sysv/linux/x86_64/init-first.c |  2 --
 3 files changed, 17 deletions(-)
  

Comments

Rafael Avila de Espindola Sept. 10, 2018, 7:39 p.m. UTC | #1
Ping

"Rafael Avila de Espindola" <rafael@espindo.la> writes:

> All the required code already existed, and some of it was already
> running.
>
> AT_SYSINFO_EHDR is processed if NEED_DL_SYSINFO_DSO is defined, but it
> looks like it always is. The call to setup_vdso is also unconditional,
> so all that was left to do was setup the function pointers and use
> them. This patch just deletes some #ifdef to enable that.
> ---
>
> Any ideas on how to test this would be appreciated. Locally I have used
> strace to check that the vdso is used, but it is not clear if I can use
> strace in an automated test.
>
> Is the copyright paperwork required when deleting code? :-)
>
> 2018-09-04  Rafael Ávila de Espíndola  <rafael@espindo.la>
>
> 	* sysdeps/unix/sysv/linux/sysdep-vdso.h: remove #ifdef SHARED.
> 	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: remove #ifdef SHARED.
> 	* sysdeps/unix/sysv/linux/x86_64/init-first.c: remove #ifdef SHARED.
>
> sysdeps/unix/sysv/linux/sysdep-vdso.h       | 11 -----------
>  sysdeps/unix/sysv/linux/x86/libc-vdso.h     |  4 ----
>  sysdeps/unix/sysv/linux/x86_64/init-first.c |  2 --
>  3 files changed, 17 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
> index 1912c1c156..6736752de6 100644
> --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
> +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
> @@ -26,8 +26,6 @@
>       funcptr (args)
>  #endif
>  
> -#ifdef SHARED
> -
>  # ifdef HAVE_VSYSCALL
>  
>  #  include <libc-vdso.h>
> @@ -86,13 +84,4 @@
>      INTERNAL_SYSCALL (name, err, nr, ##args)
>  # endif /* HAVE_VSYSCALL  */
>  
> -# else /* SHARED  */
> -
> -#  define INLINE_VSYSCALL(name, nr, args...) \
> -    INLINE_SYSCALL (name, nr, ##args)
> -#  define INTERNAL_VSYSCALL(name, err, nr, args...) \
> -    INTERNAL_SYSCALL (name, err, nr, ##args)
> -
> -#endif /* SHARED  */
> -
>  #endif /* SYSDEP_VDSO_LINUX_H  */
> diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
> index 6f86073dae..669561166f 100644
> --- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h
> +++ b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
> @@ -22,8 +22,6 @@
>  #include <time.h>
>  #include <sys/time.h>
>  
> -#ifdef SHARED
> -
>  # include <sysdep-vdso.h>
>  
>  extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
> @@ -32,6 +30,4 @@ extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
>  extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
>    attribute_hidden;
>  
> -#endif
> -
>  #endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c
> index 2320505804..57d4f9838e 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/init-first.c
> +++ b/sysdeps/unix/sysv/linux/x86_64/init-first.c
> @@ -16,7 +16,6 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  
> -#ifdef SHARED
>  # include <time.h>
>  # include <sysdep.h>
>  # include <dl-vdso.h>
> @@ -47,6 +46,5 @@ __vdso_platform_setup (void)
>  }
>  
>  # define VDSO_SETUP __vdso_platform_setup
> -#endif
>  
>  #include <csu/init-first.c>
> -- 
> 2.17.1
  

Patch

diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
index 1912c1c156..6736752de6 100644
--- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
+++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
@@ -26,8 +26,6 @@ 
      funcptr (args)
 #endif
 
-#ifdef SHARED
-
 # ifdef HAVE_VSYSCALL
 
 #  include <libc-vdso.h>
@@ -86,13 +84,4 @@ 
     INTERNAL_SYSCALL (name, err, nr, ##args)
 # endif /* HAVE_VSYSCALL  */
 
-# else /* SHARED  */
-
-#  define INLINE_VSYSCALL(name, nr, args...) \
-    INLINE_SYSCALL (name, nr, ##args)
-#  define INTERNAL_VSYSCALL(name, err, nr, args...) \
-    INTERNAL_SYSCALL (name, err, nr, ##args)
-
-#endif /* SHARED  */
-
 #endif /* SYSDEP_VDSO_LINUX_H  */
diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
index 6f86073dae..669561166f 100644
--- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
@@ -22,8 +22,6 @@ 
 #include <time.h>
 #include <sys/time.h>
 
-#ifdef SHARED
-
 # include <sysdep-vdso.h>
 
 extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
@@ -32,6 +30,4 @@  extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
 extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
   attribute_hidden;
 
-#endif
-
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c
index 2320505804..57d4f9838e 100644
--- a/sysdeps/unix/sysv/linux/x86_64/init-first.c
+++ b/sysdeps/unix/sysv/linux/x86_64/init-first.c
@@ -16,7 +16,6 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef SHARED
 # include <time.h>
 # include <sysdep.h>
 # include <dl-vdso.h>
@@ -47,6 +46,5 @@  __vdso_platform_setup (void)
 }
 
 # define VDSO_SETUP __vdso_platform_setup
-#endif
 
 #include <csu/init-first.c>