summaryrefslogtreecommitdiffstats
path: root/libunwindstack/Memory.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-10-01 21:01:09 -0700
committerChristopher Ferris <cferris@google.com>2018-10-03 20:48:45 -0700
commit9d5712c1238164d5394b188617719c91a8f2efaa (patch)
tree56d96d87d30179616f0787afb344d9bdfd24010e /libunwindstack/Memory.cpp
parent15a5c9c44fee0246b6b762457e4132b700cdc7f1 (diff)
downloadsystem_core-9d5712c1238164d5394b188617719c91a8f2efaa.tar.gz
system_core-9d5712c1238164d5394b188617719c91a8f2efaa.tar.bz2
system_core-9d5712c1238164d5394b188617719c91a8f2efaa.zip
Implement support for linker rosegment option.
The rosegment linker option results in two maps containing the elf data existing. One is an execute map where the code lives, and the other is the read-only segment which contains the elf header information. If the file backing a shared library in memory is not readable, then the new code will attempt to find the read-only map that has the same name as the current execute segment, and that is at offest zero in the file. Add new unit tests for this functionality. Add the missing MapInfoCreateMemoryTest.cpp to the list of tests. Bug: 109657296 Test: Pass new unit tests. Test: All unit libbacktrace/libunwindstack tests pass with rosegment enabled. Change-Id: If8f69e4a067d77b3f2a7c31e2e5cd989a0702a8c
Diffstat (limited to 'libunwindstack/Memory.cpp')
-rw-r--r--libunwindstack/Memory.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libunwindstack/Memory.cpp b/libunwindstack/Memory.cpp
index beb2aade8..cfa8c6d93 100644
--- a/libunwindstack/Memory.cpp
+++ b/libunwindstack/Memory.cpp
@@ -316,6 +316,18 @@ size_t MemoryRange::Read(uint64_t addr, void* dst, size_t size) {
return memory_->Read(read_addr, dst, read_length);
}
+void MemoryRanges::Insert(MemoryRange* memory) {
+ maps_.emplace(memory->offset() + memory->length(), memory);
+}
+
+size_t MemoryRanges::Read(uint64_t addr, void* dst, size_t size) {
+ auto entry = maps_.upper_bound(addr);
+ if (entry != maps_.end()) {
+ return entry->second->Read(addr, dst, size);
+ }
+ return 0;
+}
+
bool MemoryOffline::Init(const std::string& file, uint64_t offset) {
auto memory_file = std::make_shared<MemoryFileAtOffset>();
if (!memory_file->Init(file, offset)) {