system calls
openat(…) = 3
its bytes
"note"
registers
rax
3
rcx r11
stack
hello.c
main waits at line 6 · the pc is in libc's open
5
char
buf
[
32
]
;
6
int
f
=
open
(
"note"
,
0
)
;
7
int
n
=
read
(
f
,
buf
,
32
)
;
disassembly
open · libc.so.6 · the kernel
4011
9c
6
lea
rdi, [rip + 0xe61]
4011
a3
xor
esi, esi
4011
a5
mov
al, sil
4011
a8
call
401070
open@plt
open
("note", O_RDONLY)
4011
ad
mov
[rbp - 0x38], eax
open@plt
the PLT · its jmp reads open@got, 403fd8
4010
70
jmp
[rip + 0x2f62]
7ffff7d10ec0
open
open
libc.so.6 · no source here
7ffff7d10f
0e
cmp
[rip + 0x11018b]
, 0
7ffff7d10f
15
jne
7ffff7d10fb0
taken
· reads
zf
7ffff7d10f
b0
mov
rsi, rdi
7ffff7d10f
b3
xor
r9d, r9d
7ffff7d10f
b6
xor
r8d, r8d
r8
0
7ffff7d10f
b9
mov
rdi, 0xffffffffffffff9c
rdi
-100
AT_FDCWD
7ffff7d10f
c0
mov
eax, 0x101
rax
0x101
257
7ffff7d10f
c5
syscall
openat
nr 257
7ffff7d10f
c7
mov
rdx, rax
7ffff7d10f
ca
cmp
rax, -0x1000
7ffff7d10f
d0
ja
7ffff7d10fe8
7ffff7d10f
d2
mov
eax, edx
7ffff7d10f
d4
mov
rdx, [rbp - 0x48]
the kernel
openat, system call 257
openat(AT_FDCWD, "note", O_RDONLY, 0)
returns
3
"note"
rcx, r11: clobbered
Its last three set the kernel's arguments,
and openat's number, 257, in rax.
syscall crosses down; the kernel opens
"note" and answers 3 in rax.
moment 35 of 46