summaryrefslogtreecommitdiff
path: root/simpleperf/read_elf_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2019-02-07 15:06:42 -0800
committerYabin Cui <yabinc@google.com>2019-02-07 15:23:32 -0800
commitdb2c493acf984c14c16a0417e6858f0140770208 (patch)
treed5f7c063dfc8b09c4f560094ea7998e989fd1ad2 /simpleperf/read_elf_test.cpp
parented1f0357906b3b92bc180b28a6c2fd1f9082fb67 (diff)
downloadextras-db2c493acf984c14c16a0417e6858f0140770208.tar.gz
simpleperf: fix symbolization in multi-executable-segments libraries.
Apps may run with libraries with multiple executable segments. Symbolization ip addresses in these libraries need to use map.pgoff. The old formula converting ip to vaddr_in_file: vaddr_in_file = ip - map.start + min_executable_vaddr The new formula converting ip to vaddr_in_file: offset_in_file = ip - map.start + map.pgoff vaddr_in_file = offset_in_file - file_offset_of_min_executable_vaddr + min_executable_vaddr Bug: 124056476 Test: run simpleperf_unit_test. Test: use simpleperf to profile facebook app, ip addresses hitting libc.so Test: and libart.so are symbolized correctly. Change-Id: I5fd3ed822a916c4d04a9868d6d209c43ee190c5b
Diffstat (limited to 'simpleperf/read_elf_test.cpp')
-rw-r--r--simpleperf/read_elf_test.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/simpleperf/read_elf_test.cpp b/simpleperf/read_elf_test.cpp
index 55a9cde9..f51244e7 100644
--- a/simpleperf/read_elf_test.cpp
+++ b/simpleperf/read_elf_test.cpp
@@ -162,7 +162,18 @@ TEST(read_elf, read_elf_with_broken_section_table) {
BuildId build_id;
ASSERT_EQ(ElfStatus::NO_BUILD_ID, GetBuildIdFromElfFile(elf_path, &build_id));
uint64_t min_vaddr;
- ASSERT_EQ(ElfStatus::NO_ERROR, ReadMinExecutableVirtualAddressFromElfFile(elf_path, BuildId(),
- &min_vaddr));
+ uint64_t file_offset_of_min_vaddr;
+ ASSERT_EQ(ElfStatus::NO_ERROR, ReadMinExecutableVirtualAddressFromElfFile(
+ elf_path, BuildId(), &min_vaddr, &file_offset_of_min_vaddr));
ASSERT_EQ(min_vaddr, 0u);
+ ASSERT_EQ(file_offset_of_min_vaddr, 0u);
+}
+
+TEST(read_elf, ReadMinExecutableVirtualAddressFromElfFile) {
+ uint64_t min_vaddr;
+ uint64_t file_offset_of_min_vaddr;
+ ASSERT_EQ(ElfStatus::NO_ERROR, ReadMinExecutableVirtualAddressFromElfFile(
+ GetTestData("libc.so"), BuildId(), &min_vaddr, &file_offset_of_min_vaddr));
+ ASSERT_EQ(min_vaddr, 0x29000u);
+ ASSERT_EQ(file_offset_of_min_vaddr, 0x29000u);
}