Quiz2 Study Guide
Quiz 2 is closed-book, closed-note, and no electronic devices are allowed. You should be familiar with everything from the Quiz1 study guide, however the quiz will be focused on material since the last quiz. You will be provided with a Reference Card with a list of RISC-V instructions and other useful information for the quiz.
A Historical Perspective
- What is Moore’s Law and why is it important?
Programming Encodings
- Difference between assembly and machine language
- Understand the parts of processor state that are normally hidden from a program:
- Registers
- Program Counter
- What is
objumpand how is it used? - How to generate the assembly code from a C program and a binary
Data Formats
- Understand how the sizes of C basic data types
| C | Data Type | Size (bytes) |
|---|---|---|
| char | Byte | 1 |
| short | Half Word | 2 |
| int | Word | 4 |
| long | Word | 4 |
| char * | Word | 4 |
| float | Single precision | 4 |
| double | Double precision | 8 |
RISC-V Registers
Be familiar with the RISC-V registers and how they are used in the RISC-V ABI (Application Binary Interface). The registers are listed on the Reference Card, which will be provided to you for the quiz.
Understand the difference between callee saved registers and caller saved registers and why that distinction is important.
RISC-V Instructions
Be familiar with the instructions on the Reference Card, which will be provided to you for the quiz.
RISC-V Pseudo Instructions
Understand why pseudo instructions are important to the RISC-V architecture, and be familiar with some of the more common pseudo instructions.
RISC-V Control
- Be able to recognize the assembly forms of loops and branches and be able to understand what C code could produce them (while loops, for loops, do while loops).
- Understand the syntax of the goto statement in C.
RISC-V Procedures
- Understand how stack frames are allocated for function calls.
- How are arguments are passed into functions (first 8 in
a0-a8, 9+ on the stack). - How return values passed back to the calling function (
a0). - The mechanics of the
jal(jump and link) instruction (place the return address in theraregister, jump to the address of the start of the function). - The mechanics of the
retpseudo instruction (jump to address contained in theraregister). - How local variables are stored on the stack
- Mechanics of recursive procedures (no different than a regular function call).
Array Allocation and Access
- Array syntax in C and how arrays are allocated in memory.
- Understand the assembly code to access an element of an array.
- How pointer arithmetic works, why is it used, and how is it different from regular arithmetic.
- Two dimensional arrays, how are they allocated in memory (row-major order) and the assembly code to access an element of the array.
Structures and Alignment
- How to define a
structin C. - How to access a member of a
struct(dot notation). - How to access a member of a pointer to a
struct(arrow notation). - How structures are laid out in memory (in order as declared in
structwith padding if needed for alignment). - Structure data alignment
- Alignment rules for fields within the structure (field members must be aligned to an address that is a multiple of the size of the object).
- Alignment rules for the entire structure (must be padded to be a multiple of the largest field size).
Buffer Overflow
- How can a buffer overflow occur, and why it is a problem.
- Given a function with a buffer overflow error, give an attack string to execute some other code.
- What are the ways to protect from buffer overflow problems and how can hackers work around these techniques.
- Stack Randomization
- Stack Canaries
- Marking the stack as non-executable
- What are ROP attacks and how are they used to attack a binary.