[PATCH] D45506: Don't warn on ICFed symbols, warn on synthetic ones

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 10 14:11:57 PDT 2018


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

This is based on the idea of https://reviews.llvm.org/D44214 but doesn't include any refactoring.


https://reviews.llvm.org/D45506

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
@@ -39,11 +39,15 @@
 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-gc.txt --gc-sections \
 # RUN:   --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,GC
 
-# Check that a warning is emitted for the symbol removed due to --icf.
+# Check that a warning is not emitted for the symbol removed due to --icf.
 # RUN: echo "icf1" > %t-order-icf.txt
 # RUN: echo "icf2" >> %t-order-icf.txt
 # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-icf.txt --icf=all \
-# RUN:   --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,ICF
+# RUN:   --unresolved-symbols=ignore-all --fatal-warnings
+
+# RUN: echo "_GLOBAL_OFFSET_TABLE_" > %t-order-synthetic.txt
+# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-synthetic.txt --icf=all \
+# RUN:   --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SYNTHETIC
 
 # Check that a warning is emitted for symbols discarded due to a linker script /DISCARD/ section.
 # RUN: echo "discard" > %t-order-discard.txt
@@ -90,13 +94,16 @@
 # RUN: echo "absolute" >> %t-order-multi.txt
 # RUN: echo "gc" >> %t-order-multi.txt
 # RUN: echo "discard" >> %t-order-multi.txt
+# RUN: echo "_GLOBAL_OFFSET_TABLE_" >> %t-order-multi.txt
 # RUN: echo "_start" >> %t-order-multi.txt
 # RUN: ld.lld %t1.o %t3.o %t.so -o %t --symbol-ordering-file %t-order-multi.txt --gc-sections -T %t.script \
-# RUN:   --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SAMESYM,ABSOLUTE,SHARED,UNDEFINED,GC,DISCARD,MISSING2
+# RUN:   --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SAMESYM,ABSOLUTE,SHARED,UNDEFINED,GC,DISCARD,MISSING2,SYNTHETIC
 
 # WARN-NOT:    warning:
 # SAMESYM:     warning: {{.*}}.txt: duplicate ordered symbol: _start
 # WARN-NOT:    warning:
+# SYNTHETIC:   warning: <internal>: unable to order synthetic symbol: _GLOBAL_OFFSET_TABLE_
+# WARN-NOT:    warning:
 # DISCARD:     warning: {{.*}}1.o: unable to order discarded symbol: discard
 # WARN-NOT:    warning:
 # GC:          warning: {{.*}}1.o: unable to order discarded symbol: gc
@@ -109,7 +116,6 @@
 # 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
 # MULTI:       warning: {{.*}}3.o: unable to order undefined symbol: multi
 # MULTI-NEXT:  warning: {{.*}}2.o: unable to order absolute symbol: multi
@@ -156,4 +162,4 @@
 # This is a "good" instance of the symbol
 .section .text.multi,"ax", at progbits
 multi:
-  nop
+  .quad _GLOBAL_OFFSET_TABLE_
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1065,7 +1065,10 @@
       else if (D && !D->Section)
         warn(toString(File) +
              ": unable to order absolute symbol: " + Sym.getName());
-      else if (D && !D->Section->Live)
+      else if (D && isa<OutputSection>(D->Section))
+        warn(toString(File) +
+             ": unable to order synthetic symbol: " + Sym.getName());
+      else if (D && !D->Section->Repl->Live)
         warn(toString(File) +
              ": unable to order discarded symbol: " + Sym.getName());
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45506.141910.patch
Type: text/x-patch
Size: 3582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180410/8e3a9d19/attachment.bin>


More information about the llvm-commits mailing list