[ELF] Don't warn on undefined symbols if UnresolvedPolicy::Ignore is used
authorFangrui Song <maskray@google.com>
Wed, 10 Oct 2018 22:48:57 +0000 (22:48 +0000)
committerFangrui Song <maskray@google.com>
Wed, 10 Oct 2018 22:48:57 +0000 (22:48 +0000)
commit11ca54f49ce708e2b892e51e6b53f4d9e78176f3
tree9547a634edb9af233e0d4937896914b586cf9b40
parent81d381bd7b0cd38f2ba329eb811639c50c54ea51
[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
lld/ELF/Symbols.cpp
lld/test/ELF/cgprofile-shared-warn.s [new file with mode: 0644]
lld/test/ELF/symbol-ordering-file-warnings.s