What is Object file?

The file a compiler produces from one source file. It contains machine code, initial data, a symbol table and relocation entries, but addresses in other files are unresolved, so it cannot run until linked.

Field: Linkers, Loaders & Executables

Object file in the explanations

Questions that mention Object file (5)

  1. Which statement is correct about the object file (.o) a compiler produces from one source file?
  2. With the GNU linker, writing a static library before the object file that uses it, as in "gcc -lmylib main.o", can cause undefined-reference errors. Why?
  3. Disassembling an object file shows that an instruction calling the external function printf has a placeholder target such as 0. When is the correct value filled in?
  4. What is the usual sequence for producing an executable from a C program?
  5. Linking a C program gives "undefined reference to `foo'". What is the most likely cause?

Related terms

Linker Relocation Symbol table Static library Dynamic linking Procedure linkage table (PLT) Dynamic linker Assembler Address space layout randomization (ASLR) BSS section

Back to the glossary