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

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

Merge "Fix up the definition of Elf::GetInfo." am: 6853a187 am: 96139a5d

am: 1795a568

Change-Id: I0880b668854ce15da53e7736afac4fcd0343139c
parents 3e65f6b8 1795a568
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -194,26 +194,26 @@ bool Elf::IsValidElf(Memory* memory) {
  return true;
}

void Elf::GetInfo(Memory* memory, bool* valid, uint64_t* size) {
bool Elf::GetInfo(Memory* memory, uint64_t* size) {
  if (!IsValidElf(memory)) {
    *valid = false;
    return;
    return false;
  }
  *size = 0;
  *valid = true;

  // Now read the section header information.
  uint8_t class_type;
  if (!memory->ReadFully(EI_CLASS, &class_type, 1)) {
    return;
    return false;
  }

  // Get the maximum size of the elf data from the header.
  if (class_type == ELFCLASS32) {
    ElfInterface32::GetMaxSize(memory, size);
  } else if (class_type == ELFCLASS64) {
    ElfInterface64::GetMaxSize(memory, size);
  } else {
    *valid = false;
    return false;
  }
  return true;
}

bool Elf::IsValidPc(uint64_t pc) {
+2 −8
Original line number Diff line number Diff line
@@ -53,10 +53,8 @@ Memory* MapInfo::GetFileMemory() {
    return nullptr;
  }

  bool valid;
  uint64_t max_size;
  Elf::GetInfo(memory.get(), &valid, &max_size);
  if (!valid) {
  if (!Elf::GetInfo(memory.get(), &max_size)) {
    // Init as if the whole file is an elf.
    if (memory->Init(name, 0)) {
      elf_offset = offset;
@@ -109,11 +107,7 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr<Memory>& process_memory) {
  // first part of the elf file. This is done if the linker rosegment
  // option is used.
  std::unique_ptr<MemoryRange> memory(new MemoryRange(process_memory, start, end - start, 0));
  bool valid;
  uint64_t max_size;
  Elf::GetInfo(memory.get(), &valid, &max_size);
  if (valid) {
    // Valid elf, we are done.
  if (Elf::IsValidElf(memory.get())) {
    return memory.release();
  }

+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ class Elf {

  static bool IsValidElf(Memory* memory);

  static void GetInfo(Memory* memory, bool* valid, uint64_t* size);
  static bool GetInfo(Memory* memory, uint64_t* size);

  static uint64_t GetLoadBias(Memory* memory);