From 659a872024139e6f401c55c6bd60cef7739513a0 Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Mon, 18 Aug 2025 14:13:01 +0200 Subject: [PATCH] Add base address calculation --- src/rvprof_symbols.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/rvprof_symbols.c diff --git a/src/rvprof_symbols.c b/src/rvprof_symbols.c new file mode 100644 index 0000000..a597c35 --- /dev/null +++ b/src/rvprof_symbols.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include "rvprof_internal.h" + +// thread-local storage for function names +__thread char g_tmp_func_name[128]; + +// base offset for PIE +static uintptr_t g_base_address_offset = 0; +static int g_base_address_calculated = 0; + + +// base address calculatiion +static void calculate_base_address(void* known_runtime_addr, uintptr_t known_elf_addr){ + if (g_base_address_calculated) return; + + uintptr_t runtime_addr = (uintptr_t)known_runtime_addr; + if (runtime_addr > known_elf_addr){ + g_base_address_offset = runtime_addr - known_elf_addr; + } + g_base_address_calculated = 1; +} + +// compare function for symbol table quicksort +// TODO \ No newline at end of file