diff options
| -rw-r--r-- | binaryninjaapi.h | 2 | ||||
| -rw-r--r-- | binaryview.cpp | 6 | ||||
| -rw-r--r-- | view/sharedcache/core/SharedCache.cpp | 9 |
3 files changed, 10 insertions, 7 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index eac04a53..7ec05868 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -3899,6 +3899,8 @@ namespace BinaryNinja { const NameSpace& nameSpace = NameSpace(DEFAULT_INTERNAL_NAMESPACE), uint64_t ordinal = 0); Symbol(BNSymbolType type, const std::string& name, uint64_t addr, BNSymbolBinding binding = NoBinding, const NameSpace& nameSpace = NameSpace(DEFAULT_INTERNAL_NAMESPACE), uint64_t ordinal = 0); + Symbol(BNSymbolType type, const std::string& name, uint64_t addr, BNNameSpace* nameSpace, + BNSymbolBinding binding = NoBinding, uint64_t ordinal = 0); Symbol(BNSymbol* sym); /*! diff --git a/binaryview.cpp b/binaryview.cpp index 629ec4c5..e8638025 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -668,6 +668,12 @@ Symbol::Symbol(BNSymbolType type, const std::string& name, uint64_t addr, BNSymb } +Symbol::Symbol(BNSymbolType type, const std::string& name, uint64_t addr, BNNameSpace* nameSpace, BNSymbolBinding binding, uint64_t ordinal) +{ + m_object = BNCreateSymbol(type, name.c_str(), name.c_str(), name.c_str(), addr, binding, nameSpace, ordinal); +} + + Symbol::Symbol(BNSymbol* sym) { m_object = sym; diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index 224097f5..642e8bcb 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -2722,13 +2722,8 @@ void SharedCache::ReadExportNode(std::vector<Ref<Symbol>>& symbolList, const Sha #if EXPORT_TRIE_DEBUG // BNLogInfo("export: %s -> 0x%llx", n.text.c_str(), image.baseAddress + n.offset); #endif - // TODO: The usual `Symbol` constructors take a `NameSpace` and do unnecessary memory allocations - // to pass its fields down to the core API. Here we pass nullptr for the namespace which is treated - // the same, but avoids the memory allocations. Switch back to directly constructing a `Symbol` - // once it gains constructors without that overhead. - auto symbol = new Symbol(BNCreateSymbol(type, currentText.c_str(), currentText.c_str(), - currentText.c_str(), textBase + imageOffset, NoBinding, nullptr, 0)); - symbolList.push_back(symbol); + auto symbol = new Symbol(type, currentText, textBase + imageOffset, nullptr); + symbolList.emplace_back(symbol); } } } |
