4

Here is a quick sample program. (This will basically get the procmap associated with the process)

> cat sample.c

#include<stdio.h>

int main() 
{
    char buffer[1000];
    sprintf(buffer, "cat /proc/%d/maps\n", getpid());
    int status = system(buffer);
    return 1;
}

Preparing it statically

> gcc -static -o sample sample.c 
> file sample
sample: ELF 64-bit LSB  executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.24, BuildID[sha1]=9bb9f33e867df8f2d56ffb4bfb5d348c544b1050, not stripped

Executing the binary

> ./sample
00400000-004c0000 r-xp 00000000 08:01 12337398                           /home/admin/sample
006bf000-006c2000 rw-p 000bf000 08:01 12337398                           /home/admin/sample
006c2000-006c5000 rw-p 00000000 00:00 0 
0107c000-0109f000 rw-p 00000000 00:00 0                                  [heap]
7ffdb3d78000-7ffdb3d99000 rw-p 00000000 00:00 0                          [stack]
7ffdb3de7000-7ffdb3de9000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

I googled about vDSO but did not understand properly. Wikipedia says "these are ways in which kernel routines can be accessed from user space". My question is why are these shared objects appearing in execution of static binaries?

VividD
  • 10,456
  • 6
  • 64
  • 111
Sandhya Kumar
  • 293
  • 3
  • 11

1 Answers1

2

My question is why are these shared objects appearing in execution of static binaries?

They appear because your kernel "injects" them into every process.

Read more about them here and here.

Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362