Skip to content
Official PYQ · 2004

GATE CS 2004 Q9 — Parsing (LL, LR)

Explain with AI

Consider a program PP that consists of two source modules M1M_1 and M2M_2 contained in two different files. If M1M_1 contains a reference to a function defined in M2M_2 the reference will be resolved at 

Choose one option
View worked solution

Answer: C

The correct option is C.

When a program consists of multiple independent source modules (like M1M_1 and M2M_2):

  1. Compile Time: Each module is compiled separately into its own object file. During the compilation of M1M_1, the compiler encounters the reference to the function defined in M2M_2. Since M2M_2 is in a different file, the compiler cannot determine its address and leaves it as an unresolved external reference in the object code of M1M_1.
  2. Link Time: The linker takes the individual object files of M1M_1 and M2M_2 as input, combines them, and resolves all external references. It matches the function call in M1M_1 with its actual definition in M2M_2, assigning the correct relative addresses.
  3. 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.

Published
Report a correction
Keep exploringMore Parsing (LL, LR) questions