diff options
author | Christopher Ferris <cferris@google.com> | 2019-03-14 15:40:59 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-03-14 15:40:59 +0000 |
commit | 4886a5bd5942275c20fa95df3ccb03e70a97328c (patch) | |
tree | 8c40e397a05578712906cb0e546a77d9799f0dd1 /libunwindstack/tests/MapInfoGetElfTest.cpp | |
parent | ff3c13f52f1d223a4aa2904234867e6199643766 (diff) | |
parent | 02a6c448c32c37aae834bc25e92db97bfac32524 (diff) |
Merge "Add support for displaying soname in an apk."
Diffstat (limited to 'libunwindstack/tests/MapInfoGetElfTest.cpp')
-rw-r--r-- | libunwindstack/tests/MapInfoGetElfTest.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libunwindstack/tests/MapInfoGetElfTest.cpp b/libunwindstack/tests/MapInfoGetElfTest.cpp index d7b848544..d60b8b1af 100644 --- a/libunwindstack/tests/MapInfoGetElfTest.cpp +++ b/libunwindstack/tests/MapInfoGetElfTest.cpp @@ -371,4 +371,35 @@ TEST_F(MapInfoGetElfTest, multiple_thread_get_elf) { } } +// Verify that previous maps don't automatically get the same elf object. +TEST_F(MapInfoGetElfTest, prev_map_elf_not_set) { + MapInfo info1(nullptr, 0x1000, 0x2000, 0, PROT_READ, "/not/present"); + MapInfo info2(&info1, 0x2000, 0x3000, 0, PROT_READ, elf_.path); + + Elf32_Ehdr ehdr; + TestInitEhdr<Elf32_Ehdr>(&ehdr, ELFCLASS32, EM_ARM); + memory_->SetMemory(0x2000, &ehdr, sizeof(ehdr)); + Elf* elf = info2.GetElf(process_memory_, ARCH_ARM); + ASSERT_TRUE(elf != nullptr); + ASSERT_TRUE(elf->valid()); + + ASSERT_NE(elf, info1.GetElf(process_memory_, ARCH_ARM)); +} + +// Verify that a read-only map followed by a read-execute map will result +// in the same elf object in both maps. +TEST_F(MapInfoGetElfTest, read_only_followed_by_read_exec_share_elf) { + MapInfo r_info(nullptr, 0x1000, 0x2000, 0, PROT_READ, elf_.path); + MapInfo rw_info(&r_info, 0x2000, 0x3000, 0x1000, PROT_READ | PROT_EXEC, elf_.path); + + Elf32_Ehdr ehdr; + TestInitEhdr<Elf32_Ehdr>(&ehdr, ELFCLASS32, EM_ARM); + memory_->SetMemory(0x1000, &ehdr, sizeof(ehdr)); + Elf* elf = rw_info.GetElf(process_memory_, ARCH_ARM); + ASSERT_TRUE(elf != nullptr); + ASSERT_TRUE(elf->valid()); + + ASSERT_EQ(elf, r_info.GetElf(process_memory_, ARCH_ARM)); +} + } // namespace unwindstack |