From 93498ce9c0dc4cd42411e9fdc896df2ffb9660f0 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Tue, 30 Jan 2024 19:44:07 -0500 Subject: [PATCH] Fix load_symbol ignoring source when a previous source has already been loaded --- media-layer/core/src/audio/file.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/media-layer/core/src/audio/file.cpp b/media-layer/core/src/audio/file.cpp index 34de48c50e..09925482e1 100644 --- a/media-layer/core/src/audio/file.cpp +++ b/media-layer/core/src/audio/file.cpp @@ -13,10 +13,12 @@ // Load Symbol From ELF File static void load_symbol(const char *source, const char *name, std::function callback) { - static std::unique_ptr binary = NULL; - if (binary == NULL) { - binary = LIEF::ELF::Parser::parse(source); + static std::unordered_map> sources = {}; + auto pos = sources.find(std::string(source)); + if (pos == sources.end()) { + sources[std::string(source)] = LIEF::ELF::Parser::parse(source); } + std::unique_ptr &binary = sources[std::string(source)]; const LIEF::ELF::Symbol *symbol = binary->get_dynamic_symbol(name); if (symbol != NULL) { LIEF::span data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA);