Added support for dladdr()
dladdr() is a GNU extension function, which allows the caller to retrieve symbol information for a specified memory address. It is useful for things like generating backtrace information at runtime. Change-Id: I3a1def1a6c9c666d93e1e97b7d260dfa5b9b79a9
This commit is contained in:

committed by
Garmin Android technology group

parent
ede2e75f49
commit
e2a8b1fd19
@@ -538,6 +538,40 @@ Elf32_Sym *lookup(const char *name, soinfo **found)
|
||||
return 0;
|
||||
}
|
||||
|
||||
soinfo *find_containing_library(void *addr)
|
||||
{
|
||||
soinfo *si;
|
||||
|
||||
for(si = solist; si != NULL; si = si->next)
|
||||
{
|
||||
if((unsigned)addr >= si->base && (unsigned)addr - si->base < si->size) {
|
||||
return si;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Elf32_Sym *find_containing_symbol(void *addr, soinfo *si)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned soaddr = (unsigned)addr - si->base;
|
||||
|
||||
/* Search the library's symbol table for any defined symbol which
|
||||
* contains this address */
|
||||
for(i=0; i<si->nchain; i++) {
|
||||
Elf32_Sym *sym = &si->symtab[i];
|
||||
|
||||
if(sym->st_shndx != SHN_UNDEF &&
|
||||
soaddr >= sym->st_value &&
|
||||
soaddr < sym->st_value + sym->st_size) {
|
||||
return sym;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void dump(soinfo *si)
|
||||
{
|
||||
|
Reference in New Issue
Block a user