mirror of
https://gitlab.com/BinaryHardening/cfgrip
synced 2026-07-26 12:41:08 +00:00
Fix #8: expose ELF .symtab symbol names to builder
Fix #8: expose ELF .symtab symbol names to CFG builder
This commit is contained in:
+4
-1
@@ -633,6 +633,8 @@ CFG CFGBuilder::build()
|
||||
auto it = imp_map.find(a);
|
||||
if (it != imp_map.end()) name = it->second;
|
||||
}
|
||||
if (name.empty())
|
||||
name = m_bin->getSymbolName(a);
|
||||
|
||||
auto func = buildFunction(a, name);
|
||||
if (isEmpty(func)) continue;
|
||||
@@ -659,7 +661,8 @@ CFG CFGBuilder::build()
|
||||
a = skipEndbr64(a);
|
||||
if (built.count(a)) continue;
|
||||
|
||||
auto func = buildFunction(a, "");
|
||||
string sym_name = m_bin->getSymbolName(a);
|
||||
auto func = buildFunction(a, sym_name);
|
||||
if (isEmpty(func)) continue;
|
||||
setEndAddress(func);
|
||||
cfg.functions.push_back(func);
|
||||
|
||||
@@ -42,6 +42,10 @@ class Binary
|
||||
return {};
|
||||
}
|
||||
virtual const string& getPath() const = 0;
|
||||
virtual string getSymbolName(addr_t addr) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
static unique_ptr<Binary> create(const string& path);
|
||||
};
|
||||
|
||||
@@ -21,6 +21,11 @@ class ELFLoader : public Binary
|
||||
vector<pair<addr_t, string>> getExportedFunctions() const override;
|
||||
vector<ImportEntry> getImportedFunctions() const override;
|
||||
const string& getPath() const override { return m_path; }
|
||||
string getSymbolName(addr_t addr) const override
|
||||
{
|
||||
auto it = m_symbols.find(addr);
|
||||
return it != m_symbols.end() ? it->second : string();
|
||||
}
|
||||
|
||||
addr_t getInitArray() const { return m_init_array; }
|
||||
addr_t getFiniArray() const { return m_fini_array; }
|
||||
|
||||
Reference in New Issue
Block a user