From 0f26e9236d52e5e2f0a8e64114d954a516cbeb95 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Tue, 8 Apr 2025 14:16:05 -0400 Subject: [SharedCache] Apply demangled names and types more broadly Fixes the case of stub functions being applied with mangled names. --- view/sharedcache/core/Utility.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'view/sharedcache/core/Utility.cpp') diff --git a/view/sharedcache/core/Utility.cpp b/view/sharedcache/core/Utility.cpp index 396c3337..583770e6 100644 --- a/view/sharedcache/core/Utility.cpp +++ b/view/sharedcache/core/Utility.cpp @@ -65,9 +65,8 @@ uint64_t readValidULEB128(const uint8_t*& current, const uint8_t* end) return value; } -void ApplySymbol(Ref view, Ref typeLib, Ref symbol) +void ApplySymbol(Ref view, Ref typeLib, Ref symbol, Ref type) { - Ref func = nullptr; auto symbolAddress = symbol->GetAddress(); auto symbolName = symbol->GetFullName(); @@ -78,24 +77,26 @@ void ApplySymbol(Ref view, Ref typeLib, Ref sym // Define the symbol! view->DefineAutoSymbol(symbol); - // Try and pull a type to apply at the symbol location. - Ref type = nullptr; + // Try and pull a type from a type library to apply at the symbol location. + // The type library type will take precedence over the passed in type. + Ref selectedType = type; if (typeLib) - type = view->ImportTypeLibraryObject(typeLib, {symbolName}); + selectedType = view->ImportTypeLibraryObject(typeLib, {symbolName}); + Ref func = nullptr; if (symbol->GetType() == FunctionSymbol) { Ref 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); + if (!func || selectedType) + func = view->AddFunctionForAnalysis(targetPlatform, symbolAddress, false, selectedType); } else { // Other symbol types can just use this, they don't need to worry about linear sweep removing them. - view->DefineAutoSymbolAndVariableOrFunction(view->GetDefaultPlatform(), symbol, type); + view->DefineAutoSymbolAndVariableOrFunction(view->GetDefaultPlatform(), symbol, selectedType); } if (func) -- cgit v1.3.1