Fix load_symbol ignoring source when a previous source has already been loaded
This commit is contained in:
parent
90a2b0ac85
commit
93498ce9c0
@ -13,10 +13,12 @@
|
|||||||
|
|
||||||
// Load Symbol From ELF File
|
// Load Symbol From ELF File
|
||||||
static void load_symbol(const char *source, const char *name, std::function<void(const unsigned char *, uint32_t)> callback) {
|
static void load_symbol(const char *source, const char *name, std::function<void(const unsigned char *, uint32_t)> callback) {
|
||||||
static std::unique_ptr<LIEF::ELF::Binary> binary = NULL;
|
static std::unordered_map<std::string, std::unique_ptr<LIEF::ELF::Binary>> sources = {};
|
||||||
if (binary == NULL) {
|
auto pos = sources.find(std::string(source));
|
||||||
binary = LIEF::ELF::Parser::parse(source);
|
if (pos == sources.end()) {
|
||||||
|
sources[std::string(source)] = LIEF::ELF::Parser::parse(source);
|
||||||
}
|
}
|
||||||
|
std::unique_ptr<LIEF::ELF::Binary> &binary = sources[std::string(source)];
|
||||||
const LIEF::ELF::Symbol *symbol = binary->get_dynamic_symbol(name);
|
const LIEF::ELF::Symbol *symbol = binary->get_dynamic_symbol(name);
|
||||||
if (symbol != NULL) {
|
if (symbol != NULL) {
|
||||||
LIEF::span<const uint8_t> data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA);
|
LIEF::span<const uint8_t> data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA);
|
||||||
|
Loading…
Reference in New Issue
Block a user