Concept explainers
This problem concerns the m. o module from Figure 7.5 and the following version of the swap, c function that counts the number of times it has been called:
For each symbol that is defined and referenced in swap. o, indicate if it will have a symbol table entry in the symbol section in module swap. o. If so, indicate the module that defines the symbol (swap .o or m. o), the symbol type (local, global, or extern), and the section (.text, .data, or bss) it occupies in that module.
Sections in relocatable object files:
There are many sections in a relocatable object file. They are given below:
- “.text”:
- It is the machine code of the compiled program.
- “.rodata”:
- This section is used to read only the data in the format such as
- Strings in “printf” statements.
- Jump tables for switch statements.
- This section is used to read only the data in the format such as
- “.data”:
- This section is used in the initialized “C” variables of global variable and static “C” variables.
- Local “C” variables are initialized at execution time on the stack.
- It does not show in either the “.data” or “.bss” sections.
- “.bss”:
- It is used in the uninitialized global and static “C” variables, along with any global or static variables that are assigned to zero.
- “.symtab”:
- It is a symbol table.
- It contains the information about functions and global variables that are defined and referenced in the program.
- “.rel.text”:
- This section contains a list of locations in the “.text” section.
- It will require to be changed once the linker merges this object file with others.
- This section contains a list of locations in the “.text” section.
- “.rel.data”:
- This section contains relocation information for any global variables that are referenced or defined by the module.
- “.debug”:
- It is a symbol table for debugging
- It contains entries for following
- Definition of Local variables, global variables and typedefs variables and original “C” source file.
- “.line”:
- It is a mapping between line numbers in the given program
- That is in original “C” source program and machine code instructions in the “.text” section.
- It is a mapping between line numbers in the given program
- “.strtab”:
- It is a string table.
- It contains symbol tables in the “.symtab” and “.debug” sections.
- It is the table for section names in the section headers.
- It is a string table.
Explanation of Solution
For symbol “buf”:
- “.symtab” entry:
- It is occurs in the symbol table.
- Symbol type:
- It is an “extern” type. Because, the variable “buf” is declared in “extern” type which is present in “swap.c” file.
- Module defined position:
- The “buf” type is defined in “m.o” module.
- Because, the symbol “buf” are defined in “m.c” file”.
- When converting source file “m.c” to a relocatable object file, the given file becomes “m.o”.
- Section:
- The symbol “buf” is defined in “.data” section. It is the initialized global variable of “m.c” file.
For symbol “bufp0”:
- “.symtab” entry:
- It is occurs in the symbol table.
- Symbol type:
- It is a “global” symbol type. Because, the variable “bufp0” is declared outside the function in “swap.c” file.
- Module defined position:
- The “bufp0” type is defined in “swap.o” module.
- Because, the symbol “bufp0” are defined in “swap.c” file”.
- When converting source file “swap.c” to a relocatable object file, the given file becomes “swap.o”.
- Section:
- The symbol “bufp0” is defined in “.data” section. It is the initialized global variable of “swap.c” file
For symbol “bufp1”:
- “.symtab” entry:
- It is occurs in the symbol table.
- Symbol type:
- It is a “local” type. Because, the variable “bufp1” with “static” type in “swap.c” file.
- Module defined position:
- The “bufp1” type is defined in “swap.o” module.
- Because, the symbol “bufp1” are defined in “swap.c” file”.
- When converting source file “swap.c” to a relocatable object file, the given file becomes “swap.o”.
- Section:
- The symbol “bufp1” is defined in “.bss” section. It is the uninitialized static “C” variable of “swap.c” file
For symbol “swap”:
- “.symtab” entry:
- It is occurs in the symbol table.
- Symbol type:
- It is a “global” type. Because, the symbol “swap” is used in the entire program.
- Module defined position:
- The “swap” type is defined in “swap.o” module.
- Because, the symbol “swap” are defined in “swap.c” file”.
- When converting source file “swap.c” to a relocatable file, the given file becomes “swap.o”.
- Section:
- The symbol “swap” is present in “.text” section. It is the machine code of the compiled program.
For symbol “temp”:
- “.symtab” entry:
- The local variable “temp” does not a have a symbol table entry.
- So, it does not have a symbol type, module defined position and section.
- The local variable “temp” does not a have a symbol table entry.
For symbol “incr”:
- “.symtab” entry:
- It is occurs in the symbol table.
- Symbol type:
- It is a “local” type. Because, the function “incr” uses return type of “static” in “swap.c” file.
- Module defined position:
- The “swap” type is defined in “swap.o” module.
- Because, the symbol “swap” are defined in “swap.c” file”.
- When converting source file “swap.c” to a relocatable file, the given file becomes “swap.o”.
- Section:
- The symbol “swap” is present in “.text” section. It is the machine code of the compiled program.
For symbol “count”:
- “.symtab” entry:
- It is occurs in the symbol table.
- Symbol type:
- It is a “local” type. Because, the variable “count” declared in “static” type in the “swap.c” file.
- Module defined position:
- The “swap” type is defined in “swap.o” module.
- Because, the symbol “swap” are defined in “swap.c” file”.
- When converting source file “swap.c” to a relocatable file, the given file becomes “swap.o”.
- Section:
- The symbol “swap” is present in “.bss” section. Here, the static variables “count” are initialized to “0” in “swap.c” file.
The final table is
Symbol | .symtab entry? | Symbol type | Module where defined | Section |
buf | Yes | extern | m.o | .data |
bufp0 | Yes | global | swap.o | .data |
bufp1 | Yes | local | swap.o | .bss |
swap | Yes | global | swap.o | .text |
temp | No | - | - | - |
incr | Yes | local | swap.o | .text |
count | Yes | local | swap.o | .bss |
Want to see more full solutions like this?
Chapter 7 Solutions
COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Electric Circuits. (11th Edition)
Database Concepts (8th Edition)
Mechanics of Materials (10th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
- I want code in MATLAB In this part, you are required to implement Quiz Application. Add 10 questions in your program of any domain with their answers. You many use strcmpi function to compare user answer with the saved answer. If the answer is correct/matched with the saved answer user score 1 point. Functionalities that need to be implemented in Quiz application are: - 1. The user will be asked to enter the name and then asked questions one by one. 2. The user should be given the choice to pass any question. If a user passes any question, no marks will be added or deducted. 3. The user should be able to see his/her total score after every question. 4. If 70% of the answers by the user are correct, then the user passes the Quiz otherwise, the user fails the Quiz. In both cases, the user will be displayed with a message, for example, “Congratulations, you got 8/10 correct, You Pass the Exam” or “Unfortunately, you got only 4/10, You failed the Exam”. 5. At the end of the Quiz, a user…arrow_forwardUse FDR to contruct and in Python. Aslo test the module by using Unit Testings.arrow_forwardTask using C language One common way of verifying if the data integrity of a file was preserved during a copy or transmission is to verify if the checksum matches. The checksum is a small piece of data computed from the original data. Your task is to compute a recursive function that maps an integer into a single digit to be used as checksum. Given an input integer in the range from 0 to 1012, the checksum is the sum of the digits of the input number. While the resulting sum has multiple digits, the checksum will be the sum of its digits instead. For instance: if the input is 34, the checksum is 7 (3+4); if the input is 99, the sum of its digits is 18 (9+9), so the checksum is 9 (1+8); if the input is 99999999999, the sum of its digits is 99 (9+9+9+9+9+9+9+9+9+9+9), whose sum of digits is 18 (9+9), so the checksum is 9 (1+8). Requirements Follow the format of the examples below. Make sure your variables and parameters have the correct data types. You must implement a recursive…arrow_forward
- Each function has local memory associated with it to hold incoming parameters, local variables, and (in some cases) temporary variables. This region of memory is called a stack frame. Question 7 options: True Falsearrow_forwardThis must be set up in C programming language. PLEASE include comments in the code to teach me how to solve this problem so I can learn the concepts!! Write two functions, main and question_1. The main function is the start of your program, and question_1 passes in a pointer of an integer, a pointer of a double, and an integer. The main function will create two variables, an integer and a double. Set the integer to the value 5, and the double to 7.5. Call question_1 and pass in the pointer of the integer, double and the integer itself. Question_1 will take the values and add 3 to each one of them.arrow_forwardparameter list can also contain the data type of the output of function : true/false a function declared int addition (int a and b) is capable of returning one value back to the main loop : true/false main () is a void function: true / false the address returned by the reference pointer is always the same regardless of operating system: true/false a function declares as int addition (int a, int b) has a and b as output arguments : true/ falsearrow_forward
- There is only 1 ques with 2 part. Please answer the questions ( Answer in python ) Part I: Cities. Write a function called describe_city which accepts the name of a city and its country. The function should print a simple sentence as shown in the output example. Give the parameter for the country a default value. Make 5 calls to the function using the following arguments: Reykjavik, Iceland Pittsburg Ontario, Canada Cairo, Egypt Miami, USA Output Example : ( FOLLOW THE OUTPUT SAME AS GIVEN BELOW ) Reykjavik is in Iceland Pittsburg is in USA Ontario is in Canada Cairo is in Egypt Miami is in USA Part II: Blastoff!!! Write a function called count_down which has 1 integer parameter. The function should countdown from that parameter value to 1. Each step in the countdown should be printed on the same line followed by ‘Blastoff!!!’ also on the same line. All of this should happen in the function. Make 3 calls to the function with the following arguments: 3 5 10 Output…arrow_forwardYou need to write a C code to have 5 digits dynamically allocated as a number located inside a structure.First, using the append function and create function, you need to create the linked list and at the end instead of using the print and free functions, as we practiced yesterday, you need to use the temporary pointer and next pointer values to deallocate memory.arrow_forwardPlease written by computer source a multiple choice for C++ data structure, thanksarrow_forward
- Explain the concept of pass by reference. How it differs from pass by valuearrow_forwardjust answer asaparrow_forwardFunction Implementation with Data Abstraction in C Programming 1. Create a new file and SAVE as MATHV1.H Define and Implement the following functions: int sum(int x, int y); - returns the computed sum of two numbers x and y int diff(int x, int y); - returns the computed difference of two numbers x and y. Make sure that the larger number is deducted by the smaller number to avoid a negative answer long int prod(int x, int y); - returns the computed product of two number x and y float quot(int x, int y); - returns the computed quotient of two numbers x and y. Make sure that the larger number is always the numerator and divided by the smaller number to avoid division by zero error. int mod(int x, int y); - returns the computed remainder of two numbers x and y using the modulo operator %2. Create another new file and save as MYTOOLS.H void center(int row, char str[]); /*centers text across the screen -calculate here for the center col using the formula col=(80-strlen(str))/2; -then use…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning