Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is linux-vdso.so.1 present on the file system

I am learning about VDSO, wrote a simple application which calls 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 on the binary shows '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) 

I did a find for the libvdso library and there is no such library present in my file system.

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

Where is the library present?

like image 943
md.jamal Avatar asked Nov 01 '19 09:11

md.jamal


People also ask

Where is Linux vDSO?

NOTES top. Source When you compile the kernel, it will automatically compile and link the vDSO code for you. You will frequently find it under the architecture-specific directory: find arch/$ARCH/ -name '*vdso*.

What is Linux gate so 1?

linux-gate.so.1 is nothing but the Linux Virtual Dynamic Shared Object. This file only exists in each executables address space. In other words you don't have to copy or worry about this file as it is a virtual library.

What is Vsyscall?

virtual system call(vsyscall) is the first mechanism in Linux kernel to try to accelerate the execution of some certain system calls. The idea behind vsyscall is simple. Some system call just return data to user space. If the kernel maps these system call implementation and the related-data into user space pages.


1 Answers

It's a virtual shared object that doesn't have any physical file on the disk; it's a part of the kernel that's exported into every program's address space when it's loaded.

It's main purpose to make more efficient to call certain system calls (which would otherwise incur performance issues like this). The most prominent being gettimeofday(2).

You can read more about it here: http://man7.org/linux/man-pages/man7/vdso.7.html

like image 200
P.P Avatar answered Sep 22 '22 14:09

P.P