A linker is given object modules for a set of programs that were compi...
(c) is the answer. For linker to link external symbols (for example in C, to link an extern variable in one module to a global variable in another module), it must know the location of all external symbols. In C external symbols includes all global variables and function names.
(a) is trivially there is an object module. (b) must be there if we need to have relocation capability.
View all questions of this test
A linker is given object modules for a set of programs that were compi...
Object modules and Linkers
Object modules are created when a source code is compiled. It contains the machine language instructions and data required to run a program. A linker is a software tool that combines these object modules to create an executable program. The linker needs to know where the different symbols, such as functions and variables, are defined and where they are used so that it can resolve these references.
Information included in an Object Module
An object module contains the following information:
1. Object Code: This is the compiled machine language instructions and data that make up the program.
2. Relocation Bits: These are bits that indicate which parts of the object code are position-independent and can be relocated to a different memory location when the program is loaded into memory. This is important because the linker needs to know which parts of the code can be moved so that it can adjust the references accordingly.
3. Names and Locations of External Symbols: These are symbols that are defined in other object modules or libraries and are used in the current module. The object module needs to include the names and locations of these symbols so that the linker can resolve their references.
4. Absolute Addresses of Internal Symbols: These are symbols that are defined in the current object module and are used within the module. The object module needs to include their absolute addresses so that the linker can adjust the references accordingly.
Conclusion
In summary, an object module needs to include information about the object code, relocation bits, names and locations of external symbols, and absolute addresses of internal symbols. This information is necessary for the linker to combine the object modules and create an executable program.