Consider a program that consists of two source modules and contained in two different files. If contains a reference to a function defined in the reference will be resolved at
View worked solution
Answer: C
The correct option is C.
When a program consists of multiple independent source modules (like and ):
- Compile Time: Each module is compiled separately into its own object file. During the compilation of , the compiler encounters the reference to the function defined in . Since is in a different file, the compiler cannot determine its address and leaves it as an unresolved external reference in the object code of .
- Link Time: The linker takes the individual object files of and as input, combines them, and resolves all external references. It matches the function call in with its actual definition in , assigning the correct relative addresses.
- Load Time: The loader places the executable into the main memory for execution, adjusting any absolute addresses if necessary, but the inter-module symbol resolution has already been completed by the linker.
Thus, the reference to a function defined in another module is resolved at Link time.
Free practice · Your answers on this page are not saved.
