diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 24224c8cce54d2138e519ca1f484e853eee585a3..c052caf38e961db0e26d72a70d0087d0c8bf4e8e 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -831,7 +831,7 @@ template static uint32_t readAndFeatures(const InputSection &sec) { ArrayRef data = sec.rawData; auto reportFatal = [&](const uint8_t *place, const char *msg) { fatal(toString(sec.file) + ":(" + sec.name + "+0x" + - Twine::utohexstr(place - sec.rawData.data()) + "): " + msg); + utohexstr(place - sec.rawData.data()) + "): " + msg); }; while (!data.empty()) { // Read one NOTE record. @@ -1725,10 +1725,10 @@ Defined *SharedFileExtended::findSectionSymbol(uint64_t offset) const { uint64_t high = low + d->section->size; if (isDebug) - lld::outs() << "offset: 0x" + Twine::utohexstr(offset) + + lld::outs() << "offset: 0x" + utohexstr(offset) + "sect name: " + d->section->name + "low 0x" + - Twine::utohexstr(low) + " high: 0x" + - Twine::utohexstr(offset) + "\n"; + utohexstr(low) + " high: 0x" + + utohexstr(offset) + "\n"; return (offset >= low) && (offset < high); }; @@ -1785,20 +1785,21 @@ Defined *SharedFileExtended::findDefinedSymbol( auto e = this->allSymbols.end(); auto ret = std::find_if(i, e, predRange); if (ret != e) { // item was found - Defined* d = cast(*ret); + Defined *d = cast(*ret); if (isDebug) traceSymbol(*d, "found defined sym: "); return d; } - auto* sectionSym = findSectionSymbol(offset); + auto *sectionSym = findSectionSymbol(offset); if (!sectionSym) - fatal(fatalTitle + " 0x" + Twine::utohexstr(offset) + "\n"); + fatal(fatalTitle + " 0x" + utohexstr(offset) + "\n"); return sectionSym; } template -StringRef SharedFileExtended::getShStrTab(ArrayRef elfSections) { +StringRef +SharedFileExtended::getShStrTab(ArrayRef elfSections) { return CHECK(this->getObj().getSectionStringTable(elfSections), this); } @@ -1807,13 +1808,13 @@ void SharedFileExtended::traceElfSymbol(const Elf_Sym &sym, StringRef strTable) const { const ELFFile obj = this->getObj(); auto rawSec = obj.getSection(sym.st_shndx); - auto parsedSec = !rawSec.takeError() ? *obj.getSection(sym.st_shndx) : nullptr; + auto parsedSec = + !rawSec.takeError() ? *obj.getSection(sym.st_shndx) : nullptr; lld::outs() << "File: " << soName << " symName: " << *sym.getName(strTable) - << " val: 0x" << Twine::utohexstr(sym.st_value) << " sec of sym: " + << " val: 0x" << utohexstr(sym.st_value) << " sec of sym: " << (parsedSec ? *obj.getSectionName(*parsedSec) : "unknown!") - << " sym type: 0x" << Twine::utohexstr(sym.getType()) - << " sym binding: 0x" << Twine::utohexstr(sym.getBinding()) - << '\n'; + << " sym type: 0x" << utohexstr(sym.getType()) + << " sym binding: 0x" << utohexstr(sym.getBinding()) << '\n'; } template @@ -1822,34 +1823,35 @@ void SharedFileExtended::traceElfSection(const Elf_Shdr &sec) const { auto secName = *obj.getSectionName(sec); lld::outs() << "File: " << soName << " sec: " << secName << " sec addr: 0x" - << Twine::utohexstr(sec.sh_addr) << " sec offs: 0x" - << Twine::utohexstr(sec.sh_offset) << " sec ent size: 0x" - << Twine::utohexstr(sec.sh_entsize) << '\n'; + << utohexstr(sec.sh_addr) << " sec offs: 0x" + << utohexstr(sec.sh_offset) << " sec ent size: 0x" + << utohexstr(sec.sh_entsize) << '\n'; } template void SharedFileExtended::traceSymbol(const Symbol &sym, StringRef title) const { lld::outs() << "File: " << soName << ": " + title - << " symName: " << sym.getName(); + << " symName: " << sym.getName() << " exportDynamic: 0x" + << utohexstr(sym.exportDynamic); if (!sym.isDefined()) { lld::outs() << '\n'; return; } auto &d = cast(sym); - lld::outs() << " val: 0x" << Twine::utohexstr(d.value) + lld::outs() << " val: 0x" << utohexstr(d.value) << " sec of sym: " << (d.section ? d.section->name : "unknown!") - << " sym type: 0x" << Twine::utohexstr(d.type) - << " sym binding: 0x" << Twine::utohexstr(d.binding) << '\n'; + << " sym type: 0x" << utohexstr(d.type) << " sym binding: 0x" + << utohexstr(d.binding) << '\n'; } template void SharedFileExtended::traceSection(const SectionBase &sec, StringRef title) const { lld::outs() << "File: " << soName << ": " + title << " sec: " << sec.name - << " sec addr: 0x" << Twine::utohexstr(sec.address) - << " sec offs: 0x" << Twine::utohexstr(sec.getOffset(0)) - << " sec ent size: 0x" << Twine::utohexstr(sec.entsize) << '\n'; + << " sec addr: 0x" << utohexstr(sec.address) << " sec offs: 0x" + << utohexstr(sec.getOffset(0)) << " sec ent size: 0x" + << utohexstr(sec.entsize) << '\n'; } template @@ -1867,9 +1869,12 @@ Symbol &SharedFileExtended::getSymbolADLT(uint32_t symbolIndex, if (name.empty()) return sym; + /*if (name.contains("_ZdlPv")) // debug hint + lld::outs() << "debug getSymbolADLT(): " << name << "\n";*/ + // check SymbolTable auto res = elf::symtab->find(name); - if (res && res->exportDynamic) + if (res && (res->exportDynamic || res->versionId)) return *res; // check SymbolTableBaseSection diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 1adda8cd4c25560611208d37b47af0973c919da6..3e3874a4ddce8e2a23688bac35d9c7a9037d0beb 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -100,7 +100,8 @@ void elf::reportRangeError(uint8_t *loc, const Relocation &rel, const Twine &v, ErrorPlace errPlace = getErrorPlace(loc); std::string hint; if (rel.sym && !rel.sym->isSection()) - hint = "; references " + lld::toString(*rel.sym); + hint = "; references " + lld::toString(*rel.sym) + + (config->adlt ? ": raw-name: " + rel.sym->getName().str() + " " : ""); if (!errPlace.srcLoc.empty()) hint += "\n>>> referenced by " + errPlace.srcLoc; if (rel.sym && !rel.sym->isSection()) @@ -1340,7 +1341,9 @@ template void RelocationScanner::tracePushRelocADLT(Defined &symWhere, Relocation &r) const { auto file = sec.getSharedFile(); - lld::outs() << "[ADLT] Before push: type: " + toString(r.type) + + auto fullOffset = symWhere.section->address + r.offset; + lld::outs() << "[ADLT] Before push: [" + utohexstr(fullOffset) + + "] type: " + toString(r.type) + " expr: " + toString(r.expr) + " offset: 0x" + utohexstr(r.offset) + " addend: 0x" + utohexstr(r.addend) + ".\n"; @@ -1375,7 +1378,7 @@ void RelocationScanner::processForADLT(const RelTy &rel, Relocation *r) { file->traceSection(sec, failTitle); // prepare to resolve relocs - /*if (r->sym->getName() == "__ubsan_handle_cfi_check_fail") // debug hint + /*if (r->sym->getName().contains("_ZdlPv")) // debug hint isDebug = true;*/ if (isDebug)