summaryrefslogtreecommitdiff
path: root/libunwindstack/Elf.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-08-30 13:15:19 -0700
committerChristopher Ferris <cferris@google.com>2017-08-30 15:50:11 -0700
commit33f2ad27e04995e087503074feacafe1f1d40366 (patch)
treeb1ee3daae03df46f5d17c57391451505b67f47d7 /libunwindstack/Elf.cpp
parent0c643c8199f0a89cb8b49d6296fce995b3d25bdb (diff)
downloadunwinding-33f2ad27e04995e087503074feacafe1f1d40366.tar.gz
Add proper support for embedded elf files.
- Add a method to get the max size of an elf file by reading the section header offset + size. This will properly map an elf file embedded into an apk, instead of just mapping in what is done by the dynamic linker. It does assume that the section headers are at the end of the elf file. - Add new tests for the above functionality. - Update the unwind_symbols tool to take an address for finding a function instead of dumping the entire symbol table. Bug: 23762183 Test: Unit tests pass, unwind through the camera process and verify Test: the GoogleCamera.apk shows some function names. Change-Id: I00c021680fe1d43b60d652bf91bbf6667d9617be
Diffstat (limited to 'libunwindstack/Elf.cpp')
-rw-r--r--libunwindstack/Elf.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/libunwindstack/Elf.cpp b/libunwindstack/Elf.cpp
index 4fc7c67..4f7476d 100644
--- a/libunwindstack/Elf.cpp
+++ b/libunwindstack/Elf.cpp
@@ -124,6 +124,28 @@ bool Elf::IsValidElf(Memory* memory) {
return true;
}
+void Elf::GetInfo(Memory* memory, bool* valid, uint64_t* size) {
+ if (!IsValidElf(memory)) {
+ *valid = false;
+ return;
+ }
+ *size = 0;
+ *valid = true;
+
+ // Now read the section header information.
+ uint8_t class_type;
+ if (!memory->Read(EI_CLASS, &class_type, 1)) {
+ return;
+ }
+ if (class_type == ELFCLASS32) {
+ ElfInterface32::GetMaxSize(memory, size);
+ } else if (class_type == ELFCLASS64) {
+ ElfInterface64::GetMaxSize(memory, size);
+ } else {
+ *valid = false;
+ }
+}
+
ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) {
if (!IsValidElf(memory)) {
return nullptr;