Linkers, Loaders & Executables
Which describes the symbol resolution a linker performs?
- AMatching a function or variable name used in one file with its definition in another file
- BReplacing variable names in source code with short names to make it hard to read
- CEvaluating expressions containing mathematical symbols into numbers
Show answer and explanation
Answer: A. Matching a function or variable name used in one file with its definition in another file
If main.c calls sum and sum.c defines it, main.o records "references sum" and sum.o records "defines sum". The linker collects the symbol tables of all object files and finds exactly one definition for each reference. If no definition is found it reports an undefined reference; if there are two or more it reports a multiple-definition error.
- A. Correct. It ties references to definitions.
- B. That is obfuscation, not a linker task.
- C. Symbols here are names of functions and variables.