Skip to content

Commit 402d398

Browse files
authored
Add r--p fallback pattern lookup of libart.so base for Android 10 (#497)
- When the Step 2 (r-xp) mode is not found, implement the lookup logic to fall back to the first r--p segment - On android 10 Step 1 to Step 2 doesn't match any pattern, but r--p does have a libart.so address - Log findModuleBase(): Found 4 filtered map entries for libart.so: findModuleBase(): 0x70991e8000 r--p /apex/com.android.runtime/lib64/libart.so findModuleBase(): 0x7099327000 --xp /apex/com.android.runtime/lib64/libart.so findModuleBase(): 0x70997de000 rw-p /apex/com.android.runtime/lib64/libart.so findModuleBase(): 0x70997e1000 r--p /apex/com.android.runtime/lib64/libart.so findModuleBase(): `r--p` -> `r-xp` pattern not found. Falling back to first `r-xp` entry. findModuleBase(): `r-xp` pattern not found. Falling back to first `r--p` entry. findModuleBase(): Found first `r--p` block at 0x70991e8000 findModuleBase(): get module base /apex/com.android.runtime/lib64/libart.so: 0x70991e8000 findModuleBase(): update path: /apex/com.android.runtime/lib64/libart.so
1 parent b6fb2f7 commit 402d398

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

core/src/main/jni/src/elf_util.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,18 @@ bool ElfImg::findModuleBase() {
454454
}
455455
}
456456

457+
// Step 3 (Fallback): If the pattern was not found, find the first `r--p` entry.
458+
if (!found_block) {
459+
LOGD("`r-xp` pattern not found. Falling back to first `r--p` entry.");
460+
for (const auto &entry : filtered_list) {
461+
if (strcmp(entry.perms, "r--p") == 0) {
462+
found_block = &entry;
463+
LOGD("Found first `r--p` block at {:#x}", found_block->start_addr);
464+
break; // Fallback found, exit loop.
465+
}
466+
}
467+
}
468+
457469
if (!found_block) {
458470
LOGE("Fatal: Could not determine a base address for {}", elf.data());
459471
return false;

0 commit comments

Comments
 (0)