15

I noticed that all my programs compiled to gcc are linked to vdso library. Is this the library that contain the system calls to the kernel, like mmap() and fork() and other system calls?

I know that system calls are not functions of the GNU C standard library so their object code must be in some library that is linked with the application at the compilation?

So is the vdso that library?

2
  • It may be. What issues are you trying to solve?
    – Kusalananda
    Oct 9, 2017 at 11:24
  • 1
    @Kusalananda I do not have any issue whatsoever. I am trying to learn more about how the C compiler works how the linker works and to basically be a better programmer and computer scientist.
    – yoyo_fun
    Oct 9, 2017 at 11:32

1 Answer 1

20

System calls are implemented in the kernel, as mentioned in the answer to your followup question. vDSO, the virtual dynamic shared object, is a small virtual library, also implemented by the kernel, which the kernel maps into all processes. Like syscalls it is wrapped by the C library.

The main difference between syscalls and the vDSO is one of privilege. System calls are executed in kernel space, and switching between user space and kernel space is expensive. As an optimisation, some system calls which don’t actually need to run in kernel space are provided in the vDSO, which runs in user space. An example is gettimeofday which tends to be called quite often and can be implemented by the kernel without switching to kernel space.

The vdso manpage has more details. For a detailed discussion of system calls on Linux in general, including vDSO, see Anatomy of a system call part 1 and part 2.

2
  • 1
    Very good answer! The whole vDSO concept is something introduced in kernel at cirka 2.6 time. Older (= ancient) kernel versions did not do it this way. Jan 23, 2019 at 8:48
  • 2
    Came here after clicking promising first Google link ... linux-vdso.so
    – earcam
    Feb 4, 2019 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .