Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 7, Problem 7.6HW

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:

Chapter 7, Problem 7.6HW, This problem concerns the m. o module from Figure 7.5 and the following version of the swap, c , example  1

  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.

Chapter 7, Problem 7.6HW, This problem concerns the m. o module from Figure 7.5 and the following version of the swap, c , example  2

Expert Solution & Answer
Check Mark
Program Plan Intro

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.
  • “.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.
  • “.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.
  • “.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.

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.

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 typeModule where definedSection
bufYesexternm.o.data
bufp0Yesglobalswap.o.data
bufp1Yeslocalswap.o.bss
swapYesglobalswap.o.text
tempNo---
incrYeslocalswap.o.text
countYeslocalswap.o.bss

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
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…
Design a swap module that accepts two arguments of the Real data type and swaps them.
Q # 1. Note: write in c programming. Implement a Result Compilation System for CP Course. Program will take Marks of 3 Quizzes, 2 assignments, one midterm and one final term from the user as input. Marks of each quiz will be out of 15, marks of each assignment will be out of 40. Marks of Midterm will be out of 60 and Final term out of 80. Program will compute total marks in the subject according to the following grading scheme and display on the screen. Category Weightage 1 Quizzes 25% 2 Assignments 15% 3 Mid-term 20% 4 Final-term 40% Total Marks 100

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
What is Abstract Data Types(ADT) in Data Structures ? | with Example; Author: Simple Snippets;https://www.youtube.com/watch?v=n0e27Cpc88E;License: Standard YouTube License, CC-BY