summaryrefslogtreecommitdiff
path: root/targets
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 23:55:42 -0300
committerGabriel Schneider <[email protected]>2026-11-11 00:06:30 -0300
commitc94ade9e77a811d3ff75ffc2889a65375262ab1f (patch)
treecd6e1da77cae54dc1ff4c35ee9d9262549819770 /targets
parent81d97a9e38c740a96af13a8a981878947a508bc0 (diff)
downloadcomputeranim-c94ade9e77a811d3ff75ffc2889a65375262ab1f.tar.gz
computeranim-c94ade9e77a811d3ff75ffc2889a65375262ab1f.zip
trace: names for PLT stubs and GOT slots; a call followed down; the vDSO is run through
For a disassembly that follows a call into libc. A stub is open@plt and a slot open@got, from the relocations (libc's own, IFUNC and nameless, by the function they resolve to); telescope.got says what a slot holds and whether it is still lazy. A library function's entry is named even when its mapping was not known yet, by the alias the program imports. The chain holds through the stub's jump, the callee's first instruction, the syscall and the loader's resolver: ld.so's unwind section lacks the entry that ends it, which lost every frame there. A syscall is tied to its instruction's moment, and each frame's call is recorded with the row before it. Stepped by instruction, a call into the vDSO is one moment and its return the next: its clock loop, single-stepped, made three million moments of three reads. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'targets')
-rw-r--r--targets/clock.c14
-rw-r--r--targets/hello.c15
2 files changed, 29 insertions, 0 deletions
diff --git a/targets/clock.c b/targets/clock.c
new file mode 100644
index 0000000..1a63e8c
--- /dev/null
+++ b/targets/clock.c
@@ -0,0 +1,14 @@
+// The clock read through the vDSO, the kernel's code mapped into the
+// process: no system call, and a loop that retries while the kernel's time
+// data changes under it.
+#include <time.h>
+
+int main(void) {
+ struct timespec ts;
+ long odd = 0;
+ for (int i = 0; i < 3; i++) {
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ odd += ts.tv_nsec & 1;
+ }
+ return odd > 3;
+}
diff --git a/targets/hello.c b/targets/hello.c
new file mode 100644
index 0000000..b575e6f
--- /dev/null
+++ b/targets/hello.c
@@ -0,0 +1,15 @@
+// main calls libc through the PLT, each call a system call: a call followed
+// down, through the stub and libc's wrapper to the kernel, and back up.
+// Linked for lazy binding: a function's first call runs the loader's
+// resolver, its second (the second read) goes straight to it.
+#include <fcntl.h>
+#include <unistd.h>
+
+int main(int argc, char **argv) {
+ char buf[16];
+ int f = open(argv[0], O_RDONLY);
+ long n = read(f, buf, sizeof buf);
+ n += read(f, buf, sizeof buf);
+ close(f);
+ return n == 2 * sizeof buf ? 0 : 1;
+}