【问题标题】:Where is linux-vdso.so.1 present on the file system文件系统上的 linux-vdso.so.1 在哪里
【发布时间】:2020-02-27 14:54:51
【问题描述】:

我正在学习 VDSO,写了一个简单的应用程序调用 gettimeofday()

#define _GNU_SOURCE
#include <sys/syscall.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
    struct timeval current_time;

    if (gettimeofday(&current_time, NULL) == -1)
        printf("gettimeofday");

    getchar();

    exit(EXIT_SUCCESS);
}

二进制文件上的ldd显示'linux-vdso'

$ ldd ./prog
    linux-vdso.so.1 (0x00007ffce147a000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6ef9e8e000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f6efa481000)

我找到了 libvdso 库,但我的文件系统中没有这样的库。

sudo find / -name 'linux-vdso.so*'

图书馆在哪里?

【问题讨论】:

标签: c linux linux-kernel shared-libraries


【解决方案1】:

它是一个虚拟共享对象,在磁盘上没有任何物理文件;它是内核的一部分,在加载时会导出到每个程序的地址空间中。

主要目的是提高调用某些系统调用的效率(否则会产生performance issues like this)。最突出的是gettimeofday(2).

您可以在此处阅读更多信息:http://man7.org/linux/man-pages/man7/vdso.7.html

【解决方案2】:
find / -name '*vdso*.so*' 

产量

/lib/modules/4.15.0-108-generic/vdso/vdso64.so
/lib/modules/4.15.0-108-generic/vdso/vdso32.so
/lib/modules/4.15.0-108-generic/vdso/vdsox32.so

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-21
    • 2012-12-12
    • 2013-04-03
    • 1970-01-01
    • 1970-01-01
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多