[PATCH] D45197: Change which file we print when a symbol cannot be ordered

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 2 19:24:01 PDT 2018


espindola created this revision.
espindola added reviewers: jhenderson, ruiu.
Herald added subscribers: arichardson, emaste.

Currently there are a few odd things about the warning about symbols that cannot be ordered. This patch fixes:

- When there is an undefined symbol that resolves to a shared file, we print the location of the undefined reference.
- If there are multiple comdats, we report them all.

This makes the warning a bit less noisy and should also help with reusing this in https://reviews.llvm.org/D36351.


https://reviews.llvm.org/D45197

Files:
  ELF/Writer.cpp
  test/ELF/symbol-ordering-file-warnings.s


Index: test/ELF/symbol-ordering-file-warnings.s
===================================================================
--- test/ELF/symbol-ordering-file-warnings.s
+++ test/ELF/symbol-ordering-file-warnings.s
@@ -103,17 +103,15 @@
 # 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:
 # MISSING:     warning: symbol ordering file: no such symbol: missing
 # 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
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<Defined>(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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45197.140728.patch
Type: text/x-patch
Size: 2378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180403/e5275bb7/attachment.bin>


More information about the llvm-commits mailing list