@@ -813,8 +813,6 @@ void RewriteInstance::discoverFileObjects() {
813
813
814
814
// For local symbols we want to keep track of associated FILE symbol name for
815
815
// disambiguation by combined name.
816
- bool SeenFileName = false ;
817
- std::vector<std::pair<DataRefImpl, StringRef>> FileSymbols;
818
816
for (const ELFSymbolRef &Symbol : InputFile->symbols ()) {
819
817
Expected<StringRef> NameOrError = Symbol.getName ();
820
818
if (NameOrError && NameOrError->starts_with (" __asan_init" )) {
@@ -833,18 +831,8 @@ void RewriteInstance::discoverFileObjects() {
833
831
if (cantFail (Symbol.getFlags ()) & SymbolRef::SF_Undefined)
834
832
continue ;
835
833
836
- if (cantFail (Symbol.getType ()) == SymbolRef::ST_File) {
834
+ if (cantFail (Symbol.getType ()) == SymbolRef::ST_File)
837
835
FileSymbols.emplace_back (Symbol);
838
- StringRef Name =
839
- cantFail (std::move (NameOrError), " cannot get symbol name for file" );
840
- // Ignore Clang LTO artificial FILE symbol as it is not always generated,
841
- // and this uncertainty is causing havoc in function name matching.
842
- if (Name == " ld-temp.o" )
843
- continue ;
844
- FileSymbols.emplace_back (Symbol.getRawDataRefImpl (), Name);
845
- SeenFileName = true ;
846
- continue ;
847
- }
848
836
}
849
837
850
838
// Sort symbols in the file by value. Ignore symbols from non-allocatable
@@ -1019,16 +1007,11 @@ void RewriteInstance::discoverFileObjects() {
1019
1007
// The <id> field is used for disambiguation of local symbols since there
1020
1008
// could be identical function names coming from identical file names
1021
1009
// (e.g. from different directories).
1022
- auto CompareSymsByIdx = [](const std::pair<DataRefImpl, StringRef> &A,
1023
- const std::pair<DataRefImpl, StringRef> &B) {
1024
- return A.first .d .b < B.first .d .b ;
1025
- };
1026
- DataRefImpl SymDataRef = Symbol.getRawDataRefImpl ();
1027
- auto SFI = llvm::upper_bound (FileSymbols,
1028
- std::make_pair (SymDataRef, StringRef ()),
1029
- CompareSymsByIdx);
1030
- if (SymbolType == SymbolRef::ST_Function && SFI != FileSymbols.begin ())
1031
- AlternativeName = NR.uniquify (Name + " /" + SFI[-1 ].second .str ());
1010
+ auto SFI = llvm::upper_bound (FileSymbols, ELFSymbolRef (Symbol));
1011
+ if (SymbolType == SymbolRef::ST_Function && SFI != FileSymbols.begin ()) {
1012
+ StringRef FileSymbolName = cantFail (SFI[-1 ].getName ());
1013
+ AlternativeName = NR.uniquify (Name + " /" + FileSymbolName.str ());
1014
+ }
1032
1015
1033
1016
UniqueName = NR.uniquify (Name);
1034
1017
}
0 commit comments