Skip to content

Commit

Permalink
Fix duplicate symbol entries in Symtab:everyFunction
Browse files Browse the repository at this point in the history
A function should only be added to everyFunction if it was not already
in funcsByOffset or if it lives in a different code region from the
function found with the same offset.

This was introduced by #1534.
  • Loading branch information
hainest committed Sep 28, 2023
1 parent 747f0d8 commit 0a35565
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions symtabAPI/src/Symtab.C
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,13 @@ bool Symtab::addSymbolToAggregates(const Symbol *sym_tmp)
// If no function exists, create and add.
// Combine this information
// Add this symbol's names to the function.
// Keep module information
// Keep module information

auto add_func = [this](Function *f) {
boost::unique_lock<dyn_rwlock> l(symbols_rwlock);
everyFunction.push_back(f);
sorted_everyFunction = false;
};

Function *func = NULL;
bool found = false;
Expand Down Expand Up @@ -619,17 +625,14 @@ bool Symtab::addSymbolToAggregates(const Symbol *sym_tmp)

if( func->getRegion() != sym->getRegion() ) {
func = new Function(sym);
add_func(func);
} else {
// The function has an additional name
// e.g., two symbols aliasing the same code location
func->addSymbol(sym);
}
}

{
boost::unique_lock<dyn_rwlock> l(symbols_rwlock);
everyFunction.push_back(func);
sorted_everyFunction = false;
} else {
add_func(func);
}

sym->setFunction(func);
Expand Down

0 comments on commit 0a35565

Please sign in to comment.