From 2a97030c9743d4680d698414c28e8d8739614215 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 23:25:40 -0300 Subject: design: down is deeper; a call followed down; operands without size words; the heap as a scene From the user. Direction and nearness are rules: the idea, the source, its instructions, the callee and the kernel go down the frame, a call goes down and a return comes up, and every tie runs one of those ways. The disassembly can descend: a window a call depth, the caller keeping three rows with its call waiting, a PLT stub its jump, the kernel at the bottom on vellum, with verbs descend, cross and ascend. The kernel leaves the band, which keeps the calls so far as strace writes them; the backtrace has its newest frame at the bottom. Size words are dropped from operands and a width is shown as byte cells where nothing else says it; a compare shows its values and flags, a jump the flags it reads, an indirect call its target and the slot it was read from. libc's heap is a scene of blocks that exist (a dump by fields with a size and a protected pointer read, arcs as the free list, a loupe into the tcache, the list drawn over malloc's own), storyboarded on glibc 2.44. Mocks 16 to 18. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- design/mock/16-descent.svg | 733 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 733 insertions(+) create mode 100644 design/mock/16-descent.svg (limited to 'design/mock/16-descent.svg') diff --git a/design/mock/16-descent.svg b/design/mock/16-descent.svg new file mode 100644 index 0000000..c0af532 --- /dev/null +++ b/design/mock/16-descent.svg @@ -0,0 +1,733 @@ + + + + +1 +at the call +moment 1 + + + +hello.c +lines 3 to 10 of 11 +3 +4 +int +main +( +void +) +{ +5 +char +buf +[ +32 +] +; + + +6 +int +f += +open +( +"note" +, +0 +) +; +7 +int +n += +read +( +f +, +buf +, +32 +) +; +8 +close +( +f +) +; +9 +write +( +1 +, +buf +, +n +) +; +10 +return +0 +; + + + +disassembly +main +4011 +7a +4 +sub +rsp, 0x40 +4011 +7e +mov +rax, fs:[0x28] +the stack's canary +4011 +87 +mov +[rbp - 8], rax +4011 +8b +xor +eax, eax +4011 +8d +6 +lea +rax, [rip + 0xe70] += +402004 + "note" + +4011 +94 +mov +esi, 0 +rsi +0 + +4011 +99 +mov +rdi, rax +rdi +402004 + + +"note" + +4011 +9c +mov +eax, 0 +rax +0 + + + +4011 +a1 +call +401070 +open@plt +open + in libc, by the PLT +4011 +a6 +mov +[rbp - 0x38], eax +rdi +402004 + + +"note" +4011 +a9 +7 +lea +rcx, [rbp - 0x30] +rsi +O_RDONLY +4011 +ad +mov +eax, [rbp - 0x38] +4011 +b0 +mov +edx, 0x20 +4011 +b5 +mov +rsi, rcx +4011 +b8 +mov +edi, eax +4011 +ba +call +401060 +read@plt +read +4011 +bf +mov +[rbp - 0x34], eax + + + + + + + +main calls open by its stub in the PLT. The arguments +are in rdi and rsi: "note" and O_RDONLY. + + +2 +in the stub +moment 2 + + + +hello.c +main waits at line 6 · the pc is in the PLT +3 +4 +int +main +( +void +) +{ +5 +char +buf +[ +32 +] +; + +6 +int +f += +open +( +"note" +, +0 +) +; +7 +int +n += +read +( +f +, +buf +, +32 +) +; +8 +close +( +f +) +; +9 +write +( +1 +, +buf +, +n +) +; +10 +return +0 +; + + + +disassembly +open@plt · the PLT +4011 +87 +4 +mov +[rbp - 8], rax +4011 +8b +xor +eax, eax +4011 +8d +6 +lea +rax, [rip + 0xe70] += +402004 + "note" +4011 +94 +mov +esi, 0 + +4011 +99 +mov +rdi, rax + +4011 +9c +mov +eax, 0 + + +4011 +a1 +call +401070 +open@plt +open +("note", O_RDONLY) +4011 +a6 +mov +[rbp - 0x38], eax +4011 +a9 +7 +lea +rcx, [rbp - 0x30] +4011 +ad +mov +eax, [rbp - 0x38] +4011 +b0 +mov +edx, 0x20 +4011 +b5 +mov +rsi, rcx +4011 +b8 +mov +edi, eax + +open@plt +the PLT · its jmp reads open@got, 403fd8 + + + + + +4010 +70 +jmp +[rip + 0x2f62] + + +7ffff7d10ec0 + open +4010 +76 +push +4 +lazy binding: unused +4010 +7b +jmp +401020 + + + + + + + +The call pushed main+48 and went down: main's window keeps +its call, ringed; the stub's opens under it, and its jmp reads the GOT. + + +3 +the crossing +moments 4 and 5 + + + +hello.c +main waits at line 6 · the pc is in libc's open +3 +4 +int +main +( +void +) +{ +5 +char +buf +[ +32 +] +; + +6 +int +f += +open +( +"note" +, +0 +) +; +7 +int +n += +read +( +f +, +buf +, +32 +) +; +8 +close +( +f +) +; +9 +write +( +1 +, +buf +, +n +) +; +10 +return +0 +; + + + +disassembly +open · libc.so.6 + +4011 +9c +6 +mov +eax, 0 + + +4011 +a1 +call +401070 +open@plt +open +("note", O_RDONLY) +4011 +a6 +mov +[rbp - 0x38], eax + +open@plt +the PLT, jumped through + + + +4010 +70 +jmp +[rip + 0x2f62] + + +7ffff7d10ec0 + open + +open +libc.so.6 · no source + + + +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 +rdi +-100 +7ffff7d10f +ca +cmp +rax, -0x1000 +rsi +402004 + + +"note" +7ffff7d10f +d0 +ja +7ffff7d10fe8 +rdx +O_RDONLY +7ffff7d10f +d2 +mov +eax, edx +r10 +0 + + +the kernel +openat, system call 257 + + +openat(AT_FDCWD, "note", O_RDONLY, 0) +returns + +3 + "note" + rcx, r11: clobbered + + + + + + + +libc's open is a wrapper: it puts openat's number in rax +and its arguments in rdi, rsi, rdx, r10; syscall crosses down. + + +4 +back up +moment 6 + + + +hello.c +lines 3 to 10 of 11 +3 +4 +int +main +( +void +) +{ +5 +char +buf +[ +32 +] +; + + +6 +int +f += +open +( +"note" +, +0 +) +; +7 +int +n += +read +( +f +, +buf +, +32 +) +; +8 +close +( +f +) +; +9 +write +( +1 +, +buf +, +n +) +; +10 +return +0 +; + + + +disassembly +main +4011 +7a +4 +sub +rsp, 0x40 +4011 +7e +mov +rax, fs:[0x28] +the stack's canary +4011 +87 +mov +[rbp - 8], rax +4011 +8b +xor +eax, eax +4011 +8d +6 +lea +rax, [rip + 0xe70] += +402004 + "note" +4011 +94 +mov +esi, 0 + +4011 +99 +mov +rdi, rax + +4011 +9c +mov +eax, 0 + +4011 +a1 +call +401070 +open@plt +open +("note", O_RDONLY) = +3 + + + +4011 +a6 +mov +[rbp - 0x38], eax +7fffffffecc8 + + +0 +4011 +a9 +7 +lea +rcx, [rbp - 0x30] +4011 +ad +mov +eax, [rbp - 0x38] +4011 +b0 +mov +edx, 0x20 +4011 +b5 +mov +rsi, rcx +4011 +b8 +mov +edi, eax +4011 +ba +call +401060 +read@plt +read +4011 +bf +mov +[rbp - 0x34], eax + + + + + + + +open's ret came straight back to main+48: the stub was a jump, +not a call. The windows close up, and eax holds 3, the descriptor. + + -- cgit v1.3