summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2023-11-10 02:46:28 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-11-10 02:46:28 +0000
commitff931d68fe9a1b87fa9836cf37ef5b281b549207 (patch)
tree8b52cfd458424f0eee92f5fac4f537e5c121da5a
parentb5e3a3e338e094801e6643d426bd31a6b5b66733 (diff)
parent33bf0ec418a7993e1dd2df1ec1141dbde52ae7c2 (diff)
downloadunwinding-ff931d68fe9a1b87fa9836cf37ef5b281b549207.tar.gz
Move information about sections into a struct. am: 33bf0ec418
Original change: https://android-review.googlesource.com/c/platform/system/unwinding/+/2822929 Change-Id: I9fc0c842cdb3c00feda3fbbd5680884f054e264f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libunwindstack/DwarfEhFrameWithHdr.cpp21
-rw-r--r--libunwindstack/DwarfEhFrameWithHdr.h5
-rw-r--r--libunwindstack/DwarfSection.cpp15
-rw-r--r--libunwindstack/ElfInterface.cpp58
-rw-r--r--libunwindstack/include/unwindstack/DwarfSection.h5
-rw-r--r--libunwindstack/include/unwindstack/Elf.h5
-rw-r--r--libunwindstack/include/unwindstack/ElfInterface.h37
-rw-r--r--libunwindstack/tests/DwarfDebugFrameTest.cpp44
-rw-r--r--libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp88
-rw-r--r--libunwindstack/tests/DwarfSectionTest.cpp3
-rw-r--r--libunwindstack/tests/ElfFake.h12
-rw-r--r--libunwindstack/tests/ElfInterfaceTest.cpp77
-rw-r--r--libunwindstack/utils/DwarfSectionImplFake.h3
13 files changed, 221 insertions, 152 deletions
diff --git a/libunwindstack/DwarfEhFrameWithHdr.cpp b/libunwindstack/DwarfEhFrameWithHdr.cpp
index 1358e51..8e4bfee 100644
--- a/libunwindstack/DwarfEhFrameWithHdr.cpp
+++ b/libunwindstack/DwarfEhFrameWithHdr.cpp
@@ -18,6 +18,8 @@
#include <unwindstack/DwarfError.h>
#include <unwindstack/DwarfStructs.h>
+#include <unwindstack/Elf.h>
+#include <unwindstack/ElfInterface.h>
#include <unwindstack/Memory.h>
#include "Check.h"
@@ -32,19 +34,22 @@ static inline bool IsEncodingRelative(uint8_t encoding) {
}
template <typename AddressType>
-bool DwarfEhFrameWithHdr<AddressType>::EhFrameInit(uint64_t offset, uint64_t size,
- int64_t section_bias) {
- return DwarfSectionImpl<AddressType>::Init(offset, size, section_bias);
+bool DwarfEhFrameWithHdr<AddressType>::EhFrameInit(const SectionInfo& info) {
+ return DwarfSectionImpl<AddressType>::Init(info);
}
template <typename AddressType>
-bool DwarfEhFrameWithHdr<AddressType>::Init(uint64_t offset, uint64_t, int64_t section_bias) {
+bool DwarfEhFrameWithHdr<AddressType>::Init(const SectionInfo& info) {
+ if (info.flags & SHF_COMPRESSED) {
+ return false;
+ }
+
memory_.clear_func_offset();
memory_.clear_text_offset();
- memory_.set_data_offset(offset);
- memory_.set_cur_offset(offset);
+ memory_.set_data_offset(info.offset);
+ memory_.set_cur_offset(info.offset);
- hdr_section_bias_ = section_bias;
+ hdr_section_bias_ = info.bias;
// Read the first four bytes all at once.
uint8_t data[4];
@@ -95,7 +100,7 @@ bool DwarfEhFrameWithHdr<AddressType>::Init(uint64_t offset, uint64_t, int64_t s
}
hdr_entries_offset_ = memory_.cur_offset();
- hdr_entries_data_offset_ = offset;
+ hdr_entries_data_offset_ = info.offset;
return true;
}
diff --git a/libunwindstack/DwarfEhFrameWithHdr.h b/libunwindstack/DwarfEhFrameWithHdr.h
index d074b7b..c5cdb11 100644
--- a/libunwindstack/DwarfEhFrameWithHdr.h
+++ b/libunwindstack/DwarfEhFrameWithHdr.h
@@ -26,6 +26,7 @@ namespace unwindstack {
// Forward declarations.
class Memory;
+struct SectionInfo;
template <typename AddressType>
class DwarfEhFrameWithHdr : public DwarfSectionImpl<AddressType> {
@@ -56,8 +57,8 @@ class DwarfEhFrameWithHdr : public DwarfSectionImpl<AddressType> {
return pc + memory_.cur_offset() - 4;
}
- bool EhFrameInit(uint64_t offset, uint64_t size, int64_t section_bias);
- bool Init(uint64_t offset, uint64_t size, int64_t section_bias) override;
+ bool EhFrameInit(const SectionInfo& info);
+ bool Init(const SectionInfo& info) override;
const DwarfFde* GetFdeFromPc(uint64_t pc) override;
diff --git a/libunwindstack/DwarfSection.cpp b/libunwindstack/DwarfSection.cpp
index 7c99bde..1ee0988 100644
--- a/libunwindstack/DwarfSection.cpp
+++ b/libunwindstack/DwarfSection.cpp
@@ -629,15 +629,18 @@ bool DwarfSectionImpl<AddressType>::Log(uint8_t indent, uint64_t pc, const Dwarf
}
template <typename AddressType>
-bool DwarfSectionImpl<AddressType>::Init(uint64_t offset, uint64_t size, int64_t section_bias) {
- section_bias_ = section_bias;
- entries_offset_ = offset;
- entries_end_ = offset + size;
+bool DwarfSectionImpl<AddressType>::Init(const SectionInfo& info) {
+ if (info.flags & SHF_COMPRESSED) {
+ return false;
+ }
+ section_bias_ = info.bias;
+ entries_offset_ = info.offset;
+ entries_end_ = info.offset + info.size;
memory_.clear_func_offset();
memory_.clear_text_offset();
- memory_.set_cur_offset(offset);
- pc_offset_ = offset;
+ memory_.set_cur_offset(info.offset);
+ pc_offset_ = info.offset;
return true;
}
diff --git a/libunwindstack/ElfInterface.cpp b/libunwindstack/ElfInterface.cpp
index 43f1218..fe9dc79 100644
--- a/libunwindstack/ElfInterface.cpp
+++ b/libunwindstack/ElfInterface.cpp
@@ -92,39 +92,33 @@ std::unique_ptr<Memory> ElfInterface::CreateGnuDebugdataMemory() {
template <typename ElfTypes>
void ElfInterfaceImpl<ElfTypes>::InitHeaders() {
- if (eh_frame_hdr_offset_ != 0) {
+ if (eh_frame_hdr_info_.offset != 0) {
DwarfEhFrameWithHdr<AddressType>* eh_frame_hdr = new DwarfEhFrameWithHdr<AddressType>(memory_);
eh_frame_.reset(eh_frame_hdr);
- if (!eh_frame_hdr->EhFrameInit(eh_frame_offset_, eh_frame_size_, eh_frame_section_bias_) ||
- !eh_frame_->Init(eh_frame_hdr_offset_, eh_frame_hdr_size_, eh_frame_hdr_section_bias_)) {
+ if (!eh_frame_hdr->EhFrameInit(eh_frame_info_) || !eh_frame_->Init(eh_frame_hdr_info_)) {
eh_frame_.reset(nullptr);
}
}
- if (eh_frame_.get() == nullptr && eh_frame_offset_ != 0) {
+ if (eh_frame_.get() == nullptr && eh_frame_info_.offset != 0) {
// If there is an eh_frame section without an eh_frame_hdr section,
// or using the frame hdr object failed to init.
eh_frame_.reset(new DwarfEhFrame<AddressType>(memory_));
- if (!eh_frame_->Init(eh_frame_offset_, eh_frame_size_, eh_frame_section_bias_)) {
+ if (!eh_frame_->Init(eh_frame_info_)) {
eh_frame_.reset(nullptr);
}
}
if (eh_frame_.get() == nullptr) {
- eh_frame_hdr_offset_ = 0;
- eh_frame_hdr_section_bias_ = 0;
- eh_frame_hdr_size_ = static_cast<uint64_t>(-1);
- eh_frame_offset_ = 0;
- eh_frame_section_bias_ = 0;
- eh_frame_size_ = static_cast<uint64_t>(-1);
+ eh_frame_hdr_info_ = {};
+ eh_frame_info_ = {};
}
- if (debug_frame_offset_ != 0) {
+ if (debug_frame_info_.offset != 0) {
debug_frame_.reset(new DwarfDebugFrame<AddressType>(memory_));
- if (!debug_frame_->Init(debug_frame_offset_, debug_frame_size_, debug_frame_section_bias_)) {
+ if (!debug_frame_->Init(debug_frame_info_)) {
debug_frame_.reset(nullptr);
- debug_frame_offset_ = 0;
- debug_frame_size_ = static_cast<uint64_t>(-1);
+ debug_frame_info_ = {};
}
}
}
@@ -196,9 +190,11 @@ void ElfInterfaceImpl<ElfTypes>::ReadProgramHeaders(const EhdrType& ehdr, int64_
case PT_GNU_EH_FRAME:
// This is really the pointer to the .eh_frame_hdr section.
- eh_frame_hdr_offset_ = phdr.p_offset;
- eh_frame_hdr_section_bias_ = static_cast<uint64_t>(phdr.p_vaddr) - phdr.p_offset;
- eh_frame_hdr_size_ = phdr.p_memsz;
+ eh_frame_hdr_info_ = {
+ .offset = phdr.p_offset,
+ .size = phdr.p_memsz,
+ .flags = phdr.p_flags,
+ .bias = static_cast<int64_t>(static_cast<uint64_t>(phdr.p_vaddr) - phdr.p_offset)};
break;
case PT_DYNAMIC:
@@ -316,20 +312,26 @@ void ElfInterfaceImpl<ElfTypes>::ReadSectionHeaders(const EhdrType& ehdr) {
std::string name;
if (memory_->ReadString(sec_offset + shdr.sh_name, &name, sec_size - shdr.sh_name)) {
if (name == ".debug_frame") {
- debug_frame_offset_ = shdr.sh_offset;
- debug_frame_size_ = shdr.sh_size;
- debug_frame_section_bias_ = static_cast<uint64_t>(shdr.sh_addr) - shdr.sh_offset;
+ debug_frame_info_ = {
+ .offset = shdr.sh_offset,
+ .size = shdr.sh_size,
+ .flags = shdr.sh_flags,
+ .bias = static_cast<int64_t>(static_cast<uint64_t>(shdr.sh_addr) - shdr.sh_offset)};
} else if (name == ".gnu_debugdata") {
gnu_debugdata_offset_ = shdr.sh_offset;
gnu_debugdata_size_ = shdr.sh_size;
} else if (name == ".eh_frame") {
- eh_frame_offset_ = shdr.sh_offset;
- eh_frame_section_bias_ = static_cast<uint64_t>(shdr.sh_addr) - shdr.sh_offset;
- eh_frame_size_ = shdr.sh_size;
- } else if (eh_frame_hdr_offset_ == 0 && name == ".eh_frame_hdr") {
- eh_frame_hdr_offset_ = shdr.sh_offset;
- eh_frame_hdr_section_bias_ = static_cast<uint64_t>(shdr.sh_addr) - shdr.sh_offset;
- eh_frame_hdr_size_ = shdr.sh_size;
+ eh_frame_info_ = {
+ .offset = shdr.sh_offset,
+ .size = shdr.sh_size,
+ .flags = shdr.sh_flags,
+ .bias = static_cast<int64_t>(static_cast<uint64_t>(shdr.sh_addr) - shdr.sh_offset)};
+ } else if (eh_frame_hdr_info_.offset == 0 && name == ".eh_frame_hdr") {
+ eh_frame_hdr_info_ = {
+ .offset = shdr.sh_offset,
+ .size = shdr.sh_size,
+ .flags = shdr.sh_flags,
+ .bias = static_cast<int64_t>(static_cast<uint64_t>(shdr.sh_addr) - shdr.sh_offset)};
} else if (name == ".data") {
data_offset_ = shdr.sh_offset;
data_vaddr_start_ = shdr.sh_addr;
diff --git a/libunwindstack/include/unwindstack/DwarfSection.h b/libunwindstack/include/unwindstack/DwarfSection.h
index 75db6e4..880bfde 100644
--- a/libunwindstack/include/unwindstack/DwarfSection.h
+++ b/libunwindstack/include/unwindstack/DwarfSection.h
@@ -35,6 +35,7 @@ class Memory;
class Regs;
template <typename AddressType>
struct RegsInfo;
+struct SectionInfo;
class DwarfSection {
public:
@@ -92,7 +93,7 @@ class DwarfSection {
DwarfErrorCode LastErrorCode() { return last_error_.code; }
uint64_t LastErrorAddress() { return last_error_.address; }
- virtual bool Init(uint64_t offset, uint64_t size, int64_t section_bias) = 0;
+ virtual bool Init(const SectionInfo& info) = 0;
virtual bool Eval(const DwarfCie*, Memory*, const DwarfLocations&, Regs*, bool*) = 0;
@@ -132,7 +133,7 @@ class DwarfSectionImpl : public DwarfSection {
DwarfSectionImpl(Memory* memory) : DwarfSection(memory) {}
virtual ~DwarfSectionImpl() = default;
- bool Init(uint64_t offset, uint64_t size, int64_t section_bias) override;
+ bool Init(const SectionInfo& info) override;
const DwarfCie* GetCieFromOffset(uint64_t offset);
diff --git a/libunwindstack/include/unwindstack/Elf.h b/libunwindstack/include/unwindstack/Elf.h
index 6fff262..190cb57 100644
--- a/libunwindstack/include/unwindstack/Elf.h
+++ b/libunwindstack/include/unwindstack/Elf.h
@@ -16,6 +16,7 @@
#pragma once
+#include <elf.h>
#include <stddef.h>
#include <memory>
@@ -37,6 +38,10 @@
#define EM_RISCV 243
#endif
+#if !defined(SHF_COMPRESSED)
+#define SHF_COMPRESSED 0x800
+#endif
+
namespace unwindstack {
// Forward declaration.
diff --git a/libunwindstack/include/unwindstack/ElfInterface.h b/libunwindstack/include/unwindstack/ElfInterface.h
index a192450..5564f28 100644
--- a/libunwindstack/include/unwindstack/ElfInterface.h
+++ b/libunwindstack/include/unwindstack/ElfInterface.h
@@ -41,6 +41,13 @@ struct LoadInfo {
size_t table_size;
};
+struct SectionInfo {
+ uint64_t offset;
+ uint64_t size;
+ uint64_t flags;
+ int64_t bias;
+};
+
enum : uint8_t {
SONAME_UNKNOWN = 0,
SONAME_VALID,
@@ -102,20 +109,18 @@ class ElfInterface {
uint64_t dynamic_offset() { return dynamic_offset_; }
uint64_t dynamic_vaddr_start() { return dynamic_vaddr_start_; }
uint64_t dynamic_vaddr_end() { return dynamic_vaddr_end_; }
+
uint64_t data_offset() { return data_offset_; }
uint64_t data_vaddr_start() { return data_vaddr_start_; }
uint64_t data_vaddr_end() { return data_vaddr_end_; }
- uint64_t eh_frame_hdr_offset() { return eh_frame_hdr_offset_; }
- int64_t eh_frame_hdr_section_bias() { return eh_frame_hdr_section_bias_; }
- uint64_t eh_frame_hdr_size() { return eh_frame_hdr_size_; }
- uint64_t eh_frame_offset() { return eh_frame_offset_; }
- int64_t eh_frame_section_bias() { return eh_frame_section_bias_; }
- uint64_t eh_frame_size() { return eh_frame_size_; }
- uint64_t debug_frame_offset() { return debug_frame_offset_; }
- int64_t debug_frame_section_bias() { return debug_frame_section_bias_; }
- uint64_t debug_frame_size() { return debug_frame_size_; }
+
+ const SectionInfo& eh_frame_hdr_info() { return eh_frame_hdr_info_; }
+ const SectionInfo& eh_frame_info() { return eh_frame_info_; }
+ const SectionInfo& debug_frame_info() { return debug_frame_info_; }
+
uint64_t gnu_debugdata_offset() { return gnu_debugdata_offset_; }
uint64_t gnu_debugdata_size() { return gnu_debugdata_size_; }
+
uint64_t gnu_build_id_offset() { return gnu_build_id_offset_; }
uint64_t gnu_build_id_size() { return gnu_build_id_size_; }
@@ -147,17 +152,9 @@ class ElfInterface {
uint64_t data_vaddr_start_ = 0;
uint64_t data_vaddr_end_ = 0;
- uint64_t eh_frame_hdr_offset_ = 0;
- int64_t eh_frame_hdr_section_bias_ = 0;
- uint64_t eh_frame_hdr_size_ = 0;
-
- uint64_t eh_frame_offset_ = 0;
- int64_t eh_frame_section_bias_ = 0;
- uint64_t eh_frame_size_ = 0;
-
- uint64_t debug_frame_offset_ = 0;
- int64_t debug_frame_section_bias_ = 0;
- uint64_t debug_frame_size_ = 0;
+ SectionInfo eh_frame_hdr_info_ = {};
+ SectionInfo eh_frame_info_ = {};
+ SectionInfo debug_frame_info_ = {};
uint64_t gnu_debugdata_offset_ = 0;
uint64_t gnu_debugdata_size_ = 0;
diff --git a/libunwindstack/tests/DwarfDebugFrameTest.cpp b/libunwindstack/tests/DwarfDebugFrameTest.cpp
index 47a00b4..01ee372 100644
--- a/libunwindstack/tests/DwarfDebugFrameTest.cpp
+++ b/libunwindstack/tests/DwarfDebugFrameTest.cpp
@@ -21,6 +21,8 @@
#include <gtest/gtest.h>
#include <unwindstack/DwarfError.h>
+#include <unwindstack/Elf.h>
+#include <unwindstack/ElfInterface.h>
#include "DwarfDebugFrame.h"
#include "DwarfEncoding.h"
@@ -119,9 +121,15 @@ static void SetFourFdes32(MemoryFake* memory) {
SetFde32(memory, 0x5500, 0xfc, 0x300, 0x4500, 0x500);
}
+TYPED_TEST_P(DwarfDebugFrameTest, Init_compressed) {
+ SetFourFdes32(&this->memory_);
+ ASSERT_FALSE(this->debug_frame_->Init(
+ SectionInfo{.offset = 0x5000, .size = 0x600, .flags = SHF_COMPRESSED}));
+}
+
TYPED_TEST_P(DwarfDebugFrameTest, GetFdes32) {
SetFourFdes32(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x600}));
std::vector<const DwarfFde*> fdes;
this->debug_frame_->GetFdes(&fdes);
@@ -163,7 +171,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdes32) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdes32_after_GetFdeFromPc) {
SetFourFdes32(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x600}));
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x3600);
ASSERT_TRUE(fde != nullptr);
@@ -187,7 +195,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdes32_after_GetFdeFromPc) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdes32_not_in_section) {
SetFourFdes32(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x500, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x500}));
std::vector<const DwarfFde*> fdes;
this->debug_frame_->GetFdes(&fdes);
@@ -198,7 +206,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdes32_not_in_section) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdes32_big_function_address) {
SetCie32(&this->memory_, 0x5000, 0xfc, std::vector<uint8_t>{1, '\0', 0, 0, 1});
SetFde32(&this->memory_, 0x5100, 0xfc, 0, 0xe9ad9b1f, 0x200);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x200, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x200}));
std::vector<const DwarfFde*> fdes;
this->debug_frame_->GetFdes(&fdes);
@@ -216,7 +224,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdes32_big_function_address) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc32) {
SetFourFdes32(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x600}));
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x1600);
ASSERT_TRUE(fde != nullptr);
@@ -240,7 +248,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc32) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc32_reverse) {
SetFourFdes32(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x600}));
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x4600);
ASSERT_TRUE(fde != nullptr);
@@ -264,7 +272,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc32_reverse) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc32_not_in_section) {
SetFourFdes32(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x500, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x500}));
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x4600);
ASSERT_TRUE(fde == nullptr);
@@ -288,7 +296,7 @@ static void SetFourFdes64(MemoryFake* memory) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdes64) {
SetFourFdes64(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x600}));
std::vector<const DwarfFde*> fdes;
this->debug_frame_->GetFdes(&fdes);
@@ -330,7 +338,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdes64) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdes64_after_GetFdeFromPc) {
SetFourFdes64(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x600}));
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x2600);
ASSERT_TRUE(fde != nullptr);
@@ -354,7 +362,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdes64_after_GetFdeFromPc) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdes64_not_in_section) {
SetFourFdes64(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x500, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x500}));
std::vector<const DwarfFde*> fdes;
this->debug_frame_->GetFdes(&fdes);
@@ -364,7 +372,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdes64_not_in_section) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc64) {
SetFourFdes64(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x600}));
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x1600);
ASSERT_TRUE(fde != nullptr);
@@ -388,7 +396,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc64) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc64_reverse) {
SetFourFdes64(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x600}));
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x4600);
ASSERT_TRUE(fde != nullptr);
@@ -412,7 +420,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc64_reverse) {
TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc64_not_in_section) {
SetFourFdes64(&this->memory_);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x500, 0));
+ ASSERT_TRUE(this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x500}));
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x4600);
ASSERT_TRUE(fde == nullptr);
@@ -794,7 +802,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc_interleaved) {
// FDE 6 (0x0 - 0x50)
SetFde32(&this->memory_, 0x5700, 0xfc, 0, 0, 0x50);
- this->debug_frame_->Init(0x5000, 0x800, 0);
+ this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x800});
// Force reading all entries so no entries are found.
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0xfffff);
@@ -865,7 +873,7 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc_overlap) {
// FDE 2 (0x00 - 0x800)
SetFde32(&this->memory_, 0x5300, 0xfc, 0, 0x0, 0x800);
- this->debug_frame_->Init(0x5000, 0x400, 0);
+ this->debug_frame_->Init(SectionInfo{.offset = 0x5000, .size = 0x400});
// Force reading all entries so no entries are found.
const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0xfffff);
@@ -906,9 +914,9 @@ TYPED_TEST_P(DwarfDebugFrameTest, GetFdeFromPc_overlap) {
}
REGISTER_TYPED_TEST_SUITE_P(
- DwarfDebugFrameTest, GetFdes32, GetFdes32_after_GetFdeFromPc, GetFdes32_not_in_section,
- GetFdes32_big_function_address, GetFdeFromPc32, GetFdeFromPc32_reverse,
- GetFdeFromPc32_not_in_section, GetFdes64, GetFdes64_after_GetFdeFromPc,
+ DwarfDebugFrameTest, Init_compressed, GetFdes32, GetFdes32_after_GetFdeFromPc,
+ GetFdes32_not_in_section, GetFdes32_big_function_address, GetFdeFromPc32,
+ GetFdeFromPc32_reverse, GetFdeFromPc32_not_in_section, GetFdes64, GetFdes64_after_GetFdeFromPc,
GetFdes64_not_in_section, GetFdeFromPc64, GetFdeFromPc64_reverse, GetFdeFromPc64_not_in_section,
GetCieFde32, GetCieFde64, GetCieFromOffset32_cie_cached, GetCieFromOffset64_cie_cached,
GetCieFromOffset32_version1, GetCieFromOffset64_version1, GetCieFromOffset32_version3,
diff --git a/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp b/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
index 87b477a..649b9f4 100644
--- a/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
+++ b/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
@@ -20,6 +20,8 @@
#include <gtest/gtest.h>
#include <unwindstack/DwarfError.h>
+#include <unwindstack/Elf.h>
+#include <unwindstack/ElfInterface.h>
#include "DwarfEhFrameWithHdr.h"
#include "DwarfEncoding.h"
@@ -77,7 +79,7 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, Init) {
this->memory_.SetData16(0x1004, 0x500);
this->memory_.SetData32(0x1006, 126);
- ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100, 0));
+ ASSERT_TRUE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100}));
EXPECT_EQ(1U, this->eh_frame_->TestGetVersion());
EXPECT_EQ(DW_EH_PE_sdata4, this->eh_frame_->TestGetTableEncoding());
EXPECT_EQ(4U, this->eh_frame_->TestGetTableEntrySize());
@@ -87,23 +89,23 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, Init) {
// Verify a zero table entry size fails to init.
this->memory_.SetData8(0x1003, 0x1);
- ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100, 0));
+ ASSERT_FALSE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100}));
ASSERT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->eh_frame_->LastErrorCode());
// Reset the value back to the original.
this->memory_.SetData8(0x1003, DW_EH_PE_sdata4);
// Verify a zero fde count fails to init.
this->memory_.SetData32(0x1006, 0);
- ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100, 0));
+ ASSERT_FALSE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100}));
ASSERT_EQ(DWARF_ERROR_NO_FDES, this->eh_frame_->LastErrorCode());
// Verify an unexpected version will cause a fail.
this->memory_.SetData32(0x1006, 126);
this->memory_.SetData8(0x1000, 0);
- ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100, 0));
+ ASSERT_FALSE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100}));
ASSERT_EQ(DWARF_ERROR_UNSUPPORTED_VERSION, this->eh_frame_->LastErrorCode());
this->memory_.SetData8(0x1000, 2);
- ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100, 0));
+ ASSERT_FALSE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100}));
ASSERT_EQ(DWARF_ERROR_UNSUPPORTED_VERSION, this->eh_frame_->LastErrorCode());
}
@@ -127,8 +129,9 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, Init_non_zero_load_bias) {
this->memory_.SetData32(0x140c, 0x200);
this->memory_.SetData16(0x1410, 0);
- ASSERT_TRUE(this->eh_frame_->EhFrameInit(0x1300, 0x200, 0x2000));
- ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100, 0x2000));
+ ASSERT_TRUE(
+ this->eh_frame_->EhFrameInit(SectionInfo{.offset = 0x1300, .size = 0x200, .bias = 0x2000}));
+ ASSERT_TRUE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100, .bias = 0x2000}));
EXPECT_EQ(1U, this->eh_frame_->TestGetVersion());
EXPECT_EQ(0x1b, this->eh_frame_->TestGetTableEncoding());
EXPECT_EQ(4U, this->eh_frame_->TestGetTableEntrySize());
@@ -162,8 +165,9 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, Init_non_zero_load_bias_different_from_eh_
this->memory_.SetData32(0x140c, 0x200);
this->memory_.SetData16(0x1410, 0);
- ASSERT_TRUE(this->eh_frame_->EhFrameInit(0x1300, 0x200, 0x1000));
- ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100, 0x2000));
+ ASSERT_TRUE(
+ this->eh_frame_->EhFrameInit(SectionInfo{.offset = 0x1300, .size = 0x200, .bias = 0x1000}));
+ ASSERT_TRUE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100, .bias = 0x2000}));
EXPECT_EQ(1U, this->eh_frame_->TestGetVersion());
EXPECT_EQ(0x1b, this->eh_frame_->TestGetTableEncoding());
EXPECT_EQ(4U, this->eh_frame_->TestGetTableEntrySize());
@@ -177,6 +181,47 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, Init_non_zero_load_bias_different_from_eh_
EXPECT_EQ(0x4700U, fde->pc_end);
}
+TYPED_TEST_P(DwarfEhFrameWithHdrTest, Init_compressed) {
+ this->memory_.SetMemory(
+ 0x1000, std::vector<uint8_t>{0x1, DW_EH_PE_udata2, DW_EH_PE_udata4, DW_EH_PE_sdata4});
+ this->memory_.SetData16(0x1004, 0x500);
+ this->memory_.SetData32(0x1006, 126);
+
+ ASSERT_FALSE(
+ this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100, .flags = SHF_COMPRESSED}));
+}
+
+TYPED_TEST_P(DwarfEhFrameWithHdrTest, EhFrameInit_compressed) {
+ this->memory_.SetMemory(0x1000, std::vector<uint8_t>{0x1, DW_EH_PE_udata2, DW_EH_PE_udata4,
+ DW_EH_PE_pcrel | DW_EH_PE_sdata4});
+ this->memory_.SetData16(0x1004, 0x500);
+ this->memory_.SetData32(0x1006, 1);
+ this->memory_.SetData32(0x100a, 0x2500);
+ this->memory_.SetData32(0x100e, 0x1400);
+
+ // CIE 32 information.
+ this->memory_.SetData32(0x1300, 0xfc);
+ this->memory_.SetData32(0x1304, 0);
+ this->memory_.SetMemory(0x1308, std::vector<uint8_t>{1, 'z', 'R', '\0', 0, 0, 0, 0, 0x1b});
+
+ // FDE 32 information.
+ this->memory_.SetData32(0x1400, 0xfc);
+ this->memory_.SetData32(0x1404, 0x104);
+ this->memory_.SetData32(0x1408, 0x30f8);
+ this->memory_.SetData32(0x140c, 0);
+ this->memory_.SetData16(0x1410, 0);
+
+ // FDE 32 information.
+ this->memory_.SetData32(0x1500, 0xfc);
+ this->memory_.SetData32(0x1504, 0x204);
+ this->memory_.SetData32(0x1508, 0x2ff8);
+ this->memory_.SetData32(0x150c, 0x200);
+ this->memory_.SetData16(0x1510, 0);
+
+ ASSERT_FALSE(this->eh_frame_->EhFrameInit(
+ SectionInfo{.offset = 0x1300, .size = 0x300, .flags = SHF_COMPRESSED}));
+}
+
TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeFromPc_wtih_empty_fde) {
this->memory_.SetMemory(0x1000, std::vector<uint8_t>{0x1, DW_EH_PE_udata2, DW_EH_PE_udata4,
DW_EH_PE_pcrel | DW_EH_PE_sdata4});
@@ -204,8 +249,8 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeFromPc_wtih_empty_fde) {
this->memory_.SetData32(0x150c, 0x200);
this->memory_.SetData16(0x1510, 0);
- ASSERT_TRUE(this->eh_frame_->EhFrameInit(0x1300, 0x300, 0));
- ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100, 0));
+ ASSERT_TRUE(this->eh_frame_->EhFrameInit(SectionInfo{.offset = 0x1300, .size = 0x300}));
+ ASSERT_TRUE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100}));
const DwarfFde* fde = this->eh_frame_->GetFdeFromPc(0x4600);
ASSERT_TRUE(fde != nullptr);
@@ -240,8 +285,8 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdes_with_empty_fde) {
this->memory_.SetData32(0x150c, 0x200);
this->memory_.SetData16(0x1510, 0);
- ASSERT_TRUE(this->eh_frame_->EhFrameInit(0x1300, 0x300, 0));
- ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100, 0));
+ ASSERT_TRUE(this->eh_frame_->EhFrameInit(SectionInfo{.offset = 0x1300, .size = 0x300}));
+ ASSERT_TRUE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100}));
std::vector<const DwarfFde*> fdes;
this->eh_frame_->GetFdes(&fdes);
@@ -297,7 +342,7 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdes) {
this->memory_.SetData32(0x1708, 0x50f8);
this->memory_.SetData32(0x170c, 0x200);
- ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100, 0));
+ ASSERT_TRUE(this->eh_frame_->Init(SectionInfo{.offset = 0x1000, .size = 0x100}));
std::vector<const DwarfFde*> fdes;
this->eh_frame_->GetFdes(&fdes);
@@ -543,13 +588,14 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeFromPc_fde_not_found) {
}
REGISTER_TYPED_TEST_SUITE_P(DwarfEhFrameWithHdrTest, Init, Init_non_zero_load_bias,
- Init_non_zero_load_bias_different_from_eh_frame_bias,
- GetFdeFromPc_wtih_empty_fde, GetFdes_with_empty_fde, GetFdes,
- GetFdeInfoFromIndex_expect_cache_fail, GetFdeInfoFromIndex_read_pcrel,
- GetFdeInfoFromIndex_read_datarel, GetFdeInfoFromIndex_cached,
- GetFdeOffsetFromPc_verify, GetFdeOffsetFromPc_index_fail,
- GetFdeOffsetFromPc_fail_fde_count, GetFdeOffsetFromPc_search,
- GetCieFde32, GetCieFde64, GetFdeFromPc_fde_not_found);
+ Init_non_zero_load_bias_different_from_eh_frame_bias, Init_compressed,
+ EhFrameInit_compressed, GetFdeFromPc_wtih_empty_fde,
+ GetFdes_with_empty_fde, GetFdes, GetFdeInfoFromIndex_expect_cache_fail,
+ GetFdeInfoFromIndex_read_pcrel, GetFdeInfoFromIndex_read_datarel,
+ GetFdeInfoFromIndex_cached, GetFdeOffsetFromPc_verify,
+ GetFdeOffsetFromPc_index_fail, GetFdeOffsetFromPc_fail_fde_count,
+ GetFdeOffsetFromPc_search, GetCieFde32, GetCieFde64,
+ GetFdeFromPc_fde_not_found);
typedef ::testing::Types<uint32_t, uint64_t> DwarfEhFrameWithHdrTestTypes;
INSTANTIATE_TYPED_TEST_SUITE_P(Libunwindstack, DwarfEhFrameWithHdrTest, DwarfEhFrameWithHdrTestTypes);
diff --git a/libunwindstack/tests/DwarfSectionTest.cpp b/libunwindstack/tests/DwarfSectionTest.cpp
index 55f1d3a..bd801aa 100644
--- a/libunwindstack/tests/DwarfSectionTest.cpp
+++ b/libunwindstack/tests/DwarfSectionTest.cpp
@@ -21,6 +21,7 @@
#include <unwindstack/DwarfSection.h>
#include <unwindstack/Elf.h>
+#include <unwindstack/ElfInterface.h>
#include "RegsFake.h"
#include "utils/MemoryFake.h"
@@ -32,7 +33,7 @@ class MockDwarfSection : public DwarfSection {
MockDwarfSection(Memory* memory) : DwarfSection(memory) {}
virtual ~MockDwarfSection() = default;
- MOCK_METHOD(bool, Init, (uint64_t, uint64_t, int64_t), (override));
+ MOCK_METHOD(bool, Init, (const SectionInfo&), (override));
MOCK_METHOD(bool, Eval, (const DwarfCie*, Memory*, const DwarfLocations&, Regs*, bool*),
(override));
diff --git a/libunwindstack/tests/ElfFake.h b/libunwindstack/tests/ElfFake.h
index 97d6dcc..4ef8363 100644
--- a/libunwindstack/tests/ElfFake.h
+++ b/libunwindstack/tests/ElfFake.h
@@ -124,10 +124,8 @@ class ElfInterface32Fake : public ElfInterface32 {
ElfInterface32Fake(Memory* memory) : ElfInterface32(memory) {}
virtual ~ElfInterface32Fake() = default;
- void FakeSetEhFrameOffset(uint64_t offset) { eh_frame_offset_ = offset; }
- void FakeSetEhFrameSize(uint64_t size) { eh_frame_size_ = size; }
- void FakeSetDebugFrameOffset(uint64_t offset) { debug_frame_offset_ = offset; }
- void FakeSetDebugFrameSize(uint64_t size) { debug_frame_size_ = size; }
+ void FakeSetEhFrameInfo(const SectionInfo& info) { eh_frame_info_ = info; }
+ void FakeSetDebugFrameInfo(const SectionInfo& info) { debug_frame_info_ = info; }
};
class ElfInterface64Fake : public ElfInterface64 {
@@ -135,10 +133,8 @@ class ElfInterface64Fake : public ElfInterface64 {
ElfInterface64Fake(Memory* memory) : ElfInterface64(memory) {}
virtual ~ElfInterface64Fake() = default;
- void FakeSetEhFrameOffset(uint64_t offset) { eh_frame_offset_ = offset; }
- void FakeSetEhFrameSize(uint64_t size) { eh_frame_size_ = size; }
- void FakeSetDebugFrameOffset(uint64_t offset) { debug_frame_offset_ = offset; }
- void FakeSetDebugFrameSize(uint64_t size) { debug_frame_size_ = size; }
+ void FakeSetEhFrameInfo(const SectionInfo& info) { eh_frame_info_ = info; }
+ void FakeSetDebugFrameInfo(const SectionInfo& info) { debug_frame_info_ = info; }
};
class ElfInterfaceArmFake : public ElfInterfaceArm {
diff --git a/libunwindstack/tests/ElfInterfaceTest.cpp b/libunwindstack/tests/ElfInterfaceTest.cpp
index 47ae3d0..ea8c166 100644
--- a/libunwindstack/tests/ElfInterfaceTest.cpp
+++ b/libunwindstack/tests/ElfInterfaceTest.cpp
@@ -665,10 +665,8 @@ template <typename ElfType>
void ElfInterfaceTest::InitHeadersEhFrameTest() {
ElfType elf(&memory_);
- elf.FakeSetEhFrameOffset(0x10000);
- elf.FakeSetEhFrameSize(0);
- elf.FakeSetDebugFrameOffset(0);
- elf.FakeSetDebugFrameSize(0);
+ elf.FakeSetEhFrameInfo(SectionInfo{.offset = 0x10000});
+ elf.FakeSetDebugFrameInfo(SectionInfo{});
memory_.SetMemory(0x10000,
std::vector<uint8_t>{0x1, DW_EH_PE_udata2, DW_EH_PE_udata2, DW_EH_PE_udata2});
@@ -693,10 +691,8 @@ template <typename ElfType>
void ElfInterfaceTest::InitHeadersDebugFrame() {
ElfType elf(&memory_);
- elf.FakeSetEhFrameOffset(0);
- elf.FakeSetEhFrameSize(0);
- elf.FakeSetDebugFrameOffset(0x5000);
- elf.FakeSetDebugFrameSize(0x200);
+ elf.FakeSetEhFrameInfo(SectionInfo{});
+ elf.FakeSetDebugFrameInfo(SectionInfo{.offset = 0x5000, .size = 0x200});
memory_.SetData32(0x5000, 0xfc);
memory_.SetData32(0x5004, 0xffffffff);
@@ -822,8 +818,8 @@ void ElfInterfaceTest::InitSectionHeadersMalformedSymData() {
int64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
EXPECT_EQ(0, load_bias);
- EXPECT_EQ(0U, elf->debug_frame_offset());
- EXPECT_EQ(0U, elf->debug_frame_size());
+ EXPECT_EQ(0U, elf->debug_frame_info().offset);
+ EXPECT_EQ(0U, elf->debug_frame_info().size);
EXPECT_EQ(0U, elf->gnu_debugdata_offset());
EXPECT_EQ(0U, elf->gnu_debugdata_size());
@@ -894,8 +890,8 @@ void ElfInterfaceTest::InitSectionHeaders(uint64_t entry_size) {
int64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
EXPECT_EQ(0, load_bias);
- EXPECT_EQ(0U, elf->debug_frame_offset());
- EXPECT_EQ(0U, elf->debug_frame_size());
+ EXPECT_EQ(0U, elf->debug_frame_info().offset);
+ EXPECT_EQ(0U, elf->debug_frame_info().size);
EXPECT_EQ(0U, elf->gnu_debugdata_offset());
EXPECT_EQ(0U, elf->gnu_debugdata_size());
@@ -1011,20 +1007,23 @@ void ElfInterfaceTest::InitSectionHeadersOffsets() {
int64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
EXPECT_EQ(0, load_bias);
- EXPECT_EQ(0x6000U, elf->debug_frame_offset());
- EXPECT_EQ(0, elf->debug_frame_section_bias());
- EXPECT_EQ(0x500U, elf->debug_frame_size());
+ EXPECT_EQ(0x6000U, elf->debug_frame_info().offset);
+ EXPECT_EQ(0, elf->debug_frame_info().bias);
+ EXPECT_EQ(0x500U, elf->debug_frame_info().size);
+ EXPECT_EQ(0U, elf->debug_frame_info().flags);
EXPECT_EQ(0x5000U, elf->gnu_debugdata_offset());
EXPECT_EQ(0x800U, elf->gnu_debugdata_size());
- EXPECT_EQ(0x7000U, elf->eh_frame_offset());
- EXPECT_EQ(0, elf->eh_frame_section_bias());
- EXPECT_EQ(0x800U, elf->eh_frame_size());
+ EXPECT_EQ(0x7000U, elf->eh_frame_info().offset);
+ EXPECT_EQ(0, elf->eh_frame_info().bias);
+ EXPECT_EQ(0x800U, elf->eh_frame_info().size);
+ EXPECT_EQ(0U, elf->eh_frame_info().flags);
- EXPECT_EQ(0xa000U, elf->eh_frame_hdr_offset());
- EXPECT_EQ(0, elf->eh_frame_hdr_section_bias());
- EXPECT_EQ(0xf00U, elf->eh_frame_hdr_size());
+ EXPECT_EQ(0xa000U, elf->eh_frame_hdr_info().offset);
+ EXPECT_EQ(0, elf->eh_frame_hdr_info().bias);
+ EXPECT_EQ(0xf00U, elf->eh_frame_hdr_info().size);
+ EXPECT_EQ(0U, elf->eh_frame_hdr_info().flags);
EXPECT_EQ(0xb000U, elf->gnu_build_id_offset());
EXPECT_EQ(0xf00U, elf->gnu_build_id_size());
@@ -1090,13 +1089,15 @@ void ElfInterfaceTest::InitSectionHeadersOffsetsEhFrameSectionBias(uint64_t addr
int64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
EXPECT_EQ(0, load_bias);
- EXPECT_EQ(offset, elf->eh_frame_offset());
- EXPECT_EQ(expected_bias, elf->eh_frame_section_bias());
- EXPECT_EQ(0x500U, elf->eh_frame_size());
+ EXPECT_EQ(offset, elf->eh_frame_info().offset);
+ EXPECT_EQ(expected_bias, elf->eh_frame_info().bias);
+ EXPECT_EQ(0x500U, elf->eh_frame_info().size);
+ EXPECT_EQ(0U, elf->eh_frame_info().flags);
- EXPECT_EQ(0x8000U, elf->eh_frame_hdr_offset());
- EXPECT_EQ(0, elf->eh_frame_hdr_section_bias());
- EXPECT_EQ(0x800U, elf->eh_frame_hdr_size());
+ EXPECT_EQ(0x8000U, elf->eh_frame_hdr_info().offset);
+ EXPECT_EQ(0, elf->eh_frame_hdr_info().bias);
+ EXPECT_EQ(0x800U, elf->eh_frame_hdr_info().size);
+ EXPECT_EQ(0U, elf->eh_frame_hdr_info().flags);
}
TEST_F(ElfInterfaceTest, init_section_headers_offsets_eh_frame_section_bias_zero_32) {
@@ -1182,12 +1183,14 @@ void ElfInterfaceTest::InitSectionHeadersOffsetsEhFrameHdrSectionBias(uint64_t a
int64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
EXPECT_EQ(0, load_bias);
- EXPECT_EQ(0x5000U, elf->eh_frame_offset());
- EXPECT_EQ(0, elf->eh_frame_section_bias());
- EXPECT_EQ(0x500U, elf->eh_frame_size());
- EXPECT_EQ(offset, elf->eh_frame_hdr_offset());
- EXPECT_EQ(expected_bias, elf->eh_frame_hdr_section_bias());
- EXPECT_EQ(0x800U, elf->eh_frame_hdr_size());
+ EXPECT_EQ(0x5000U, elf->eh_frame_info().offset);
+ EXPECT_EQ(0, elf->eh_frame_info().bias);
+ EXPECT_EQ(0x500U, elf->eh_frame_info().size);
+ EXPECT_EQ(0U, elf->eh_frame_info().flags);
+ EXPECT_EQ(offset, elf->eh_frame_hdr_info().offset);
+ EXPECT_EQ(expected_bias, elf->eh_frame_hdr_info().bias);
+ EXPECT_EQ(0x800U, elf->eh_frame_hdr_info().size);
+ EXPECT_EQ(0U, elf->eh_frame_hdr_info().flags);
}
TEST_F(ElfInterfaceTest, init_section_headers_offsets_eh_frame_hdr_section_bias_zero_32) {
@@ -1261,9 +1264,9 @@ void ElfInterfaceTest::InitSectionHeadersOffsetsDebugFrameSectionBias(uint64_t a
int64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
EXPECT_EQ(0, load_bias);
- EXPECT_EQ(offset, elf->debug_frame_offset());
- EXPECT_EQ(expected_bias, elf->debug_frame_section_bias());
- EXPECT_EQ(0x800U, elf->debug_frame_size());
+ EXPECT_EQ(offset, elf->debug_frame_info().offset);
+ EXPECT_EQ(expected_bias, elf->debug_frame_info().bias);
+ EXPECT_EQ(0x800U, elf->debug_frame_info().size);
}
TEST_F(ElfInterfaceTest, init_section_headers_offsets_debug_frame_section_bias_zero_32) {
@@ -1325,7 +1328,7 @@ void ElfInterfaceTest::CheckGnuEhFrame(uint64_t addr, uint64_t offset, int64_t e
int64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
EXPECT_EQ(0, load_bias);
- EXPECT_EQ(expected_bias, elf->eh_frame_hdr_section_bias());
+ EXPECT_EQ(expected_bias, elf->eh_frame_hdr_info().bias);
}
TEST_F(ElfInterfaceTest, eh_frame_zero_section_bias_32) {
diff --git a/libunwindstack/utils/DwarfSectionImplFake.h b/libunwindstack/utils/DwarfSectionImplFake.h
index 54ed995..5b9eb0d 100644
--- a/libunwindstack/utils/DwarfSectionImplFake.h
+++ b/libunwindstack/utils/DwarfSectionImplFake.h
@@ -17,6 +17,7 @@
#pragma once
#include <unwindstack/DwarfSection.h>
+#include <unwindstack/ElfInterface.h>
#include <unwindstack/Memory.h>
namespace unwindstack {
@@ -27,7 +28,7 @@ class DwarfSectionImplFake : public DwarfSectionImpl<TypeParam> {
DwarfSectionImplFake(Memory* memory) : DwarfSectionImpl<TypeParam>(memory) {}
virtual ~DwarfSectionImplFake() = default;
- bool Init(uint64_t, uint64_t, int64_t) override { return false; }
+ bool Init(const SectionInfo&) override { return false; }
void GetFdes(std::vector<const DwarfFde*>*) override {}