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(¤t_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?
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*.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With