Which system program is responsible for placing an already linked (or relocatable) program into main memory and preparing it to begin execution?

Difficulty: Easy

Correct Answer: Loader

Explanation:


Introduction / Context:
After code is compiled and linked, the resulting executable must be mapped into memory so the CPU can run it. This final step assigns memory, fixes addresses if needed, and transfers control to the program's entry point. The component that performs these tasks is the loader.


Given Data / Assumptions:

  • Executable or relocatable image is available.
  • Operating system provides loading facilities.
  • Relocation and initialization may be required.


Concept / Approach:
The loader reads the program image, allocates memory, resolves relocations (if not already fixed), links with shared libraries at load time as necessary, sets up the stack and environment, and jumps to the entry point. Linkers combine modules; assemblers and compilers translate source code but do not run the program.


Step-by-Step Solution:

1) Open the executable image and parse headers to determine segments.2) Reserve and map code/data segments into main memory.3) Apply relocations and resolve dynamic libraries if applicable.4) Initialize runtime state and transfer control to the entry point.


Verification / Alternative check:
Tracing a program start shows the OS loader reading the binary, mapping sections, and invoking the program's main entry after runtime initialization.


Why Other Options Are Wrong:

  • Linker: Produces executables; does not execute them.
  • Assembler / Compiler: Translate code; not responsible for loading.
  • None of the above: Incorrect because the loader performs the setup.


Common Pitfalls:
Confusing static linking with loading; even statically linked programs require a loader to map and start execution.


Final Answer:
Loader

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion