Lecture 1
Lecture 1
Name
Binding
Thing
Create
bindings
Create
Reference
objects
Destroy Reactivate
bindings bindings
11
Memory Layout
Higher
Address
STACK
HEAP
Lower
CODE Address
12
Stack-Based Allocation
Bookkeeping
Subroutine B
fp when
Return address C is running
Subroutine A
Arguments
called from the
and
main program Higher
returns Address
14
Stack-Based Allocation
15
Stack Operations
n Code is executed until function call F is encountered
n Push the arguments for F on the stack
n Call F and place its return address RET on the stack
q RET is the address stored in the instruction pointer EIP at the
time when F is called
q It is the location at which to continue the execution when F is
completed
n Execute the prolog code
q EBP (fp) value is pushed onto the stack
16
Example
AAAAAAAAAA
int array[5]; AAAAAAAAAA
array
AAAAAAAAAA
}
AAAAAAAAAA
EBP
int main()
AAAAAAA
RET
{
b
function(1, 2);
a
}
17
Program Exploit: Buffer Overflow
int j = 0, sum = 0;
System.out.println(sum);
Department of Computer Science, the
University of Illinois at Chicago 20
Java Language Specification
n Version Java SE X Edition
q https://docs.oracle.com/en/java/javase/X
q https://docs.oracle.com/javase/specs/jls/seX/html/index.html
n Section 15.14 https://docs.oracle.com/javase/specs/jls/seX/html/jls-
15.html#jls-15.14
n At run time, if evaluation of the operand expression completes abruptly, then
the postfix increment expression completes abruptly for the same reason
and no incrementation occurs. Otherwise, the value 1 is added to the value
of the variable and the sum is stored back into the variable.
n Before the addition, binary numeric promotion (§5.6.2) is performed on the
value 1 and the value of the variable. If necessary, the sum is narrowed by a
narrowing primitive conversion (§5.1.3) and/or subjected to boxing
conversion (§5.1.7) to the type of the variable before it is stored.
n The value of the postfix increment expression is the value of the variable
before the new value is stored.
int j = 0, sum = 0;
System.out.println(sum);
Department of Computer Science, the
University of Illinois at Chicago 22
What About This Program?
n Mandatory
q The Michael Scott book, chapter 3
q The Scala book, chapters 1-3