Where a pointer lives
hello.c:8
kernel
memory
cpu
source
hello.c
7
char
buf[
16
] =
"Hello, world!\n"
;
8
char
*p = buf;
lea
rax, [rbp-0x20]
mov
[rbp-0x8], rax
9
write(
1
, p,
14
);
10
return
0
;
registers
x86-64
0
0
0
0
5
5
d
4
a
1
c
0
1
1
6
d
rip
0
0
0
0
7
f
f
d
3
a
2
c
1
e
4
0
rax
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
rdi
0
0
0
0
7
f
f
d
3
a
2
c
1
e
3
0
rsp
0
0
0
0
7
f
f
d
3
a
2
c
1
e
6
0
rbp
stack
from 7ffd3a2c1e30 · low addresses on top
+0
+1
+2
+3
+4
+5
+6
+7
as text
main
3a2c
1e30
3a2c
1e38
3a2c
1e40
48
65
6c
6c
6f
2c
20
77
H
e
l
l
o
,
w
buf
3a2c
1e48
6f
72
6c
64
21
0a
00
00
o
r
l
d
!
·
·
·
3a2c
1e50
00
3f
9a
c1
77
d2
8e
5b
·
?
·
·
w
·
·
[
canary
3a2c
1e58
40
1e
2c
3a
fd
7f
00
00
@
·
,
:
·
·
·
·
p
3a2c
1e60
00
1f
2c
3a
fd
7f
00
00
·
·
,
:
·
·
·
·
saved rbp
3a2c
1e68
90
9d
22
5e
3c
7f
00
00
·
·
"
^
<
·
·
·
return to
__libc_start_call_main
rsp
rbp
the same eight bytes, low byte first, as one number
0
0
0
0
7
f
f
d
3
a
2
c
1
e
4
0
= where
buf
starts
The pointer p is eight ordinary bytes on the stack.
Read as one number, they are the address of buf.