diff options
Diffstat (limited to 'lib/ReaderWriter/MachO')
| -rw-r--r-- | lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp | 4 | ||||
| -rw-r--r-- | lib/ReaderWriter/MachO/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | lib/ReaderWriter/MachO/CompactUnwindPass.cpp | 43 | ||||
| -rw-r--r-- | lib/ReaderWriter/MachO/LayoutPass.cpp | 31 | ||||
| -rw-r--r-- | lib/ReaderWriter/MachO/MachOLinkingContext.cpp | 14 | ||||
| -rw-r--r-- | lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp | 6 |
6 files changed, 51 insertions, 48 deletions
diff --git a/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp b/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp index aee9959ca6b8..8cb6710857e3 100644 --- a/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp +++ b/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp @@ -674,7 +674,7 @@ void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref, *loc32 = ref.addend() + inAtomAddress - fixupAddress; return; case delta32Anon: - // The value we write here should be the the delta to the target + // The value we write here should be the delta to the target // after taking in to account the difference from the fixup back to the // last defined label // ie, if we have: @@ -690,7 +690,7 @@ void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref, *loc64 = ref.addend() + inAtomAddress - fixupAddress; return; case delta64Anon: - // The value we write here should be the the delta to the target + // The value we write here should be the delta to the target // after taking in to account the difference from the fixup back to the // last defined label // ie, if we have: diff --git a/lib/ReaderWriter/MachO/CMakeLists.txt b/lib/ReaderWriter/MachO/CMakeLists.txt index f2fc34772496..37d1de432c0f 100644 --- a/lib/ReaderWriter/MachO/CMakeLists.txt +++ b/lib/ReaderWriter/MachO/CMakeLists.txt @@ -26,6 +26,7 @@ add_lld_library(lldMachO Support LINK_LIBS + lldCommon lldCore lldYAML ${LLVM_PTHREAD_LIB} diff --git a/lib/ReaderWriter/MachO/CompactUnwindPass.cpp b/lib/ReaderWriter/MachO/CompactUnwindPass.cpp index 1e210409237f..fa0aaa103eeb 100644 --- a/lib/ReaderWriter/MachO/CompactUnwindPass.cpp +++ b/lib/ReaderWriter/MachO/CompactUnwindPass.cpp @@ -282,7 +282,7 @@ public: private: llvm::Error perform(SimpleFile &mergedFile) override { - DEBUG(llvm::dbgs() << "MachO Compact Unwind pass\n"); + LLVM_DEBUG(llvm::dbgs() << "MachO Compact Unwind pass\n"); std::map<const Atom *, CompactUnwindEntry> unwindLocs; std::map<const Atom *, const Atom *> dwarfFrames; @@ -319,7 +319,7 @@ private: // Finally, we can start creating pages based on these entries. - DEBUG(llvm::dbgs() << " Splitting entries into pages\n"); + LLVM_DEBUG(llvm::dbgs() << " Splitting entries into pages\n"); // FIXME: we split the entries into pages naively: lots of 4k pages followed // by a small one. ld64 tried to minimize space and align them to real 4k // boundaries. That might be worth doing, or perhaps we could perform some @@ -336,11 +336,13 @@ private: pages.back().entries = remainingInfos.slice(0, entriesInPage); remainingInfos = remainingInfos.slice(entriesInPage); - DEBUG(llvm::dbgs() - << " Page from " << pages.back().entries[0].rangeStart->name() - << " to " << pages.back().entries.back().rangeStart->name() << " + " - << llvm::format("0x%x", pages.back().entries.back().rangeLength) - << " has " << entriesInPage << " entries\n"); + LLVM_DEBUG(llvm::dbgs() + << " Page from " + << pages.back().entries[0].rangeStart->name() << " to " + << pages.back().entries.back().rangeStart->name() << " + " + << llvm::format("0x%x", + pages.back().entries.back().rangeLength) + << " has " << entriesInPage << " entries\n"); } while (!remainingInfos.empty()); auto *unwind = new (_file.allocator()) @@ -360,7 +362,7 @@ private: const SimpleFile &mergedFile, std::map<const Atom *, CompactUnwindEntry> &unwindLocs, std::vector<const Atom *> &personalities, uint32_t &numLSDAs) { - DEBUG(llvm::dbgs() << " Collecting __compact_unwind entries\n"); + LLVM_DEBUG(llvm::dbgs() << " Collecting __compact_unwind entries\n"); for (const DefinedAtom *atom : mergedFile.defined()) { if (atom->contentType() != DefinedAtom::typeCompactUnwindInfo) @@ -369,14 +371,15 @@ private: auto unwindEntry = extractCompactUnwindEntry(atom); unwindLocs.insert(std::make_pair(unwindEntry.rangeStart, unwindEntry)); - DEBUG(llvm::dbgs() << " Entry for " << unwindEntry.rangeStart->name() - << ", encoding=" - << llvm::format("0x%08x", unwindEntry.encoding)); + LLVM_DEBUG(llvm::dbgs() << " Entry for " + << unwindEntry.rangeStart->name() << ", encoding=" + << llvm::format("0x%08x", unwindEntry.encoding)); if (unwindEntry.personalityFunction) - DEBUG(llvm::dbgs() << ", personality=" - << unwindEntry.personalityFunction->name() - << ", lsdaLoc=" << unwindEntry.lsdaLocation->name()); - DEBUG(llvm::dbgs() << '\n'); + LLVM_DEBUG(llvm::dbgs() + << ", personality=" + << unwindEntry.personalityFunction->name() + << ", lsdaLoc=" << unwindEntry.lsdaLocation->name()); + LLVM_DEBUG(llvm::dbgs() << '\n'); // Count number of LSDAs we see, since we need to know how big the index // will be while laying out the section. @@ -454,7 +457,7 @@ private: const std::map<const Atom *, const Atom *> &dwarfFrames) { std::vector<CompactUnwindEntry> unwindInfos; - DEBUG(llvm::dbgs() << " Creating __unwind_info entries\n"); + LLVM_DEBUG(llvm::dbgs() << " Creating __unwind_info entries\n"); // The final order in the __unwind_info section must be derived from the // order of typeCode atoms, since that's how they'll be put into the object // file eventually (yuck!). @@ -465,10 +468,10 @@ private: unwindInfos.push_back(finalizeUnwindInfoEntryForAtom( atom, unwindLocs, personalities, dwarfFrames)); - DEBUG(llvm::dbgs() << " Entry for " << atom->name() - << ", final encoding=" - << llvm::format("0x%08x", unwindInfos.back().encoding) - << '\n'); + LLVM_DEBUG(llvm::dbgs() + << " Entry for " << atom->name() << ", final encoding=" + << llvm::format("0x%08x", unwindInfos.back().encoding) + << '\n'); } return unwindInfos; diff --git a/lib/ReaderWriter/MachO/LayoutPass.cpp b/lib/ReaderWriter/MachO/LayoutPass.cpp index 7bca07eb16d6..9058e4f562e2 100644 --- a/lib/ReaderWriter/MachO/LayoutPass.cpp +++ b/lib/ReaderWriter/MachO/LayoutPass.cpp @@ -191,7 +191,7 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc, // Sort atoms by their ordinal overrides only if they fall in the same // chain. if (leftRoot == rightRoot) { - DEBUG(reason = formatReason("override", lc._override, rc._override)); + LLVM_DEBUG(reason = formatReason("override", lc._override, rc._override)); return lc._override < rc._override; } @@ -200,8 +200,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc, DefinedAtom::ContentPermissions rightPerms = rightRoot->permissions(); if (leftPerms != rightPerms) { - DEBUG(reason = - formatReason("contentPerms", (int)leftPerms, (int)rightPerms)); + LLVM_DEBUG( + reason = formatReason("contentPerms", (int)leftPerms, (int)rightPerms)); return leftPerms < rightPerms; } @@ -210,7 +210,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc, DefinedAtom::ContentType rightType = rightRoot->contentType(); if (leftType != rightType) { - DEBUG(reason = formatReason("contentType", (int)leftType, (int)rightType)); + LLVM_DEBUG(reason = + formatReason("contentType", (int)leftType, (int)rightType)); return leftType < rightType; } @@ -226,8 +227,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc, const File *rightFile = &rightRoot->file(); if (leftFile != rightFile) { - DEBUG(reason = formatReason(".o order", (int)leftFile->ordinal(), - (int)rightFile->ordinal())); + LLVM_DEBUG(reason = formatReason(".o order", (int)leftFile->ordinal(), + (int)rightFile->ordinal())); return leftFile->ordinal() < rightFile->ordinal(); } @@ -236,8 +237,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc, uint64_t rightOrdinal = rightRoot->ordinal(); if (leftOrdinal != rightOrdinal) { - DEBUG(reason = formatReason("ordinal", (int)leftRoot->ordinal(), - (int)rightRoot->ordinal())); + LLVM_DEBUG(reason = formatReason("ordinal", (int)leftRoot->ordinal(), + (int)rightRoot->ordinal())); return leftOrdinal < rightOrdinal; } @@ -251,7 +252,7 @@ static bool compareAtoms(const LayoutPass::SortKey &lc, LayoutPass::SortOverride customSorter) { std::string reason; bool result = compareAtomsSub(lc, rc, customSorter, reason); - DEBUG({ + LLVM_DEBUG({ StringRef comp = result ? "<" : ">="; llvm::dbgs() << "Layout: '" << lc._atom.get()->name() << "' " << comp << " '" @@ -441,7 +442,7 @@ void LayoutPass::undecorate(File::AtomRange<DefinedAtom> &atomRange, /// Perform the actual pass llvm::Error LayoutPass::perform(SimpleFile &mergedFile) { - DEBUG(llvm::dbgs() << "******** Laying out atoms:\n"); + LLVM_DEBUG(llvm::dbgs() << "******** Laying out atoms:\n"); // sort the atoms ScopedTask task(getDefaultDomain(), "LayoutPass"); File::AtomRange<DefinedAtom> atomRange = mergedFile.defined(); @@ -450,12 +451,12 @@ llvm::Error LayoutPass::perform(SimpleFile &mergedFile) { buildFollowOnTable(atomRange); // Check the structure of followon graph if running in debug mode. - DEBUG(checkFollowonChain(atomRange)); + LLVM_DEBUG(checkFollowonChain(atomRange)); // Build override maps buildOrdinalOverrideMap(atomRange); - DEBUG({ + LLVM_DEBUG({ llvm::dbgs() << "unsorted atoms:\n"; printDefinedAtoms(atomRange); }); @@ -465,15 +466,15 @@ llvm::Error LayoutPass::perform(SimpleFile &mergedFile) { [&](const LayoutPass::SortKey &l, const LayoutPass::SortKey &r) -> bool { return compareAtoms(l, r, _customSorter); }); - DEBUG(checkTransitivity(vec, _customSorter)); + LLVM_DEBUG(checkTransitivity(vec, _customSorter)); undecorate(atomRange, vec); - DEBUG({ + LLVM_DEBUG({ llvm::dbgs() << "sorted atoms:\n"; printDefinedAtoms(atomRange); }); - DEBUG(llvm::dbgs() << "******** Finished laying out atoms\n"); + LLVM_DEBUG(llvm::dbgs() << "******** Finished laying out atoms\n"); return llvm::Error::success(); } diff --git a/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lib/ReaderWriter/MachO/MachOLinkingContext.cpp index 4ef7a62a8297..ce423d03aae3 100644 --- a/lib/ReaderWriter/MachO/MachOLinkingContext.cpp +++ b/lib/ReaderWriter/MachO/MachOLinkingContext.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "lld/Common/ErrorHandler.h" #include "lld/ReaderWriter/MachOLinkingContext.h" #include "ArchHandler.h" #include "File.h" @@ -579,29 +580,26 @@ MachOLinkingContext::findPathForFramework(StringRef fwName) const{ return llvm::None; } -bool MachOLinkingContext::validateImpl(raw_ostream &diagnostics) { +bool MachOLinkingContext::validateImpl() { // TODO: if -arch not specified, look at arch of first .o file. if (_currentVersion && _outputMachOType != MH_DYLIB) { - diagnostics << "error: -current_version can only be used with dylibs\n"; + error("-current_version can only be used with dylibs"); return false; } if (_compatibilityVersion && _outputMachOType != MH_DYLIB) { - diagnostics - << "error: -compatibility_version can only be used with dylibs\n"; + error("-compatibility_version can only be used with dylibs"); return false; } if (_deadStrippableDylib && _outputMachOType != MH_DYLIB) { - diagnostics - << "error: -mark_dead_strippable_dylib can only be used with dylibs.\n"; + error("-mark_dead_strippable_dylib can only be used with dylibs"); return false; } if (!_bundleLoader.empty() && outputMachOType() != MH_BUNDLE) { - diagnostics - << "error: -bundle_loader can only be used with Mach-O bundles\n"; + error("-bundle_loader can only be used with Mach-O bundles"); return false; } diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp index 3b07a40f9bf2..473de894894e 100644 --- a/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp +++ b/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp @@ -906,7 +906,7 @@ readCompUnit(const NormalizedFile &normalizedFile, abbrevData.getU8(&abbrevOffset); uint32_t name; llvm::dwarf::Form form; - llvm::DWARFFormParams formParams = {version, addrSize, Format}; + llvm::dwarf::FormParams formParams = {version, addrSize, Format}; TranslationUnitSource tu; while ((name = abbrevData.getULEB128(&abbrevOffset)) | (form = static_cast<llvm::dwarf::Form>( @@ -1431,8 +1431,8 @@ llvm::Error normalizedObjectToAtoms(MachOFile *file, const NormalizedFile &normalizedFile, bool copyRefs) { - DEBUG(llvm::dbgs() << "******** Normalizing file to atoms: " - << file->path() << "\n"); + LLVM_DEBUG(llvm::dbgs() << "******** Normalizing file to atoms: " + << file->path() << "\n"); bool scatterable = ((normalizedFile.flags & MH_SUBSECTIONS_VIA_SYMBOLS) != 0); // Create atoms from each section. |
