Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to turn off vdso on glibc side?

I am aware that passing vdso=0 to kernel can turn this feature off, and that the dynamic linker in glibc can automatic detect and use vdso feature from kernel.

Here I met with this problem. There is a RHEL 5.6 box (kernel 2.6.18-238.el5) in my institution where I only have a normal user access, probably suffering from RHEL bug 673616.

As I compile a toolchain of linux-headers-3.9/gcc-4.7.2/glibc-2.17/binutils-2.23 on top of it, gcc bootstrap fails in cc1 in stage2 cannnot be run

Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaaaca6eb in ?? ()
(gdb) info sharedlibrary 
From                To                  Syms Read   Shared Object Library
0x00002aaaaaaabba0  0x00002aaaaaac3249  Yes (*)     /home/benda/gnto/lib64/ld-linux-x86-64.so.2
0x00002aaaaacd29b0  0x00002aaaaace2480  Yes (*)     /home/benda/gnto/usr/lib/libmpc.so.3
0x00002aaaaaef2cd0  0x00002aaaaaf36c08  Yes (*)     /home/benda/gnto/usr/lib/libmpfr.so.4
0x00002aaaab14f280  0x00002aaaab19b658  Yes (*)     /home/benda/gnto/usr/lib/libgmp.so.10
0x00002aaaab3b3060  0x00002aaaab3b3b50  Yes (*)     /home/benda/gnto/lib/libdl.so.2
0x00002aaaab5b87b0  0x00002aaaab5c4bb0  Yes (*)     /home/benda/gnto/usr/lib/libz.so.1
0x00002aaaab7d0e70  0x00002aaaab80f62c  Yes (*)     /home/benda/gnto/lib/libm.so.6
0x00002aaaaba70d40  0x00002aaaabb81aec  Yes (*)     /home/benda/gnto/lib/libc.so.6
(*): Shared library is missing debugging information.

and a simple program

#include <sys/time.h>
#include <stdio.h>

int main () {
    struct timeval tim;
    gettimeofday(&tim, NULL);
    return 0;
}

get segment fault in the same way if compiled against glibc-2.17 and xgcc from stage1.

Both cc1 and the test program can be run on another running RHEL 5.5 (kernel 2.6.18-194.26.1.el5) with gcc-4.7.2/glibc-2.17/binutils-2.23 as normal user.

I cannot simply upgrade the box to a newer RHEL version, nor could I turn VDSO off via sysctl or proc. The question is, is there a way to compile glibc so that it turns off VDSO unconditionally?

like image 425
heroxbd Avatar asked Oct 21 '22 06:10

heroxbd


1 Answers

The problem is solved with a simple patch or here:

Index: work/glibc-2.17/elf/dl-support.c
=====================================================================
--- work.orig/glibc-2.17/elf/dl-support.c
+++ work/glibc-2.17/elf/dl-support.c
@@ -212,16 +212,6 @@ _dl_aux_init (ElfW(auxv_t) *av)
       case AT_HWCAP:
    GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
    break;
-#ifdef NEED_DL_SYSINFO
-      case AT_SYSINFO:
-   GL(dl_sysinfo) = av->a_un.a_val;
-   break;
-#endif
-#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
-      case AT_SYSINFO_EHDR:
-   GL(dl_sysinfo_dso) = (void *) av->a_un.a_val;
-   break;
-#endif
       case AT_UID:
    uid ^= av->a_un.a_val;
    seen |= 1;
Index: work/glibc-2.17/elf/setup-vdso.h
=====================================================================
--- work.orig/glibc-2.17/elf/setup-vdso.h
+++ work/glibc-2.17/elf/setup-vdso.h
@@ -20,7 +20,7 @@ static inline void __attribute__ ((alway
 setup_vdso (struct link_map *main_map __attribute__ ((unused)),
        struct link_map ***first_preload __attribute__ ((unused)))
 {
-#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
+#if 0
   if (GLRO(dl_sysinfo_dso) == NULL)
     return;
 
like image 77
heroxbd Avatar answered Oct 26 '22 09:10

heroxbd