News for hackers. Stuff that matters.
Re:How statically linked programs run on Linux by amscanne on Sunday November 17, 2013 @10:25PM (#6752316)
Interesting list!

I was actually surprised that the VDSO [1] page was missing from that. For those unfamiliar... the Linux kernel selects the best system call implementation for the current system and exports a special page to user-space. It also provides a few specific additional routines (generally related to getting the current time without having to jump in and out of the kernel).

I'm not advocating for this approach, but it's there and can have a big impact. As a fun exercise, I just checked how much impact this has on my VM right now...

timetest.c:

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

    int main(void) {
        for (int i = 0; i < 1000000000; i++) {
            time(NULL);
        }
    }
gcc timetest.c -o timetest -std=c99 && time ./timetest

    real	0m3.589s
    user	0m3.588s
    sys 	0m0.000s
gcc timetest.c -o timetest -std=c99 -static && time ./timetest

    real	0m41.436s
    user	0m16.900s
    sys 	0m24.456s
[1] http://en.wikipedia.org/wiki/VDSO

There are no comments on this comment yet.