Linking/API Calls

How do multiple source files become a single executable?

ELF file formats:

  • Executable file
  • Shared Object file
  • Relocatable file
  • and some others

ELF Header specifies the file format

 + Executable: specifies how to load the program into a process image (remember exec and forking?)

 

 + Relocatable: specifies how to include it's own code and data into an Executable or Shared object. Object files waiting to be included.

 

 + Shared Object: Dynamic library that links with an executable on load by a linker. Think printf, Libc, stdio.h 

How do multiple source files become a single executable?

ELF file formats:

  • Executable file
  • Shared Object file
  • Relocatable file

Linker links objects with shared libraries.

What does the whole pipeline look like then?

1. Gcc compiles into ELF Relocatables

 

2. Linker links Relocatables and attaches necessary information for SO linking into an Executable

 

3. Loader execs the Executable, then the dynamic linker actually links to the shared objects for code execution. 

If a Shared Object is a Dynamic Library, then what is a Static Library?

Static libraries are a collection of Relocatables!

 

Where in the pipeline should they take part?

Linking

By Drake P