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(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()); } 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: : 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",@progbits multi: - nop + .quad _GLOBAL_OFFSET_TABLE_