diff options
| author | Glenn Smith <glenn@vector35.com> | 2024-10-23 20:18:23 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2024-10-23 20:22:55 -0400 |
| commit | 2214557964551956750203029321329689282546 (patch) | |
| tree | 78abec7b3ea50e6c3b9f584307afbe52c5ff76dd /demangler/gnu3/demangle_gnu3.cpp | |
| parent | 83fbc7ebf26678de9a695c05fd87e0f77959ef52 (diff) | |
Compile demangler plugins directly into the core for P E R F
Turns out, this is a rather hot path on initial binary loading (>50% runtime), and trying to pipe it all through the FFI makes it really slow. Like 100% slower. Ouch. Now, the demangler plugins are written with a bunch of #ifdef macros to allow for building both as a plugin and directly into the core. There is no functionality change here apart from regaining the lost performance.
Diffstat (limited to 'demangler/gnu3/demangle_gnu3.cpp')
| -rw-r--r-- | demangler/gnu3/demangle_gnu3.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/demangler/gnu3/demangle_gnu3.cpp b/demangler/gnu3/demangle_gnu3.cpp index 412003d1..fdef5b8f 100644 --- a/demangler/gnu3/demangle_gnu3.cpp +++ b/demangler/gnu3/demangle_gnu3.cpp @@ -15,15 +15,19 @@ // Includes snippets from LLVM, which is under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. -#include "binaryninjaapi.h" +#include "demangle_gnu3.h" #include <stdarg.h> #include <algorithm> #include <memory> -#include "demangle_gnu3.h" +#ifdef BINARYNINJACORE_LIBRARY +using namespace BinaryNinjaCore; +#define GetClass GetTypeClass +#else using namespace BinaryNinja; using namespace std; +#endif #define MAX_DEMANGLE_LENGTH 4096 @@ -2346,8 +2350,13 @@ public: return DemangleGNU3::IsGNU3MangledString(name); } +#ifdef BINARYNINJACORE_LIBRARY + virtual bool Demangle(Architecture* arch, const string& name, Ref<Type>& outType, QualifiedName& outVarName, + BinaryView* view) override +#else virtual bool Demangle(Ref<Architecture> arch, const string& name, Ref<Type>& outType, QualifiedName& outVarName, Ref<BinaryView> view) override +#endif { if (view) return DemangleGNU3::DemangleStringGNU3(arch, name, outType, outVarName, view); @@ -2358,9 +2367,13 @@ public: extern "C" { +#ifndef BINARYNINJACORE_LIBRARY BN_DECLARE_CORE_ABI_VERSION +#endif -#ifdef DEMO_EDITION +#ifdef BINARYNINJACORE_LIBRARY + bool DemangleGNU3PluginInit() +#elif defined(DEMO_EDITION) bool DemangleGNU3PluginInit() #else BINARYNINJAPLUGIN bool CorePluginInit() |
