@@ -65,9 +65,8 @@ uint64_t readValidULEB128(const uint8_t*& current, const uint8_t* end)
6565 return value;
6666}
6767
68- void ApplySymbol (Ref<BinaryView> view, Ref<TypeLibrary> typeLib, Ref<Symbol> symbol)
68+ void ApplySymbol (Ref<BinaryView> view, Ref<TypeLibrary> typeLib, Ref<Symbol> symbol, Ref<Type> type )
6969{
70- Ref<Function> func = nullptr ;
7170 auto symbolAddress = symbol->GetAddress ();
7271 auto symbolName = symbol->GetFullName ();
7372
@@ -78,24 +77,26 @@ void ApplySymbol(Ref<BinaryView> view, Ref<TypeLibrary> typeLib, Ref<Symbol> sym
7877 // Define the symbol!
7978 view->DefineAutoSymbol (symbol);
8079
81- // Try and pull a type to apply at the symbol location.
82- Ref<Type> type = nullptr ;
80+ // Try and pull a type from a type library to apply at the symbol location.
81+ // The type library type will take precedence over the passed in type.
82+ Ref<Type> selectedType = type;
8383 if (typeLib)
84- type = view->ImportTypeLibraryObject (typeLib, {symbolName});
84+ selectedType = view->ImportTypeLibraryObject (typeLib, {symbolName});
8585
86+ Ref<Function> func = nullptr ;
8687 if (symbol->GetType () == FunctionSymbol)
8788 {
8889 Ref<Platform> targetPlatform = view->GetDefaultPlatform ();
8990 // Make sure to check for already added function from the function table.
9091 // Unless we have retrieved a type here we don't need to make a new function.
9192 func = view->GetAnalysisFunction (targetPlatform, symbolAddress);
92- if (!func || type )
93- func = view->AddFunctionForAnalysis (targetPlatform, symbolAddress, false , type );
93+ if (!func || selectedType )
94+ func = view->AddFunctionForAnalysis (targetPlatform, symbolAddress, false , selectedType );
9495 }
9596 else
9697 {
9798 // Other symbol types can just use this, they don't need to worry about linear sweep removing them.
98- view->DefineAutoSymbolAndVariableOrFunction (view->GetDefaultPlatform (), symbol, type );
99+ view->DefineAutoSymbolAndVariableOrFunction (view->GetDefaultPlatform (), symbol, selectedType );
99100 }
100101
101102 if (func)
0 commit comments