Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9bbc31e authored by Christopher Ferris's avatar Christopher Ferris Committed by android-build-merger
Browse files

Merge "Verify that the elf matches the expected arch." am: b31badf7 am: bc2a0e30

am: 3f1f7631

Change-Id: I398e6266c19f15b11fdfe6d795fee2b2fc03f084
parents bfc3a0d8 3f1f7631
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
  unwindstack::Unwinder unwinder(MAX_BACKTRACE_FRAMES + num_ignore_frames, stack_map->stack_maps(),
                                 regs, stack_map->process_memory());
  unwinder.SetResolveNames(stack_map->ResolveNames());
  stack_map->SetArch(regs->Arch());
  if (stack_map->GetJitDebug() != nullptr) {
    unwinder.SetJitDebug(stack_map->GetJitDebug(), regs->Arch());
  }
+12 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <unwindstack/Elf.h>
#include <unwindstack/MapInfo.h>
#include <unwindstack/Maps.h>
#include <unwindstack/Regs.h>

#include "UnwindStackMap.h"

@@ -106,7 +107,17 @@ std::string UnwindStackMap::GetFunctionName(uint64_t pc, uint64_t* offset) {
    return "";
  }

  unwindstack::Elf* elf = map_info->GetElf(process_memory());
  if (arch_ == unwindstack::ARCH_UNKNOWN) {
    if (pid_ == getpid()) {
      arch_ = unwindstack::Regs::CurrentArch();
    } else {
      // Create a remote regs, to figure out the architecture.
      std::unique_ptr<unwindstack::Regs> regs(unwindstack::Regs::RemoteGet(pid_));
      arch_ = regs->Arch();
    }
  }

  unwindstack::Elf* elf = map_info->GetElf(process_memory(), arch_);

  std::string name;
  uint64_t func_offset;
+5 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#if !defined(NO_LIBDEXFILE_SUPPORT)
#include <unwindstack/DexFiles.h>
#endif
#include <unwindstack/Elf.h>
#include <unwindstack/JitDebug.h>
#include <unwindstack/Maps.h>

@@ -58,6 +59,8 @@ class UnwindStackMap : public BacktraceMap {
  unwindstack::DexFiles* GetDexFiles() { return dex_files_.get(); }
#endif

  void SetArch(unwindstack::ArchEnum arch) { arch_ = arch; }

 protected:
  uint64_t GetLoadBias(size_t index) override;

@@ -67,6 +70,8 @@ class UnwindStackMap : public BacktraceMap {
#if !defined(NO_LIBDEXFILE_SUPPORT)
  std::unique_ptr<unwindstack::DexFiles> dex_files_;
#endif

  unwindstack::ArchEnum arch_ = unwindstack::ARCH_UNKNOWN;
};

class UnwindStackOfflineMap : public UnwindStackMap {
+2 −2
Original line number Diff line number Diff line
@@ -54,8 +54,8 @@ DexFiles::~DexFiles() {
  }
}

void DexFiles::SetArch(ArchEnum arch) {
  switch (arch) {
void DexFiles::ProcessArch() {
  switch (arch()) {
    case ARCH_ARM:
    case ARCH_MIPS:
    case ARCH_X86:
+5 −0
Original line number Diff line number Diff line
@@ -88,6 +88,11 @@ void Elf::InitGnuDebugdata() {
  }
}

void Elf::Invalidate() {
  interface_.reset(nullptr);
  valid_ = false;
}

bool Elf::GetSoname(std::string* name) {
  std::lock_guard<std::mutex> guard(lock_);
  return valid_ && interface_->GetSoname(name);
Loading