1
h17
CS32 F18
Name:
(as it would appear on official course roster)
Umail address: @umail.ucsb.edu
Optional: name you wish to be called
if different from name above.
Optional: name of "homework buddy"
(leaving this blank signifies "I worked alone"

h17: Memory Concepts

ready? assigned due points
true Tue 11/20 08:00AM Tue 11/27 02:00PM

You may collaborate on this homework with AT MOST one person, an optional "homework buddy".

MAY ONLY BE TURNED IN IN THE LECTURE LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the four lowest scores (if you have zeros, those are the four lowest scores).


Reading: Memory Concepts, CS32 Reader (p. 55 - 70)

  1. (10 pts) Fill in the information in the header. The following are required to get the 10 "participation" points.
    • Filling in your name and umail address.

    Also: For paper submission PLEASE submit on ONE SHEET OF PAPER, double-sided if at all possible. If you must submit on two printed sheets write name on BOTH sheets and no staples, paperclips, or folded corners.

  2. Object files (.o files) are organized in standard way to allow the linker to organize multiple source files into a single executable. The reading discusses the five major sections of an object file. Below, list the order of the five major sections in an object file. Accompany each with a one-sentence description or example of what belongs there.
    • (3 pts)
       
    • (3 pts)
       
    • (3 pts)
       
    • (3 pts)
       
    • (3 pts)
       
  3. (5 pts) Referring to memory addresses, we distinguish between physical addresses and logical/virtual addresses. BRIEFLY, write a few sentences (not too many!) of sentences that describe each of these type of addresses. Your answer should have just enough detail to make it clear to the grader that you understand the difference between these, and how they relate to each other.
     
  4. Answer each part regarding overflow:

    1. (2 pts) Briefly define what overflow in memory is.
       
    2. (2 pts) What is the mixed strategy C/C++ use when dealing with overflow?
       
  5. Linking is commonly thought of as the process by which separately compiled object modules (files) are combined into a single, runnable executable. This is somewhat misleading nomenclature, however, since linking is more properly thought of as a two stage process. Using the information in the reading, name and describe the two steps involved in linking.

    1. (5 pts) Briefly describe the first step:
       
    2. (5 pts) Briefly describe the second step:
       
  6. Suppose that a source file defines these three structs: struct A { int a, double b, int c }; , struct B { char a, int b, w_char c }; and struct C { int a, int c, int b }; . For purposes of this problem, assume that sizeof(int) is 4, sizeof(double) is 8, sizeof(char) is 1, sizeof(w_char) is 2. Also assume that ints and doubles must be aligned on word boundaries corresponding to their sizes, as explained in the reading.

    1. (2 pts) What is the value of sizeof(A)? Illustrate your answer.
       
    2. (2 pts) What is the value of sizeof(B)? Illustrate your answer.
       
    3. (2 pts) What is the value of sizeof(C)? Illustrate your answer.