From 6a7a87b8ecb7902de5640cad00028997825024d2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 10:38:30 -0300 Subject: trace: a function's basic blocks; ASan's shadow memory For a graph of a function's blocks: at the first stop inside it a function's blocks are recorded once (bounds, how each ends, where its edges go), with every instruction's text up to 2048 of them; telescope.blocks reads them, and a branch event ties a run to the edge it took. Stripped libraries get blocks from their unwind bounds. For a plain build seen against an ASan one: record --asan keeps the shadow of every region it records, the offset found from the process; telescope.shadow gives an address's shadow byte. The report functions are named and the chain holds from inside the report to main. Tested on an overflowing target built plain, with gcc's ASan and with clang's. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- targets/overflow.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 targets/overflow.c (limited to 'targets') diff --git a/targets/overflow.c b/targets/overflow.c new file mode 100644 index 0000000..1c33e5b --- /dev/null +++ b/targets/overflow.c @@ -0,0 +1,18 @@ +// A simple stack overflow: a loop writes 40 bytes into a 16-byte buffer +// when given an argument. Built plain it overwrites the saved frame +// pointer and the return address, and `ret` jumps to 0x4141414141414141; +// built with -fsanitize=address the first byte past the buffer is +// reported. Without an argument it writes 16 and is fine. +#include + +__attribute__((noinline)) static void fill(int n) { + char buf[16]; + for (int i = 0; i < n; i++) buf[i] = 'A'; + printf("%c\n", buf[0]); +} + +int main(int argc, char **argv) { + (void)argv; + fill(argc > 1 ? 40 : 16); + return 0; +} -- cgit v1.3