Skip to content

Commit

Permalink
Highlight what the CPU is doing at each step
Browse files Browse the repository at this point in the history
Main had previously been lit up the whole time, but that's less
descriptive than showing where the program counter is.
  • Loading branch information
robertdfrench committed Jul 24, 2024
1 parent d78722b commit e53fa51
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ Consider this program which calls `printf` three times:
int main() {
printf("1");
printf("2");
printf("3");
return 0;
}
```
Expand All @@ -297,38 +296,38 @@ sequenceDiagram
participant printf_got as got[printf]
activate ld.so
ld.so->>printf_got: write resolver address
ld.so-->>printf_got: write resolver address
ld.so->>main: start program
deactivate ld.so
activate main
note over main: printf("1")
main->>printf_plt: call printf stub
deactivate main
activate printf_plt
printf_plt->>printf_got: get resolver address
printf_plt-->>printf_got: get resolver address
printf_plt->>ld.so: jump to resolver
deactivate printf_plt
activate ld.so
ld.so->>libc: lookup address of printf
ld.so->>printf_got: write printf address
ld.so-->>libc: lookup address of printf
ld.so-->>printf_got: write printf address
ld.so->>libc: jump to actual printf in libc
deactivate ld.so
activate libc
libc->>main: return
deactivate libc
activate main
note over main: printf("2")
main->>printf_plt: call printf stub
deactivate main
activate printf_plt
printf_plt->>printf_got: get printf address
printf_plt-->>printf_got: get printf address
printf_plt->>libc: jump to actual printf in libc
deactivate printf_plt
activate libc
libc->>main: return
deactivate libc
deactivate main
```

#### Viewing the PLT
Expand Down

0 comments on commit e53fa51

Please sign in to comment.