alloc_debug: get load_bias error

malloc_debug can use libunwind and libunwindstck to unwind backtrace,
if libc.debug.malloc.options contains the string of "backtrace_full",
malloc_debug will use libunwindstck, and if libc.debug.malloc.options
contains the string of "backtrace=*", malloc_debug will use libunwind.

The result of libunwindstck is normal, but the result of libuniwnd
is abnormal, there is a offset between the rel_cp and the correct value,
so addr2line can't decode the right line number.

Libunwind and libunbiwndpack calculate load_bias is different, so malloc_debug
get load_bias alignment with libunwindstack.

Bug: 169539402
Change-Id: I640fb5db39af622a0bb52abf2c107984065a89d5
This commit is contained in:
Weiwei.Zhang 2020-09-28 14:43:51 +08:00 committed by Denis Hsu
parent 73ed0c4525
commit 8d01fac300
1 changed files with 5 additions and 2 deletions

View File

@ -116,14 +116,17 @@ static void read_loadbias(MapEntry* entry) {
if (!get_val<ElfW(Word)>(entry, addr + offsetof(ElfW(Phdr), p_type), &phdr.p_type)) {
return;
}
if (!get_val<ElfW(Word)>(entry, addr + offsetof(ElfW(Phdr), p_flags), &phdr.p_flags)) {
return;
}
if (!get_val<ElfW(Off)>(entry, addr + offsetof(ElfW(Phdr), p_offset), &phdr.p_offset)) {
return;
}
if (phdr.p_type == PT_LOAD && phdr.p_offset == entry->offset) {
if ((phdr.p_type == PT_LOAD) && (phdr.p_flags & PF_X) ) {
if (!get_val<ElfW(Addr)>(entry, addr + offsetof(ElfW(Phdr), p_vaddr), &phdr.p_vaddr)) {
return;
}
entry->load_bias = phdr.p_vaddr;
entry->load_bias = phdr.p_vaddr - phdr.p_offset;
return;
}
addr += sizeof(phdr);