Commit a3a18a73 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Android] Don't apply offset to library start address for libs mapped from APK.

On Android, we mmap the .so directly from the APK, therefore the file offset
in this case refers to the offset of the .so in the APK, not the offset in
the .so file itself. As such, moving the start position of the library based
on this gives incorrect results when later symbolizing the addresses based on
the .so.

TBR=ulan@chromium.org

Change-Id: I16f78c91106dc85334a8b0034c96b19442af7b05
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627545Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61803}
parent a7e5504d
......@@ -106,9 +106,6 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break;
if (fscanf(fp, "%" V8PRIxPTR, &offset) != 1) break;
// Adjust {start} based on {offset}.
start -= offset;
int c;
if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') {
// Found a read-only executable entry. Skip characters until we reach
......@@ -135,6 +132,21 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
snprintf(lib_name, kLibNameLen, "%08" V8PRIxPTR "-%08" V8PRIxPTR, start,
end);
}
#ifdef V8_OS_ANDROID
size_t lib_name_length = strlen(lib_name);
if (lib_name_length < 4 ||
strncmp(&lib_name[lib_name_length - 4], ".apk", 4) != 0) {
// Only adjust {start} based on {offset} if the file isn't the APK,
// since we load the library directly from the APK and don't want to
// apply the offset of the .so in the APK as the libraries offset.
start -= offset;
}
#else
// Adjust {start} based on {offset}.
start -= offset;
#endif
result.push_back(SharedLibraryAddress(lib_name, start, end));
} else {
// Entry not describing executable data. Skip to end of line to set up
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment