summaryrefslogtreecommitdiff
path: root/libunwindstack/Global.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-10-30 16:16:45 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-10-30 16:16:45 +0000
commitb31badf70f7734d1ef6d1a95ee73dc57ebd2b19d (patch)
treeb150ea58a97519c38abf33f0654eb709d0c9846f /libunwindstack/Global.cpp
parent1d0ee36de7af27ee43e5075b99e9427130a1f0f1 (diff)
parent4568f4bc0f116f097a13b1d931de93cf525ae204 (diff)
Merge "Verify that the elf matches the expected arch."
Diffstat (limited to 'libunwindstack/Global.cpp')
-rw-r--r--libunwindstack/Global.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/libunwindstack/Global.cpp b/libunwindstack/Global.cpp
index f0ad2b680..7a3de01d2 100644
--- a/libunwindstack/Global.cpp
+++ b/libunwindstack/Global.cpp
@@ -31,6 +31,13 @@ Global::Global(std::shared_ptr<Memory>& memory) : memory_(memory) {}
Global::Global(std::shared_ptr<Memory>& memory, std::vector<std::string>& search_libs)
: memory_(memory), search_libs_(search_libs) {}
+void Global::SetArch(ArchEnum arch) {
+ if (arch_ == ARCH_UNKNOWN) {
+ arch_ = arch;
+ ProcessArch();
+ }
+}
+
uint64_t Global::GetVariableOffset(MapInfo* info, const std::string& variable) {
if (!search_libs_.empty()) {
bool found = false;
@@ -46,7 +53,7 @@ uint64_t Global::GetVariableOffset(MapInfo* info, const std::string& variable) {
}
}
- Elf* elf = info->GetElf(memory_);
+ Elf* elf = info->GetElf(memory_, arch());
uint64_t ptr;
// Find first non-empty list (libraries might be loaded multiple times).
if (elf->GetGlobalVariable(variable, &ptr) && ptr != 0) {