Assemblers, Linkers and Loaders · Compiler Design
4 questions · asked in 4 of 27 years (2000–2026)
MCQ 41-mark 4
2000Questions per year2026
Questions 1–4 of 4
Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2 the reference will be resolved at
Answer: (C)
Each module is compiled on its own. While compiling M1, the compiler does not see M2, so it cannot know the address of the M2 function. It leaves the call as an unresolved external symbol in the object file of M1.
The linker then joins the object files, matches that symbol with the definition in M2 and fills in the address. So the reference is resolved at link time. For example, with gcc:
Answer: (C)
The linker then joins the object files, matches that symbol with the definition in M2 and fills in the address. So the reference is resolved at link time. For example, with gcc:
gcc -c c1.c -o c1.o gcc -c c2.c -o c2.o gcc c1.o c2.o -o C.exeThe first two commands only compile. The last command links.
Answer: (C)
Which of the following is NOT an advantage of using shared, dynamically linked libraries as opposed to using statically linked libraries?
Answer: (C)
Dynamic linking makes program startup slower, not faster. Before the program runs, the loader must find and map the shared libraries and set up the global offset table (GOT) so that library calls can be resolved. A statically linked program has all of this done already, at link time.
The other three are real advantages of shared libraries:
- (A) The library code is not copied into each executable, so executables are smaller.
- (B) One copy of the library in memory is shared by many processes, so less memory is used and the overall page fault rate in the system is lower.
- (D) A newer version of a library is picked up when the program is loaded, so existing programs need not be re-linked.
Answer: (C)
The other three are real advantages of shared libraries:
- (A) The library code is not copied into each executable, so executables are smaller.
- (B) One copy of the library in memory is shared by many processes, so less memory is used and the overall page fault rate in the system is lower.
- (D) A newer version of a library is picked up when the program is loaded, so existing programs need not be re-linked.
Answer: (C)
Dynamic linking can cause security concerns because
Answer: (B)
With dynamic linking, the program finds and loads its libraries at run time by searching a list of directories (for example, LD_LIBRARY_PATH on Linux or the DLL search order on Windows). Since this search path is not fixed until run time, an attacker who can place a harmful library with the same name in a directory searched earlier can make the program load it. That code then runs with the program's rights.
(A) "Security is dynamic" has no technical meaning here.
(C) Linking in itself is not insecure; static linking fixes the library code at build time.
(D) Cryptographic routines can be dynamically linked like any other library.
Answer: (B)
(A) "Security is dynamic" has no technical meaning here.
(C) Linking in itself is not insecure; static linking fixes the library code at build time.
(D) Cryptographic routines can be dynamically linked like any other library.
Answer: (B)
The process of assigning load addresses to the various parts of the program and adjusting the code and date in the program to reflect the assigned addresses is called
Answer: (C)
Relocation means giving load addresses to the parts of a program that depend on position. The code and data are then adjusted to match the assigned addresses.
So, Option C is the answer.
Symbol resolution means searching files and libraries. Symbolic references or library names are replaced with real, usable memory addresses before the program runs.
Keep practising
Topics in Compiler Design
Lexical AnalysisParsingSyntax-directed TranslationRuntime Environment
Assemblers, Linkers and LoadersYou are here
Intermediate Code GenerationMatching