diff options
| author | Mason Reed <mason@vector35.com> | 2025-04-02 05:31:24 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-04-02 05:36:54 -0400 |
| commit | 96c40afe7296aba26ee7fb639517c7f16e137cc6 (patch) | |
| tree | b85fde78e1efe798cd46ab2a7a2b3de120f1caba /view/sharedcache/core/Utility.cpp | |
| parent | 04e70aeba41dcf5296637123a03bf584438976b9 (diff) | |
[SharedCache] Fix linear sweep picking up basically every function and removing it
Diffstat (limited to 'view/sharedcache/core/Utility.cpp')
| -rw-r--r-- | view/sharedcache/core/Utility.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/view/sharedcache/core/Utility.cpp b/view/sharedcache/core/Utility.cpp index c4891930..396c3337 100644 --- a/view/sharedcache/core/Utility.cpp +++ b/view/sharedcache/core/Utility.cpp @@ -71,30 +71,36 @@ void ApplySymbol(Ref<BinaryView> view, Ref<TypeLibrary> typeLib, Ref<Symbol> sym auto symbolAddress = symbol->GetAddress(); auto symbolName = symbol->GetFullName(); - if (symbol->GetType() == FunctionSymbol) - { - Ref<Platform> targetPlatform = view->GetDefaultPlatform(); - func = view->AddFunctionForAnalysis(targetPlatform, symbolAddress, true); - } + // Sometimes the symbol will be duplicated, so lets not do this work again. + if (view->GetSymbolByAddress(symbolAddress)) + return; + // Define the symbol! + view->DefineAutoSymbol(symbol); + + // Try and pull a type to apply at the symbol location. + Ref<Type> type = nullptr; if (typeLib) + type = view->ImportTypeLibraryObject(typeLib, {symbolName}); + + if (symbol->GetType() == FunctionSymbol) { - auto type = view->ImportTypeLibraryObject(typeLib, {symbolName}); - // TODO: This is still auto - if (type) - view->DefineAutoSymbolAndVariableOrFunction(view->GetDefaultPlatform(), symbol, type); - else - view->DefineAutoSymbol(symbol); + Ref<Platform> targetPlatform = view->GetDefaultPlatform(); + // Make sure to check for already added function from the function table. + // Unless we have retrieved a type here we don't need to make a new function. + func = view->GetAnalysisFunction(targetPlatform, symbolAddress); + if (!func || type) + func = view->AddFunctionForAnalysis(targetPlatform, symbolAddress, false, type); } else { - view->DefineAutoSymbol(symbol); + // Other symbol types can just use this, they don't need to worry about linear sweep removing them. + view->DefineAutoSymbolAndVariableOrFunction(view->GetDefaultPlatform(), symbol, type); } - if (!func) - func = view->GetAnalysisFunction(view->GetDefaultPlatform(), symbolAddress); if (func) { + // objective c type adjustment stuff. if (symbolName == "_objc_msgSend") { func->SetHasVariableArguments(false); |
