2018-02-14 21:36:22 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/symbol-ordering-file-warnings1.s -o %t2.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/symbol-ordering-file-warnings2.s -o %t3.o
|
|
|
|
# RUN: ld.lld -shared %t2.o -o %t.so
|
|
|
|
|
|
|
|
# Check that a warning is emitted for entries in the file that are not present in any used input.
|
|
|
|
# RUN: echo "missing" > %t-order-missing.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-missing.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,MISSING
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that the warning can be disabled.
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-missing.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all --no-warn-symbol-ordering 2>&1 | \
|
2018-02-14 21:36:22 +08:00
|
|
|
# RUN: FileCheck %s --check-prefixes=WARN --allow-empty
|
|
|
|
|
|
|
|
# Check that the warning can be re-enabled
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-missing.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all --no-warn-symbol-ordering --warn-symbol-ordering 2>&1 | \
|
2018-02-14 21:36:22 +08:00
|
|
|
# RUN: FileCheck %s --check-prefixes=WARN,MISSING
|
|
|
|
|
|
|
|
# Check that a warning is emitted for imported shared symbols.
|
|
|
|
# RUN: echo "shared" > %t-order-shared.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o %t.so -o %t --symbol-ordering-file %t-order-shared.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SHARED
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that a warning is emitted for absolute symbols.
|
|
|
|
# RUN: echo "absolute" > %t-order-absolute.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-absolute.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,ABSOLUTE
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that a warning is emitted for symbols discarded due to --gc-sections.
|
|
|
|
# RUN: echo "gc" > %t-order-gc.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# 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
|
2018-02-14 21:36:22 +08:00
|
|
|
|
2018-04-11 05:13:52 +08:00
|
|
|
# Check that a warning is not emitted for the symbol removed due to --icf.
|
2018-02-16 18:49:57 +08:00
|
|
|
# RUN: echo "icf1" > %t-order-icf.txt
|
|
|
|
# RUN: echo "icf2" >> %t-order-icf.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-icf.txt --icf=all \
|
2018-04-11 05:13:52 +08:00
|
|
|
# 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
|
2018-02-16 18:49:57 +08:00
|
|
|
|
2018-02-14 21:36:22 +08:00
|
|
|
# Check that a warning is emitted for symbols discarded due to a linker script /DISCARD/ section.
|
|
|
|
# RUN: echo "discard" > %t-order-discard.txt
|
|
|
|
# RUN: echo "SECTIONS { /DISCARD/ : { *(.text.discard) } }" > %t.script
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-discard.txt -T %t.script \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,DISCARD
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that LLD does not warn for discarded COMDAT symbols, if they are present in the kept instance.
|
|
|
|
# RUN: echo "comdat" > %t-order-comdat.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o %t2.o -o %t --symbol-ordering-file %t-order-comdat.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN --allow-empty
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that if a COMDAT was unused and discarded via --gc-sections, warn for each instance.
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o %t2.o -o %t --symbol-ordering-file %t-order-comdat.txt --gc-sections \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,COMDAT
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that if a weak symbol is not kept, because of an equivalent global symbol, no warning is emitted.
|
|
|
|
# RUN: echo "glob_or_wk" > %t-order-weak.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o %t2.o -o %t --symbol-ordering-file %t-order-weak.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN --allow-empty
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that symbols only in unused archive members result in a warning.
|
|
|
|
# RUN: rm -f %t.a
|
|
|
|
# RUN: llvm-ar rc %t.a %t3.o
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o %t.a -o %t --symbol-ordering-file %t-order-missing.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,MISSING --allow-empty
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that a warning for each same-named symbol with an issue.
|
|
|
|
# RUN: echo "multi" > %t-order-same-name.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o %t2.o %t3.o -o %t --symbol-ordering-file %t-order-same-name.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,MULTI
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that a warning is emitted if the same symbol is mentioned multiple times in the ordering file.
|
|
|
|
# RUN: echo "_start" > %t-order-multiple-same.txt
|
|
|
|
# RUN: echo "_start" >> %t-order-multiple-same.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-multiple-same.txt \
|
|
|
|
# RUN: --unresolved-symbols=ignore-all 2>&1 | FileCheck %s --check-prefixes=WARN,SAMESYM
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# Check that all warnings can be emitted from the same input.
|
|
|
|
# RUN: echo "missing_sym" > %t-order-multi.txt
|
|
|
|
# RUN: echo "undefined" >> %t-order-multi.txt
|
|
|
|
# RUN: echo "_start" >> %t-order-multi.txt
|
|
|
|
# RUN: echo "shared" >> %t-order-multi.txt
|
|
|
|
# RUN: echo "absolute" >> %t-order-multi.txt
|
|
|
|
# RUN: echo "gc" >> %t-order-multi.txt
|
|
|
|
# RUN: echo "discard" >> %t-order-multi.txt
|
2018-04-11 05:13:52 +08:00
|
|
|
# RUN: echo "_GLOBAL_OFFSET_TABLE_" >> %t-order-multi.txt
|
2018-02-14 21:36:22 +08:00
|
|
|
# RUN: echo "_start" >> %t-order-multi.txt
|
2018-03-07 08:07:26 +08:00
|
|
|
# RUN: ld.lld %t1.o %t3.o %t.so -o %t --symbol-ordering-file %t-order-multi.txt --gc-sections -T %t.script \
|
[ELF] Don't warn on undefined symbols if UnresolvedPolicy::Ignore is used
Summary:
Add a condition UnresolvedPolicy::Ignore to elf::warnUnorderedSymbol to suppress Sym->isUndefined() warnings from both
1) --symbol-ordering-file=
2) .llvm.call-graph-profile
If --unresolved-symbols=ignore-all is used,
no "undefined symbol" error/warning is emitted. It makes sense to not warn unorderable symbols.
Otherwise,
If an executable is linked, the default policy UnresolvedPolicy::ErrorOrWarn will issue a "undefined symbol" error. The unorderable symbol warning is redundant.
If a shared object is linked, it is possible that only part of object files are used and some symbols are left undefined. The warning is not very necessary.
In particular for .llvm.call-graph-profile, when linking a shared object, a call graph profile may contain undefined symbols. This case generated a warning before but it will be suppressed by this patch.
Reviewers: ruiu, davidxl, espindola
Reviewed By: ruiu
Subscribers: grimar, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D53044
llvm-svn: 344195
2018-10-11 06:48:57 +08:00
|
|
|
# RUN: 2>&1 | FileCheck %s --check-prefixes=WARN,SAMESYM,ABSOLUTE,SHARED,UNDEFINED,GC,DISCARD,MISSING2,SYNTHETIC
|
2018-02-14 21:36:22 +08:00
|
|
|
|
|
|
|
# WARN-NOT: warning:
|
|
|
|
# SAMESYM: warning: {{.*}}.txt: duplicate ordered symbol: _start
|
|
|
|
# WARN-NOT: warning:
|
2018-04-11 05:13:52 +08:00
|
|
|
# SYNTHETIC: warning: <internal>: unable to order synthetic symbol: _GLOBAL_OFFSET_TABLE_
|
|
|
|
# WARN-NOT: warning:
|
2018-02-14 21:36:22 +08:00
|
|
|
# DISCARD: warning: {{.*}}1.o: unable to order discarded symbol: discard
|
|
|
|
# WARN-NOT: warning:
|
|
|
|
# GC: warning: {{.*}}1.o: unable to order discarded symbol: gc
|
|
|
|
# WARN-NOT: warning:
|
2018-04-06 11:36:19 +08:00
|
|
|
# SHARED: warning: {{.*}}.so: unable to order shared symbol: shared
|
2018-02-14 21:36:22 +08:00
|
|
|
# WARN-NOT: warning:
|
|
|
|
# UNDEFINED: warning: {{.*}}3.o: unable to order undefined symbol: undefined
|
|
|
|
# WARN-NOT: warning:
|
2018-04-06 11:36:19 +08:00
|
|
|
# ABSOLUTE: warning: {{.*}}1.o: unable to order absolute symbol: absolute
|
|
|
|
# WARN-NOT: warning:
|
2018-02-14 21:36:22 +08:00
|
|
|
# MISSING: warning: symbol ordering file: no such symbol: missing
|
[ELF] Don't warn on undefined symbols if UnresolvedPolicy::Ignore is used
Summary:
Add a condition UnresolvedPolicy::Ignore to elf::warnUnorderedSymbol to suppress Sym->isUndefined() warnings from both
1) --symbol-ordering-file=
2) .llvm.call-graph-profile
If --unresolved-symbols=ignore-all is used,
no "undefined symbol" error/warning is emitted. It makes sense to not warn unorderable symbols.
Otherwise,
If an executable is linked, the default policy UnresolvedPolicy::ErrorOrWarn will issue a "undefined symbol" error. The unorderable symbol warning is redundant.
If a shared object is linked, it is possible that only part of object files are used and some symbols are left undefined. The warning is not very necessary.
In particular for .llvm.call-graph-profile, when linking a shared object, a call graph profile may contain undefined symbols. This case generated a warning before but it will be suppressed by this patch.
Reviewers: ruiu, davidxl, espindola
Reviewed By: ruiu
Subscribers: grimar, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D53044
llvm-svn: 344195
2018-10-11 06:48:57 +08:00
|
|
|
# WARN-NOT: warning:
|
2018-02-14 21:36:22 +08:00
|
|
|
# MISSING2: warning: symbol ordering file: no such symbol: missing_sym
|
[ELF] Don't warn on undefined symbols if UnresolvedPolicy::Ignore is used
Summary:
Add a condition UnresolvedPolicy::Ignore to elf::warnUnorderedSymbol to suppress Sym->isUndefined() warnings from both
1) --symbol-ordering-file=
2) .llvm.call-graph-profile
If --unresolved-symbols=ignore-all is used,
no "undefined symbol" error/warning is emitted. It makes sense to not warn unorderable symbols.
Otherwise,
If an executable is linked, the default policy UnresolvedPolicy::ErrorOrWarn will issue a "undefined symbol" error. The unorderable symbol warning is redundant.
If a shared object is linked, it is possible that only part of object files are used and some symbols are left undefined. The warning is not very necessary.
In particular for .llvm.call-graph-profile, when linking a shared object, a call graph profile may contain undefined symbols. This case generated a warning before but it will be suppressed by this patch.
Reviewers: ruiu, davidxl, espindola
Reviewed By: ruiu
Subscribers: grimar, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D53044
llvm-svn: 344195
2018-10-11 06:48:57 +08:00
|
|
|
# WARN-NOT: warning:
|
2018-02-14 21:36:22 +08:00
|
|
|
# COMDAT: warning: {{.*}}1.o: unable to order discarded symbol: comdat
|
[ELF] Don't warn on undefined symbols if UnresolvedPolicy::Ignore is used
Summary:
Add a condition UnresolvedPolicy::Ignore to elf::warnUnorderedSymbol to suppress Sym->isUndefined() warnings from both
1) --symbol-ordering-file=
2) .llvm.call-graph-profile
If --unresolved-symbols=ignore-all is used,
no "undefined symbol" error/warning is emitted. It makes sense to not warn unorderable symbols.
Otherwise,
If an executable is linked, the default policy UnresolvedPolicy::ErrorOrWarn will issue a "undefined symbol" error. The unorderable symbol warning is redundant.
If a shared object is linked, it is possible that only part of object files are used and some symbols are left undefined. The warning is not very necessary.
In particular for .llvm.call-graph-profile, when linking a shared object, a call graph profile may contain undefined symbols. This case generated a warning before but it will be suppressed by this patch.
Reviewers: ruiu, davidxl, espindola
Reviewed By: ruiu
Subscribers: grimar, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D53044
llvm-svn: 344195
2018-10-11 06:48:57 +08:00
|
|
|
# WARN-NOT: warning:
|
|
|
|
# MULTI: warning: {{.*}}2.o: unable to order absolute symbol: multi
|
2018-02-14 21:36:22 +08:00
|
|
|
# WARN-NOT: warning:
|
|
|
|
|
|
|
|
absolute = 0x1234
|
|
|
|
|
|
|
|
.section .text.gc,"ax",@progbits
|
|
|
|
.global gc
|
|
|
|
gc:
|
|
|
|
nop
|
|
|
|
|
|
|
|
.section .text.discard,"ax",@progbits
|
|
|
|
.global discard
|
|
|
|
discard:
|
|
|
|
nop
|
|
|
|
|
|
|
|
.section .text.comdat,"axG",@progbits,comdat,comdat
|
|
|
|
.weak comdat
|
|
|
|
comdat:
|
|
|
|
nop
|
|
|
|
|
|
|
|
.section .text.glob_or_wk,"ax",@progbits
|
|
|
|
.weak glob_or_wk
|
|
|
|
glob_or_wk:
|
|
|
|
nop
|
|
|
|
|
2018-02-16 18:49:57 +08:00
|
|
|
.section .text._start,"ax",@progbits
|
2018-02-14 21:36:22 +08:00
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
movq %rax, absolute
|
|
|
|
callq shared
|
|
|
|
|
2018-02-16 18:49:57 +08:00
|
|
|
.section .text.icf1,"ax",@progbits
|
|
|
|
.global icf1
|
|
|
|
icf1:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.section .text.icf2,"ax",@progbits
|
|
|
|
.global icf2
|
|
|
|
icf2:
|
|
|
|
ret
|
|
|
|
|
2018-02-14 21:36:22 +08:00
|
|
|
# This is a "good" instance of the symbol
|
2018-02-16 18:49:57 +08:00
|
|
|
.section .text.multi,"ax",@progbits
|
2018-02-14 21:36:22 +08:00
|
|
|
multi:
|
2018-04-11 05:13:52 +08:00
|
|
|
.quad _GLOBAL_OFFSET_TABLE_
|