diff options
| author | Fangrui Song <maskray@google.com> | 2019-05-22 09:06:42 +0000 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-05-22 09:06:42 +0000 |
| commit | b72b091389f6027882c32f4181139cb6af56f9ea (patch) | |
| tree | 1f668597bb6525c677e6f8dc61a02987e9b5509f /lld/ELF/SymbolTable.cpp | |
| parent | 1d846e1a4d64fbf892f2a16d76a4300af679699b (diff) | |
| download | bcm5719-llvm-b72b091389f6027882c32f4181139cb6af56f9ea.tar.gz bcm5719-llvm-b72b091389f6027882c32f4181139cb6af56f9ea.zip | |
[ELF] Improve error message for relocations to symbols defined in discarded sections
Rather than report "undefined symbol: ", give more informative message
about the object file that defines the discarded section.
In particular, PR41133, if the section is a discarded COMDAT, print the
section group signature and the object file with the prevailing
definition. This is useful to track down some ODR issues.
We need to
* add `uint32_t DiscardedSecIdx` to Undefined for this feature.
* make ComdatGroups public and change its type to DenseMap<CachedHashStringRef, const InputFile *>
Reviewed By: ruiu
Differential Revision: https://reviews.llvm.org/D59649
llvm-svn: 361359
Diffstat (limited to 'lld/ELF/SymbolTable.cpp')
| -rw-r--r-- | lld/ELF/SymbolTable.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 7bad4f92a69..b6d1741f856 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -46,7 +46,7 @@ template <class ELFT> void SymbolTable::addCombinedLTOObject() { LTO->add(*F); for (InputFile *File : LTO->compile()) { - DenseSet<CachedHashStringRef> DummyGroups; + DenseMap<CachedHashStringRef, const InputFile *> DummyGroups; auto *Obj = cast<ObjFile<ELFT>>(File); Obj->parse(DummyGroups); for (Symbol *Sym : Obj->getGlobalSymbols()) @@ -135,7 +135,11 @@ Symbol *SymbolTable::addSymbol(const Symbol &New) { static void addUndefined(Symbol *Old, const Undefined &New) { // An undefined symbol with non default visibility must be satisfied // in the same DSO. - if (Old->isShared() && New.Visibility != STV_DEFAULT) { + // + // If this is a non-weak defined symbol in a discarded section, override the + // existing undefined symbol for better error message later. + if ((Old->isShared() && New.Visibility != STV_DEFAULT) || + (Old->isUndefined() && New.Binding != STB_WEAK && New.DiscardedSecIdx)) { Old->replace(New); return; } |

