Each question below is a diagnostic question for a lab section. Test your understanding by answering the corresponding question as you finish an exercise. We encourage you to check in with a TA after completing a section or two, while the material is still fresh in your mind.
How does a program change during the linking process? According to
what segment is the
n variable in
linking.o, and how is it different in
linking.elf? How does the instruction
bl _cstart change after linking?
On a sheet of paper, with address 0x0 at the bottom of the page and
0x8000000 at the top, sketch a diagram of the program memory for
code/linking. Include the contents of the stack at the point
where execution has just entered the
main function. Use the memory diagram for simple
as a guide.
How does the bootloader work? As a group, collectively add comments to
bootloader.c explaining what it does.
How does the saved
pc in a function’s stack frame relate to the address of the first instruction for the function? If you take the saved
pc in the stack frame for
main and subtract it from the saved
lr in the stack frame for
diff, what do you get? Express your answer as a number, then explain conceptually what that computation represents. The memory diagram for simple is a helpful reference.
How should the number of
free calls relate to the number of
malloc calls in a correctly-written program that uses heap allocation?
Before leaving the lab, check in with a TA and discuss any challenges to answering the questions in the lab. If you do not feel confident about your responses, please ask us about it too!