Question

In: Computer Science

UNIX/LINUX LAB   (1) Compile hello.c program: gcc hello.c -o hello (2) Compile hello.c program with -static...

UNIX/LINUX LAB  

(1) Compile hello.c program: gcc hello.c -o hello

(2) Compile hello.c program with -static option: gcc -static hello.c -o hello1

(3) Use size command to see the memory layout of these two programs (hello and hello1).

(4) Write a brief summary of what you have noted here.

Submit the session history (log) of this activity and a brief summary.


hello.c program bottom
////////////
#include <stdio.h>
#include <stdlib.h>   
int main()
{
        printf("Hello World\n");   // waw hello Richard and ok
        exit(0);         // end of the program
}

Solutions

Expert Solution

vi hello.c

cat hello.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello World\n"); // waw hello Richard and ok
exit(0); // end of the program
}


$ gcc hello.c -o hello

$ gcc -static hello.c -o hello1


$ size hello
text data bss dec hex filename
1297 556 4 1857 741 hello


$ size hello1
text data bss dec hex filename
533437 3456 12408 549301 861b5 hello1

$ history
1158 vi hello.c
1159 gcc hello.c -o hello
1160 gcc -static hello.c -o hello1
1161 size hello
1162 size hello1
1163 history


Size command : Size command takes the argument of the file name. If none are specified, the file a.out will be used.
It outputs text, data, bss, dec, hex, and filename.
Text column displays the actual machine instructions that CPU is going to execute.
Data column displays all initialized variables declared.
Bss column displays uninitialized data such as arrays or null pointers.

When we compile a file with -static option, It links a program statically, that is it does not require a dependency on dynamic libraries at runtime in order to run. Also, In the above observation, when we compile with static option (i.e. when the hello1 file is generated, values of text, data and bss are increased).


Related Solutions

UNIX/LINUX LAB (1) Review the sample shell program (tryShell.c), and compile/run the program (tryShell) with the...
UNIX/LINUX LAB (1) Review the sample shell program (tryShell.c), and compile/run the program (tryShell) with the following commands, and at the end, use CTRL+C to terminate the program: ls ls -l tryShell* date whoami hostname uname -a ctrl+C    (2) Run the program (tryShell) with "time -p" with a few commands: time -p ./tryShell (3) Edit the program (tryShell.c) so that it will exit (terminate the program) when the input command string is "exit" try shell.c code at bottom //////////// #include...
System Administration Linux/Unix This lab is for you to research and implement old school DNS for...
System Administration Linux/Unix This lab is for you to research and implement old school DNS for your virtualized environment Currently, if you tried to ping your server01 by IP address (192.168.10.11), you would receive a response. If you tried to ping using its hostname "server01", it would result in "ping: hostname: Temporary failure in name resolution" 1) Research how and where to implement 2) Create the following entries: 192.168.10.1 router 192.168.10.11 SRV1 192.168.10.12 SRV2 192.168.10.13 client 3) Ensure these hostnames...
please write in c using linux or unix Write a program that will simulate non -...
please write in c using linux or unix Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
Please write in C using linux or unix. Write a program that will simulate non -...
Please write in C using linux or unix. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
compile and link two c programs from cmd prompt: using command gcc program1.c program2.h -o main...
compile and link two c programs from cmd prompt: using command gcc program1.c program2.h -o main but getting error undefined reference to scheduleFCFS not sure how to correct issue.
guide to unix using linux / 4th edition / chapter 2 / p10 2.10 Assume that...
guide to unix using linux / 4th edition / chapter 2 / p10 2.10 Assume that you work for a company that is developing a telephone database and you are creating directories for the Mail and Receiving Departments, which are referenced in the company’s budget and accounting systems as departments 4540 and 4550. After you create the directories, you begin creating files of department phone numbers to store in those directories. You must use the mkdir (make directory) command to...
IN LINUX/UNIX 1. Based on the example “awkc7” introduced in the handouts, please write an awk...
IN LINUX/UNIX 1. Based on the example “awkc7” introduced in the handouts, please write an awk script to display the first six records in “loginfile.” Please test your script to make sure the script displays the following information: ics325sp200221 pts/6        75.168.197.229   Wed Apr 29 22:09 - 23:27 (01:17)     ics325sp200221 pts/10       75.168.197.229   Wed Apr 29 22:04 - 22:07 (00:02)     ics325sp200220 pts/10       24.118.187.116   Wed Apr 29 15:28 - 15:30 (00:02)     ics325sp200220 pts/10       24.118.187.116   Wed Apr 29 15:22 - 15:23 (00:00)     ics325sp200222 pts/11      ...
Guide to UNIX Using Linux (4th Edition) 1.What is sed? A Stream editor is used to...
Guide to UNIX Using Linux (4th Edition) 1.What is sed? A Stream editor is used to perform basic transformations on text read from a file or a pipe. The result is sent to standard output. The syntax for the sed command has no output file specification, but results can be saved to a file using output redirection. The editor does not modify the original input. What distinguishes sed from other editors, such as vi and ed, is its ability to...
QUESTION 1 Match the following LINUX/UNIX commands with what they do. du    whereis users who...
QUESTION 1 Match the following LINUX/UNIX commands with what they do. du    whereis users who am i A. display a compact list of users currently logged in B. locate the binary, source, and manual page files for a command C. summarize disk usage D. who am i currently logged in as on the Linux server. QUESTION 2 What rm command option (flag) would you use to remove a file that begins with a - (hyphen)? -f -p --   ...
PLEASE USE LINUX/UNIX 1.Use either pico, vi, or cat to create the following file and name...
PLEASE USE LINUX/UNIX 1.Use either pico, vi, or cat to create the following file and name it as “mysedfile”: Name Class1 Class2 Class3 Tom 92 94 88 Nancy 91 85 95 Lisa 99 77 96 Jerry 84 98 90 2. Please use sed command(s) to complete the following tasks. display Tom’s record. display Lisa’s record. display both Tom’s and Lisa’s records. remove the blank line(s) from “mysedfile.” replace all the digits with *.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT