adding of interesting symbols only
This commit is contained in:
parent
659a872024
commit
12ee7a6ad7
|
@ -25,4 +25,44 @@ static void calculate_base_address(void* known_runtime_addr, uintptr_t known_elf
|
|||
}
|
||||
|
||||
// compare function for symbol table quicksort
|
||||
// TODO
|
||||
static int compare_symbol(const void* a, const void* b){
|
||||
const symbol_entry_t* sym_a = (const symbol_entry_t*)a;
|
||||
const symbol_entry_t* sym_b = (const symbol_entry_t*)b;
|
||||
|
||||
if (sym_a->addr < sym_b->addr) return -1;
|
||||
if (sym_a->addr > sym_b->addr) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// add symbol to symbol table
|
||||
static int add_symbol(uintptr_t addr, const char* name, size_t size){
|
||||
if (!name || strlen(name) == 0) return 0;
|
||||
|
||||
// skip most internal symbols
|
||||
if (name[0] == '_' && name[1] == '_'){
|
||||
if (strncmp(name, "__cyg_profile", 13) == 0) return 0;
|
||||
if (strncmp(name, "__libc_", 7) == 0) return 0;
|
||||
if (strncmp(name, "__gmon_", 7) == 0) return 0;
|
||||
if (strstr(name, "_start") == NULL && strstr(name, "_init") == NULL && strstr(name, "_fini") == NULL && strstr(name, "main") == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// skip section symbols
|
||||
if (strstr(name, ".") != NULL) return 0;
|
||||
// skip versioned symbols
|
||||
if (strstr(name, "@") != NULL) return 0;
|
||||
|
||||
// add interesting symbols
|
||||
size_t name_len = strlen(name);
|
||||
char* tmp_name = rvprof_malloc(name_len+1);
|
||||
if (!tmp_name) return -1;
|
||||
strcpy(tmp_name, name);
|
||||
|
||||
g_rvprof.symbols.data[g_rvprof.symbols.size].addr = addr;
|
||||
g_rvprof.symbols.data[g_rvprof.symbols.size].name = tmp_name;
|
||||
g_rvprof.symbols.data[g_rvprof.symbols.size].size = size;
|
||||
g_rvprof.symbols.size++;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue