Library segments

When linking a program, we have two broad choices:

  • Static linking
  • Dynamic linking

Static linking implies that any and all library text (code) and data is saved within the program's binary executable file (hence it's larger, and a bit faster to load up).

Dynamic linking implies that any and all shared library text (code) and data is not saved within the program's binary executable file; instead, it is shared by all processes and mapped into the process VAS at runtime (hence the binary executable is a lot smaller, though it might take a bit longer to load up). Dynamic linking is always the default.

Think about the Hello, world C program. You invoked printf(3), but did you write the code for it? No, of course not; we understand ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.