Skip to content

Commit

Permalink
Fix issues with dumping and loading symbols
Browse files Browse the repository at this point in the history
Zero size symbols now load from config.
Addressed dumped from binary now always include the base image offset.
  • Loading branch information
OmniBlade committed Jan 9, 2024
1 parent 7093baa commit a17713a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions executable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,18 @@ unassemblize::Executable::Executable(const char *file_name, OutputFormats format

for (auto it = exe_syms.begin(); it != exe_syms.end(); ++it) {
if (it->value() != 0 && !it->name().empty() && m_symbolMap.find(it->value()) == m_symbolMap.end()) {
m_symbolMap.insert({it->value(), Symbol(it->name(), it->value(), it->size())});
uint64_t value = it->value() > m_binary->imagebase() ? it->value() : it->value() + m_binary->imagebase();
m_symbolMap.insert({it->value(), Symbol(it->name(), value, it->size())});
}
}

auto exe_imports = m_binary->imported_functions();

for (auto it = exe_imports.begin(); it != exe_imports.end(); ++it) {
if (it->value() != 0 && !it->name().empty() && m_symbolMap.find(it->value()) == m_symbolMap.end()) {
uint64_t value = it->value() > m_binary->imagebase() ? it->value() : it->value() + m_binary->imagebase();
m_loadedSymbols.push_back(it->name());
m_symbolMap.insert({it->value(), Symbol(m_loadedSymbols.back(), it->value(), it->size())});
m_symbolMap.insert({it->value(), Symbol(m_loadedSymbols.back(), value, it->size())});
}
}
}
Expand Down Expand Up @@ -252,10 +254,6 @@ void unassemblize::Executable::load_symbols(nlohmann::json &js)

it->at("size").get_to(size);

if (size == 0) {
continue;
}

// Only load symbols for addresses we don't have any symbol for yet.
if (m_symbolMap.find(addr) == m_symbolMap.end()) {
m_loadedSymbols.push_back(name);
Expand Down

0 comments on commit a17713a

Please sign in to comment.