Question

In: Computer Science

Compilers and Assemblers translate each source file individually to generate object code files. Hence the object...

Compilers and Assemblers translate each source file individually to generate object code files. Hence the object files need to be linked together before they can be executed. Theoretically, however, it is possible to skip the linking step and directly have compilers generate the final executable file. What would be the downside of taking the latter approach

Solutions

Expert Solution

Linking means creation of single executable file from combining different object files that are translated by the compiler . Yes , in theory it is possible to compile the object files without linking them but there are problems in following this approach and that is explained below

Following is the downside or disadvantage s of using the latter approach i.e compiling without linking :

=>  Suppose you wrote a very big program with lots of functions they will all be translated as different object files and if you don't use any linker or you skip the linking step . During compilation , if the compiler could not find the definition of particular function it would simply assume that the function was defined in another file ,if that is not the case (not defined in other file also ) then there is no way the compiler would know , compiler dosen't look into more than one file at a time

=>. Then after compiling the code will not work and there will be no error messages because the compiler don't even know what went wrong . You will have to look into hundered lines of code to find error .

=>. The linker dosen't do that linker look for more than one file at a time and try to find the reference for that from function or any other symbol if it doesn't find any reference to the unmentioned function it will simply show error .

=> Compiler errors are usually syntavtic in nature : missing semicolon ,extra paranthesis and all that . While the Linker errors are more like missing or multiple definitions , without the linker you will have hard time finding these errors which will be very time consuming .


Related Solutions

3. Translate the following C code to MIPS assembly code (in two separate files). int main()...
3. Translate the following C code to MIPS assembly code (in two separate files). int main() { printf(“before subroutine!\n”); Subfunc(); printf(“after subroutine!\n!”); } void Subfunc() {printf(“I am subroutine!\n”);} Submission file: Lab4_3a.asm for the main routine and Lab4_3b.asm for the sub-routine.
4. Translate the following C code to MIPS assembly (in two separate files). Run the program...
4. Translate the following C code to MIPS assembly (in two separate files). Run the program step by step and observe the order of instructions being executed and the value of $sp. int main() { int x=2; z=Subfunc(x); printf(“Value of z is: %d”, z); } int Subfunc(int x) { return x+1;} Submission file: Lab4_4a.asm and Lab4_4b.asm
Below is my source code for file merging. when i run the code my merged file...
Below is my source code for file merging. when i run the code my merged file is blank and it never shows merging complete prompt. i dont see any errors or why my code would be causing this. i saved both files with male names and female names in the same location my source code is in as a rtf #include #include #include using namespace std; int main() { ifstream inFile1; ifstream inFile2; ofstream outFile1; int mClientNumber, fClientNumber; string mClientName;...
Create a class Student (in the separate c# file but in the project’s source files folder)...
Create a class Student (in the separate c# file but in the project’s source files folder) with those attributes (i.e. instance variables): Student Attribute Data type (student) id String firstName String lastName String courses Array of Course objects Student class must have 2 constructors: one default (without parameters), another with 4 parameters (for setting the instance variables listed in the above table) In addition Student class must have setter and getter methods for the 4 instance variables, and getGPA method...
a – DSB. Write the code for an m-file (script) to generate a DSB signal. The...
a – DSB. Write the code for an m-file (script) to generate a DSB signal. The modulating (message) signal is a single tone signal with frequency 1kHz and the carrier frequency is 30kHz. Time Vector: 3001 points over range from 0 to 3ms (3 cycles of the modulating signal). Plot your original message signal both in time and its spectrum. (Note: the Matlab examples 6.1 and 6.2 will help, but use the cosine functions for your signals instead of sine...
HCS12 Assembly code please. Translate the following code into assembly. Allocate each variable on the stack....
HCS12 Assembly code please. Translate the following code into assembly. Allocate each variable on the stack. Simulate your program and screenshot the final value of the variables in memory. { char A,B,C; int F; A = 2; B = 6; C = - 10; F = (A + B)*C; C = F +10 }
Write source code in C to simulate the contiguous file allocation with the following conditions: •...
Write source code in C to simulate the contiguous file allocation with the following conditions: • Prompt the user to ender the no of files • Enter the name of the file • Enter the Starting block number • Enter no of block occupied by the file i.Condition: No two files must have the same block(if the user enter the same block no present in the previous file prompt the user “Block already in use”) #include<stdio.h> #include<conio.h> struct {    ...
DSB: Write the code for an m-file (script) to generate a DSB signal. The modulating (message)...
DSB: Write the code for an m-file (script) to generate a DSB signal. The modulating (message) signal is a single tone signal with frequency 1kHz and the carrier frequency is 30kHz. Time Vector: 3001 points over range from 0 to 3ms (3 cycles of the modulating signal). Plot your original message signal both in time and its spectrum. (Note: use the cosine functions for your signals). In your report you should include the plots for the modulated signal in time...
Directly copy the source code and paste into the Word file. Screenshot of running result must...
Directly copy the source code and paste into the Word file. Screenshot of running result must be presented. 1. (20 points) Write the “Hello, world!” program. 2. (30 points) Write a program to calculate the sum from -5 to10. Use the for loop to do the calculation. 3. (20 points) Write a complete C++ program that asks the user to enter the necessary information about the cylinder, calculate the volume in a function (named as calculate_vol, using reference to pass...
Part 1. Single-tone Modulation a –Write the code for an m-file (script) to generate a single...
Part 1. Single-tone Modulation a –Write the code for an m-file (script) to generate a single tone FM signal. The modulating (message) signal is a single tone signal with frequency 1kHz and the carrier frequency is 20kHz. Vary the modulation index as m=0.2; 0.5; 1; 5 and 10. Plot your original message signal and the modulated signal for each value of m. Discuss the results. Use cosine function to define the message signal. b- Repeat the part above only that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT