diff options
Diffstat (limited to 'lld/lib')
-rw-r--r-- | lld/lib/Passes/LayoutPass.cpp | 20 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/CoreLinkingContext.cpp | 2 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp | 2 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp | 2 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp | 2 |
5 files changed, 19 insertions, 9 deletions
diff --git a/lld/lib/Passes/LayoutPass.cpp b/lld/lib/Passes/LayoutPass.cpp index d58fbcf3a96..a98fb8ab664 100644 --- a/lld/lib/Passes/LayoutPass.cpp +++ b/lld/lib/Passes/LayoutPass.cpp @@ -63,14 +63,21 @@ static std::string atomToDebugString(const Atom *atom) { return str; } -static void showCycleDetectedError(AtomToAtomT &followOnNexts, +static void showCycleDetectedError(const Registry ®istry, + AtomToAtomT &followOnNexts, const DefinedAtom *atom) { const DefinedAtom *start = atom; llvm::dbgs() << "There's a cycle in a follow-on chain!\n"; do { llvm::dbgs() << " " << atomToDebugString(atom) << "\n"; for (const Reference *ref : *atom) { - llvm::dbgs() << " " << atomToDebugString(ref->target()) << "\n"; + StringRef kindValStr; + if (!registry.referenceKindToString(ref->kindNamespace(), ref->kindArch(), + ref->kindValue(), kindValStr)) { + kindValStr = "<unknown>"; + } + llvm::dbgs() << " " << kindValStr + << ": " << atomToDebugString(ref->target()) << "\n"; } atom = followOnNexts[atom]; } while (atom != start); @@ -80,7 +87,8 @@ static void showCycleDetectedError(AtomToAtomT &followOnNexts, /// Exit if there's a cycle in a followon chain reachable from the /// given root atom. Uses the tortoise and hare algorithm to detect a /// cycle. -static void checkNoCycleInFollowonChain(AtomToAtomT &followOnNexts, +static void checkNoCycleInFollowonChain(const Registry ®istry, + AtomToAtomT &followOnNexts, const DefinedAtom *root) { const DefinedAtom *tortoise = root; const DefinedAtom *hare = followOnNexts[root]; @@ -88,7 +96,7 @@ static void checkNoCycleInFollowonChain(AtomToAtomT &followOnNexts, if (!tortoise || !hare) return; if (tortoise == hare) - showCycleDetectedError(followOnNexts, tortoise); + showCycleDetectedError(registry, followOnNexts, tortoise); tortoise = followOnNexts[tortoise]; hare = followOnNexts[followOnNexts[hare]]; } @@ -138,7 +146,7 @@ void LayoutPass::checkFollowonChain(MutableFile::DefinedAtomRange &range) { for (const auto &ai : _followOnRoots) roots.insert(ai.second); for (const DefinedAtom *root : roots) - checkNoCycleInFollowonChain(_followOnNexts, root); + checkNoCycleInFollowonChain(_registry, _followOnNexts, root); // Verify that all the atoms in followOnNexts have references to // their roots. @@ -247,6 +255,8 @@ static bool compareAtoms(const LayoutPass::SortKey &lc, return result; } +LayoutPass::LayoutPass(const Registry ®istry) : _registry(registry) {} + // Returns the atom immediately followed by the given atom in the followon // chain. const DefinedAtom *LayoutPass::findAtomFollowedBy( diff --git a/lld/lib/ReaderWriter/CoreLinkingContext.cpp b/lld/lib/ReaderWriter/CoreLinkingContext.cpp index 2e4d45dea48..31d8440b099 100644 --- a/lld/lib/ReaderWriter/CoreLinkingContext.cpp +++ b/lld/lib/ReaderWriter/CoreLinkingContext.cpp @@ -262,7 +262,7 @@ bool CoreLinkingContext::validateImpl(raw_ostream &) { void CoreLinkingContext::addPasses(PassManager &pm) { for (StringRef name : _passNames) { if (name.equals("layout")) - pm.add(std::unique_ptr<Pass>((new LayoutPass()))); + pm.add(std::unique_ptr<Pass>(new LayoutPass(registry()))); else if (name.equals("GOT")) pm.add(std::unique_ptr<Pass>(new TestingGOTPass(*this))); else if (name.equals("stubs")) diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp index c3b68909311..63ae3f4b30f 100644 --- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp @@ -54,7 +54,7 @@ bool ELFLinkingContext::isLittleEndian() const { void ELFLinkingContext::addPasses(PassManager &pm) { if (_runLayoutPass) - pm.add(std::unique_ptr<Pass>(new LayoutPass())); + pm.add(std::unique_ptr<Pass>(new LayoutPass(registry()))); pm.add(std::unique_ptr<Pass>(new elf::ArrayOrderPass())); } diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp index cb8740d1e10..5bd9a5e5df6 100644 --- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp +++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp @@ -295,7 +295,7 @@ void MachOLinkingContext::addPasses(PassManager &pm) { pm.add(std::unique_ptr<Pass>(new mach_o::GOTPass)); pm.add(std::unique_ptr<Pass>(new mach_o::StubsPass(*this))); } - pm.add(std::unique_ptr<Pass>(new LayoutPass())); + pm.add(std::unique_ptr<Pass>(new LayoutPass(registry()))); } Writer &MachOLinkingContext::writer() const { diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp index c727ab8df58..c38c4aef878 100644 --- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp @@ -262,7 +262,7 @@ void PECOFFLinkingContext::addPasses(PassManager &pm) { pm.add(std::unique_ptr<Pass>(new pecoff::SetSubsystemPass(*this))); pm.add(std::unique_ptr<Pass>(new pecoff::EdataPass(*this))); pm.add(std::unique_ptr<Pass>(new pecoff::IdataPass(*this))); - pm.add(std::unique_ptr<Pass>(new LayoutPass())); + pm.add(std::unique_ptr<Pass>(new LayoutPass(registry()))); pm.add(std::unique_ptr<Pass>(new pecoff::GroupedSectionsPass())); } |