Linkers, Loaders & Executables
What is the main role of a linker?
- ATo combine object files and libraries, bind names to addresses and produce an executable
- BTo find and report grammar errors in source code
- CTo automatically free a running program's memory when it is no longer used
Show answer and explanation
Answer: A. To combine object files and libraries, bind names to addresses and produce an executable
The linker matches each name (symbol) referenced in the object files with a definition somewhere (symbol resolution), lays out every file's code and data to decide final addresses, and rewrites placeholder addresses in instructions with the right values (relocation). It also pulls in functions from libraries as needed. The result is an executable that the OS can load and run.
- A. Correct. It performs symbol resolution and relocation.
- B. The compiler finds grammar errors.
- C. That is a garbage collector's job.