Loading libunwindstack/MapInfo.cpp +11 −15 Original line number Original line Diff line number Diff line Loading @@ -96,11 +96,6 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr<Memory>& process_memory) { } } } } // If the map isn't readable, don't bother trying to read from process memory. if (!(flags & PROT_READ)) { return nullptr; } // Need to verify that this elf is valid. It's possible that // Need to verify that this elf is valid. It's possible that // only part of the elf file to be mapped into memory is in the executable // only part of the elf file to be mapped into memory is in the executable // map. In this case, there will be another read-only map that includes the // map. In this case, there will be another read-only map that includes the Loading Loading @@ -132,7 +127,10 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr<Memory>& process_memory) { } } } } if (ro_map_info != nullptr) { if (ro_map_info == nullptr) { return nullptr; } // Make sure that relative pc values are corrected properly. // Make sure that relative pc values are corrected properly. elf_offset = offset - closest_offset; elf_offset = offset - closest_offset; Loading @@ -143,8 +141,6 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr<Memory>& process_memory) { return ranges; return ranges; } } return nullptr; } Elf* MapInfo::GetElf(const std::shared_ptr<Memory>& process_memory, ArchEnum expected_arch) { Elf* MapInfo::GetElf(const std::shared_ptr<Memory>& process_memory, ArchEnum expected_arch) { // Make sure no other thread is trying to add the elf to this map. // Make sure no other thread is trying to add the elf to this map. Loading libunwindstack/tests/MapInfoGetElfTest.cpp +0 −21 Original line number Original line Diff line number Diff line Loading @@ -290,27 +290,6 @@ TEST_F(MapInfoGetElfTest, file_backed_non_zero_offset_partial_file_whole_elf64) ASSERT_TRUE(elf->memory()->ReadFully(0x1000, buffer.data(), 1)); ASSERT_TRUE(elf->memory()->ReadFully(0x1000, buffer.data(), 1)); } } TEST_F(MapInfoGetElfTest, process_memory_not_read_only) { MapInfo info(nullptr, 0x9000, 0xa000, 0x1000, 0, ""); // Create valid elf data in process memory only. Elf64_Ehdr ehdr; TestInitEhdr<Elf64_Ehdr>(&ehdr, ELFCLASS64, EM_AARCH64); ehdr.e_shoff = 0x2000; ehdr.e_shentsize = sizeof(Elf64_Shdr) + 100; ehdr.e_shnum = 0; memory_->SetMemory(0x9000, &ehdr, sizeof(ehdr)); Elf* elf = info.GetElf(process_memory_, ARCH_ARM64); ASSERT_TRUE(elf != nullptr); ASSERT_FALSE(elf->valid()); info.elf.reset(); info.flags = PROT_READ; elf = info.GetElf(process_memory_, ARCH_ARM64); ASSERT_TRUE(elf->valid()); } TEST_F(MapInfoGetElfTest, check_device_maps) { TEST_F(MapInfoGetElfTest, check_device_maps) { MapInfo info(nullptr, 0x7000, 0x8000, 0x1000, PROT_READ | MAPS_FLAGS_DEVICE_MAP, MapInfo info(nullptr, 0x7000, 0x8000, 0x1000, PROT_READ | MAPS_FLAGS_DEVICE_MAP, "/dev/something"); "/dev/something"); Loading Loading
libunwindstack/MapInfo.cpp +11 −15 Original line number Original line Diff line number Diff line Loading @@ -96,11 +96,6 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr<Memory>& process_memory) { } } } } // If the map isn't readable, don't bother trying to read from process memory. if (!(flags & PROT_READ)) { return nullptr; } // Need to verify that this elf is valid. It's possible that // Need to verify that this elf is valid. It's possible that // only part of the elf file to be mapped into memory is in the executable // only part of the elf file to be mapped into memory is in the executable // map. In this case, there will be another read-only map that includes the // map. In this case, there will be another read-only map that includes the Loading Loading @@ -132,7 +127,10 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr<Memory>& process_memory) { } } } } if (ro_map_info != nullptr) { if (ro_map_info == nullptr) { return nullptr; } // Make sure that relative pc values are corrected properly. // Make sure that relative pc values are corrected properly. elf_offset = offset - closest_offset; elf_offset = offset - closest_offset; Loading @@ -143,8 +141,6 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr<Memory>& process_memory) { return ranges; return ranges; } } return nullptr; } Elf* MapInfo::GetElf(const std::shared_ptr<Memory>& process_memory, ArchEnum expected_arch) { Elf* MapInfo::GetElf(const std::shared_ptr<Memory>& process_memory, ArchEnum expected_arch) { // Make sure no other thread is trying to add the elf to this map. // Make sure no other thread is trying to add the elf to this map. Loading
libunwindstack/tests/MapInfoGetElfTest.cpp +0 −21 Original line number Original line Diff line number Diff line Loading @@ -290,27 +290,6 @@ TEST_F(MapInfoGetElfTest, file_backed_non_zero_offset_partial_file_whole_elf64) ASSERT_TRUE(elf->memory()->ReadFully(0x1000, buffer.data(), 1)); ASSERT_TRUE(elf->memory()->ReadFully(0x1000, buffer.data(), 1)); } } TEST_F(MapInfoGetElfTest, process_memory_not_read_only) { MapInfo info(nullptr, 0x9000, 0xa000, 0x1000, 0, ""); // Create valid elf data in process memory only. Elf64_Ehdr ehdr; TestInitEhdr<Elf64_Ehdr>(&ehdr, ELFCLASS64, EM_AARCH64); ehdr.e_shoff = 0x2000; ehdr.e_shentsize = sizeof(Elf64_Shdr) + 100; ehdr.e_shnum = 0; memory_->SetMemory(0x9000, &ehdr, sizeof(ehdr)); Elf* elf = info.GetElf(process_memory_, ARCH_ARM64); ASSERT_TRUE(elf != nullptr); ASSERT_FALSE(elf->valid()); info.elf.reset(); info.flags = PROT_READ; elf = info.GetElf(process_memory_, ARCH_ARM64); ASSERT_TRUE(elf->valid()); } TEST_F(MapInfoGetElfTest, check_device_maps) { TEST_F(MapInfoGetElfTest, check_device_maps) { MapInfo info(nullptr, 0x7000, 0x8000, 0x1000, PROT_READ | MAPS_FLAGS_DEVICE_MAP, MapInfo info(nullptr, 0x7000, 0x8000, 0x1000, PROT_READ | MAPS_FLAGS_DEVICE_MAP, "/dev/something"); "/dev/something"); Loading