Add base address calculation
This commit is contained in:
parent
a0b3af9c40
commit
659a872024
|
@ -0,0 +1,28 @@
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <elf.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#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
|
Loading…
Reference in New Issue