Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -494,20 +494,12 @@ // An undefined symbol with non default visibility must be satisfied // in the same DSO. - if (WasInserted) { - replaceSymbol(S, File, Name, Sym.getBinding(), Sym.st_other, + uint8_t Binding = WasInserted ? Sym.getBinding() : S->Binding; + if (WasInserted || + ((S->isUndefined() || S->isLazy()) && S->Visibility == STV_DEFAULT)) { + replaceSymbol(S, File, Name, Binding, Sym.st_other, Sym.getType(), Sym.st_value, Sym.st_size, Alignment, VerdefIndex); - return; - } - - if ((S->isUndefined() || S->isLazy()) && S->Visibility == STV_DEFAULT) { - uint8_t Binding = S->Binding; - replaceSymbol(S, File, Name, Sym.getBinding(), Sym.st_other, - Sym.getType(), Sym.st_value, Sym.st_size, - Alignment, VerdefIndex); - - S->Binding = Binding; } }