Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -1052,21 +1052,23 @@ if (It == SymbolOrder.end()) continue; SymbolOrderEntry &Ent = It->second; + if (Ent.Present && !Sym->isLocal()) + continue; Ent.Present = true; auto *D = dyn_cast(Sym); if (Config->WarnSymbolOrdering) { if (Sym->isUndefined()) - warn(File->getName() + + warn(Sym->File->getName() + ": unable to order undefined symbol: " + Sym->getName()); else if (Sym->isShared()) - warn(File->getName() + + warn(Sym->File->getName() + ": unable to order shared symbol: " + Sym->getName()); else if (D && !D->Section) - warn(File->getName() + + warn(Sym->File->getName() + ": unable to order absolute symbol: " + Sym->getName()); else if (D && !D->Section->Live) - warn(File->getName() + + warn(Sym->File->getName() + ": unable to order discarded symbol: " + Sym->getName()); } if (!D) Index: test/ELF/symbol-ordering-file-warnings.s =================================================================== --- test/ELF/symbol-ordering-file-warnings.s +++ test/ELF/symbol-ordering-file-warnings.s @@ -103,7 +103,7 @@ # WARN-NOT: warning: # GC: warning: {{.*}}1.o: unable to order discarded symbol: gc # WARN-NOT: warning: -# SHARED: warning: {{.*}}1.o: unable to order shared symbol: shared +# SHARED: warning: {{.*}}.so: unable to order shared symbol: shared # WARN-NOT: warning: # UNDEFINED: warning: {{.*}}3.o: unable to order undefined symbol: undefined # WARN-NOT: warning: @@ -111,9 +111,7 @@ # MISSING2: warning: symbol ordering file: no such symbol: missing_sym # ICF: warning: {{.*}}1.o: unable to order discarded symbol: icf2 # COMDAT: warning: {{.*}}1.o: unable to order discarded symbol: comdat -# COMDAT-NEXT: warning: {{.*}}2.o: unable to order discarded symbol: comdat # MULTI: warning: {{.*}}2.o: unable to order absolute symbol: multi -# MULTI-NEXT: warning: {{.*}}3.o: unable to order undefined symbol: multi # WARN-NOT: warning: absolute = 0x1234