mirror of
https://github.com/QuasarApp/LIEF.git
synced 2025-04-28 13:24:32 +00:00
Fix conflict when the builder tries to resolve the DT_XXX_ARRAY section
This commit is contained in:
parent
3730e447e1
commit
22344e764e
@ -121,6 +121,8 @@ class LIEF_API Builder {
|
||||
|
||||
bool should_swap(void) const;
|
||||
|
||||
Section& array_section(uint64_t addr);
|
||||
|
||||
mutable vector_iostream ios_;
|
||||
Binary* binary_;
|
||||
|
||||
|
@ -222,5 +222,22 @@ void Builder::build(NOTE_TYPES type) {
|
||||
}
|
||||
|
||||
|
||||
Section& Builder::array_section(uint64_t addr) {
|
||||
static const std::set<ELF_SECTION_TYPES> ARRAY_TYPES = {
|
||||
ELF_SECTION_TYPES::SHT_INIT_ARRAY,
|
||||
ELF_SECTION_TYPES::SHT_FINI_ARRAY,
|
||||
ELF_SECTION_TYPES::SHT_PREINIT_ARRAY,
|
||||
};
|
||||
|
||||
for (Section* section : this->binary_->sections_) {
|
||||
if (section->virtual_address() >= addr and
|
||||
addr < (section->virtual_address() + section->size())
|
||||
and ARRAY_TYPES.count(section->type()) > 0) {
|
||||
return *section;
|
||||
}
|
||||
}
|
||||
throw not_found("Can find the section associated with DT_ARRAY");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ void Builder::build_dynamic_section(void) {
|
||||
throw not_found(std::string("Unable to find the 'DT_ARRAYSZ' associated with ") + to_string(entry->tag()));
|
||||
}
|
||||
|
||||
Section& array_section = this->binary_->section_from_virtual_address(address);
|
||||
Section& array_section = this->array_section(address);
|
||||
|
||||
const std::vector<uint64_t>& array = entry->as<DynamicEntryArray>()->array();
|
||||
const size_t array_size = array.size() * sizeof(Elf_Addr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user