- 2069 Chaitra · 2 marks
Role of linker
Short answer
A linker combines one or more object files with required library routines to produce a single executable file. It resolves external references, assigns final addresses, and reports errors like undefined references.
Explain the role of linker.
A linker is a system program that combines one or more object files with the library routines they use and produces a single executable file.
Its roles are:
- Joins the object code of the main program, other modules and library functions (for example
printffrom the C library). - Resolves external references, so a function call in one module is connected to its definition in another.
- Assigns final relative addresses to the combined code and data.
- Reports an error such as "undefined reference" when a function used is not found.
Flow: source (.c) -> compiler -> object (.obj) -> linker (+ libraries) -> executable (.exe).
✓ Answer checked by Claude Opus 5.5 (high effort)