【问题标题】:is it possible to turn off vdso on glibc side?是否可以在 glibc 端关闭 vdso?
【发布时间】:2013-06-28 16:29:52
【问题描述】:

我知道将 vdso=0 传递给内核可以关闭此功能,并且 glibc 中的动态链接器可以自动检测和使用内核中的 vdso 功能。

在这里我遇到了这个问题。在我的机构中有一个 RHEL 5.6 机器(内核 2.6.18-238.el5),我只有普通用户访问权限,可能患有RHEL bug 673616

当我在上面编译 linux-headers-3.9/gcc-4.7.2/glibc-2.17/binutils-2.23 的工具链时,gcc bootstrap 在第 2 阶段的 cc1 中失败,无法运行

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.

还有一个简单的程序

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

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

如果针对 glibc-2.17 和来自 stage1 的 xgcc 编译,则以相同的方式获取段错误。

cc1 和测试程序都可以在另一个正在运行的 RHEL 5.5(内核 2.6.18-194.26.1.el5)上以 gcc-4.7.2/glibc-2.17/binutils-2.23 作为普通用户运行。

我不能简单地将机器升级到较新的 RHEL 版本,也不能通过 sysctl 或 proc 关闭 VDSO。问题是,有没有办法编译 glibc 使其无条件关闭 VDSO?

【问题讨论】:

    标签: gcc linux-kernel glibc vdso


    【解决方案1】:

    问题通过simple patchhere 解决:

    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;
     
    

    【讨论】:

    • 请问补丁文件怎么用?
    • 当然,在编译 glibc 之前应用补丁,使用“patch”。 jungels.net/articles/diff-patch-ten-minutes.html
    • 没有回答“是否可以在 glibc 端关闭 vdso?”的问题。
    • 答案是“是”。
    猜你喜欢
    • 1970-01-01
    • 2011-01-05
    • 1970-01-01
    • 1970-01-01
    • 2011-01-04
    • 2020-03-10
    • 1970-01-01
    • 2018-09-11
    相关资源
    最近更新 更多