diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 6743de95cd2f016b000c1eb1930453888dafe0f7..bd7ad685c4364c5737bad0aef05ba19502311a49 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -558,6 +558,7 @@ static struct AdltWriter { template void trackPhdr(OutputSection *sec, PhdrEntry *phdr); template void traceRelocs(); template void tracePhdrs(); + template void traceDuplicates(); } adltWriter; } // namespace @@ -674,6 +675,33 @@ template void AdltWriter::tracePhdrs() { } } +template void AdltWriter::traceDuplicates() { + SmallVector*, Symbol*>, 0> duplicates; + lld::outs() << "[ADLT] Duplicate symbols:\n"; + for (auto cachedName : ctx->adlt.duplicatedSymNames) { + StringRef name = cachedName.val(); + for (auto *file : ctx->sharedFilesExtended) + if (auto *soFile = cast>(file)) { + StringRef newName = soFile->addAdltPostfix(name); + Symbol *sym = elf::symtab->find(newName); + if (sym != nullptr) + duplicates.push_back({soFile, sym}); + } + + lld::outs() << "[ADLT] " << name << ":\n"; + lld::outs() << "Shared files indexes: "; + for (auto it : duplicates) + lld::outs() << it.first->orderIdx << " "; + lld::outs() << "\n"; + + for (auto it : duplicates) + lld::outs() << it.first->orderIdx << ": " + << it.second->getOutputSection()->name << "\t" + << it.first->soName << "\n"; + duplicates.clear(); + } +} + StringRef AdltWriter::phdrTypeToStr(uint32_t p_type) { switch (p_type) { case PT_PHDR: @@ -2347,6 +2375,7 @@ template void Writer::finalizeSections() { adltWriter.checkPhdrs(); adltWriter.checkRelocs(); if (config->adltTrace) { + adltWriter.traceDuplicates(); adltWriter.tracePhdrs(); adltWriter.traceRelocs(); }