diff options
author | Yabin Cui <yabinc@google.com> | 2022-01-20 13:28:25 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2022-01-20 14:13:27 -0800 |
commit | 2d5c6a4e2f8384e15b392f2c87e10a5ebe7d35ef (patch) | |
tree | d8f4297043092850676118592861959dd1f3130a /libunwindstack/MapInfo.cpp | |
parent | b61aebb7f7afaad9b775a59dcd0ea6289fc4325a (diff) | |
download | unwinding-2d5c6a4e2f8384e15b392f2c87e10a5ebe7d35ef.tar.gz |
Fix getting elf file from JIT_SYMFILE maps.
For maps with MAPS_FLAGS_JIT_SYMFILE_MAP, the map range
is for a JIT function, which can be smaller than elf header size.
To get elf file from those maps, increase map_size to make sure
we can read elf header.
Bug: 215556268
Test: run libunwindstack_unit_test
Change-Id: Ib549f02c8ea806598ddb4319c655705227e36e16
Diffstat (limited to 'libunwindstack/MapInfo.cpp')
-rw-r--r-- | libunwindstack/MapInfo.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libunwindstack/MapInfo.cpp b/libunwindstack/MapInfo.cpp index 6193015..f19c6b7 100644 --- a/libunwindstack/MapInfo.cpp +++ b/libunwindstack/MapInfo.cpp @@ -120,7 +120,11 @@ Memory* MapInfo::GetFileMemory() { // and reinit to that size. This is needed because the dynamic linker // only maps in a portion of the original elf, and never the symbol // file data. - uint64_t map_size = end() - start(); + // + // For maps with MAPS_FLAGS_JIT_SYMFILE_MAP, the map range is for a JIT function, + // which can be smaller than elf header size. So make sure map_size is large enough + // to read elf header. + uint64_t map_size = std::max<uint64_t>(end() - start(), sizeof(ElfTypes64::Ehdr)); if (!memory->Init(name(), offset(), map_size)) { return nullptr; } |