System call differences between static and dynamically linked programs

I'm working on an assignment and one of the questions has me explain the differences between straces of the same program, one dynamically linked and the other statically linked. Here are the straces:

Dynamic:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
  -nan    0.000000           0         1           read
  -nan    0.000000           0         1           write
  -nan    0.000000           0         2           open
  -nan    0.000000           0         2           close
  -nan    0.000000           0         1           execve
  -nan    0.000000           0         3         3 access
  -nan    0.000000           0         1           brk
  -nan    0.000000           0         1           munmap
  -nan    0.000000           0         3           mprotect
  -nan    0.000000           0         7           mmap2
  -nan    0.000000           0         3           fstat64
  -nan    0.000000           0         1           set_thread_area
------ ----------- ----------- --------- --------- ----------------
100.00    0.000000                    26         3 total


Static:
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
  -nan    0.000000           0         1           write
  -nan    0.000000           0         1           execve
  -nan    0.000000           0         4           brk
  -nan    0.000000           0         1           uname
  -nan    0.000000           0         1           mmap2
  -nan    0.000000           0         1           fstat64
  -nan    0.000000           0         1           set_thread_area
------ ----------- ----------- --------- --------- ----------------
100.00    0.000000                    10           total


It looks like the main difference here is the read, write, open, close at the beginning of the dynamically linked program. I'm assuming that is where it's going on and fetching the relevant library code? I'm not really sure where to start in figuring out exactly the reason behind these differences.
Bamp. Anyone know? Or have resources to point me to?
The shared library file has to be processed (opened, mapped, read, unmapped, closed) whereas the static library doesn't need to do that seperately as the code is part of the main program.

It's possible that your trace is seeing those operations.
Topic archived. No new replies allowed.