Skip to content

Commit 5320c69

Browse files
committed
Use heuristic confidence for ELF symbol auto-type inference.
1 parent 5cab99a commit 5320c69

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

view/elf/elfview.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,7 +2526,7 @@ void ElfView::DefineElfSymbol(BNSymbolType type, const string& incomingName, uin
25262526
// Try to demangle any C++ symbols
25272527
string shortName = rawName;
25282528
string fullName = rawName;
2529-
Ref<Type> typeRef = symbolTypeRef;
2529+
Confidence<Ref<Type>> typeRef = symbolTypeRef;
25302530
if (m_arch)
25312531
{
25322532
QualifiedName demangledName;
@@ -2542,18 +2542,19 @@ void ElfView::DefineElfSymbol(BNSymbolType type, const string& incomingName, uin
25422542
}
25432543
}
25442544

2545+
// If unable to extract type information, create a default type with the given size and heuristic confidence
25452546
if (!typeRef && (size > 0 && size <= 8))
25462547
{
2547-
typeRef = Type::IntegerType(size, false);
2548+
typeRef = Type::IntegerType(size, false)->WithConfidence(BN_HEURISTIC_CONFIDENCE);
25482549
}
25492550

2550-
return std::pair<Ref<Symbol>, Ref<Type>>(
2551+
return std::pair<Ref<Symbol>, Confidence<Ref<Type>>>(
25512552
new Symbol(type, shortName, fullName, rawName, addr, binding, nameSpace), typeRef);
25522553
};
25532554

25542555
if (m_symbolQueue)
25552556
{
2556-
m_symbolQueue->Append(process, [this](Symbol* symbol, Type* type) {
2557+
m_symbolQueue->Append(process, [this](Symbol* symbol, const Confidence<Ref<Type>>& type) {
25572558
DefineAutoSymbolAndVariableOrFunction(GetDefaultPlatform(), symbol, type);
25582559
});
25592560
}

0 commit comments

Comments
 (0)