aboutsummaryrefslogtreecommitdiff
path: root/lld/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lld/lib')
-rw-r--r--lld/lib/Core/Resolver.cpp11
-rw-r--r--lld/lib/Core/SymbolTable.cpp18
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp31
-rw-r--r--lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp2
-rw-r--r--lld/lib/ReaderWriter/MachO/File.h2
-rw-r--r--lld/lib/ReaderWriter/MachO/GOTPass.cpp2
-rw-r--r--lld/lib/ReaderWriter/MachO/LayoutPass.cpp4
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp2
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp4
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp2
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp14
-rw-r--r--lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp4
12 files changed, 44 insertions, 52 deletions
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 7e6d95f8223f..d1c3d8159f58 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -223,8 +223,8 @@ bool Resolver::resolveUndefines() {
if (!file)
return true;
if (std::error_code ec = file->parse()) {
- llvm::errs() << "Cannot open " + file->path()
- << ": " << ec.message() << "\n";
+ llvm::errs() << "Cannot open " + file->path() << ": " << ec.message()
+ << "\n";
return false;
}
DEBUG_WITH_TYPE("resolver",
@@ -424,9 +424,8 @@ bool Resolver::checkUndefines() {
// Seems like this symbol is undefined. Warn that.
foundUndefines = true;
if (_ctx.printRemainingUndefines()) {
- llvm::errs() << "Undefined symbol: " << undef->file().path()
- << ": " << _ctx.demangle(undef->name())
- << "\n";
+ llvm::errs() << "Undefined symbol: " << undef->file().path() << ": "
+ << _ctx.demangle(undef->name()) << "\n";
}
}
if (!foundUndefines)
@@ -436,7 +435,7 @@ bool Resolver::checkUndefines() {
return true;
}
-// remove from _atoms all coaleseced away atoms
+// Remove from _atoms all coalesced away atoms.
void Resolver::removeCoalescedAwayAtoms() {
DEBUG_WITH_TYPE("resolver",
llvm::dbgs() << "******** Removing coalesced away atoms:\n");
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp
index 55cc27c38a62..3ce9555aa494 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -157,21 +157,15 @@ bool SymbolTable::addByName(const Atom &newAtom) {
useNew = true;
break;
}
- llvm::errs() << "Size mismatch: "
- << existing->name() << " (" << existingSize << ") "
- << newAtom.name() << " (" << newSize << ")\n";
+ llvm::errs() << "Size mismatch: " << existing->name() << " ("
+ << existingSize << ") " << newAtom.name() << " (" << newSize
+ << ")\n";
LLVM_FALLTHROUGH;
}
case MCR_Error:
- llvm::errs() << "Duplicate symbols: "
- << existing->name()
- << ":"
- << existing->file().path()
- << " and "
- << newAtom.name()
- << ":"
- << newAtom.file().path()
- << "\n";
+ llvm::errs() << "Duplicate symbols: " << existing->name() << ":"
+ << existing->file().path() << " and " << newAtom.name()
+ << ":" << newAtom.file().path() << "\n";
llvm::report_fatal_error("duplicate symbol error");
break;
}
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 8566ababc655..062e945bbd83 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -232,7 +232,7 @@ static std::error_code parseOrderFile(StringRef orderFilePath,
sym = prefixAndSym.first;
if (!sym.empty()) {
ctx.appendOrderedSymbol(sym, prefix);
- //llvm::errs() << sym << ", prefix=" << prefix << "\n";
+ // llvm::errs() << sym << ", prefix=" << prefix << "\n";
}
}
return std::error_code();
@@ -788,7 +788,7 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
break;
case llvm::MachO::MH_EXECUTE:
// dynamic executables default to generating a version load command,
- // while static exectuables only generate it if required.
+ // while static executables only generate it if required.
if (isStaticExecutable) {
if (flagOn)
ctx.setGenerateVersionLoadCommand(true);
@@ -836,7 +836,7 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
break;
case llvm::MachO::MH_EXECUTE:
// dynamic executables default to generating a version load command,
- // while static exectuables only generate it if required.
+ // while static executables only generate it if required.
if (isStaticExecutable) {
if (flagOn)
ctx.setGenerateFunctionStartsLoadCommand(true);
@@ -885,7 +885,7 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
break;
case llvm::MachO::MH_EXECUTE:
// dynamic executables default to generating a version load command,
- // while static exectuables only generate it if required.
+ // while static executables only generate it if required.
if (isStaticExecutable) {
if (flagOn)
ctx.setGenerateDataInCodeLoadCommand(true);
@@ -926,7 +926,7 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
ctx.setSdkVersion(sdkVersion);
} else if (ctx.generateVersionLoadCommand()) {
// If we don't have an sdk version, but were going to emit a load command
- // with min_version, then we need to give an warning as we have no sdk
+ // with min_version, then we need to give a warning as we have no sdk
// version to put in that command.
// FIXME: We need to decide whether to make this an error.
warn("-sdk_version is required when emitting min version load command. "
@@ -1144,14 +1144,16 @@ static void createFiles(MachOLinkingContext &ctx, bool Implicit) {
/// This is where the link is actually performed.
bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly,
- raw_ostream &Error) {
+ raw_ostream &StdoutOS, raw_ostream &StderrOS) {
+ lld::stdoutOS = &StdoutOS;
+ lld::stderrOS = &StderrOS;
+
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
errorHandler().errorLimitExceededMsg =
"too many errors emitted, stopping now (use "
"'-error-limit 0' to see all errors)";
- errorHandler().errorOS = &Error;
errorHandler().exitEarly = CanExitEarly;
- enableColors(Error.has_colors());
+ StderrOS.enable_colors(StderrOS.has_colors());
MachOLinkingContext ctx;
if (!parse(args, ctx))
@@ -1196,10 +1198,9 @@ bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly,
if (auto ec = pm.runOnFile(*merged)) {
// FIXME: This should be passed to logAllUnhandledErrors but it needs
// to be passed a Twine instead of a string.
- *errorHandler().errorOS << "Failed to run passes on file '"
- << ctx.outputPath() << "': ";
- logAllUnhandledErrors(std::move(ec), *errorHandler().errorOS,
- std::string());
+ lld::errs() << "Failed to run passes on file '" << ctx.outputPath()
+ << "': ";
+ logAllUnhandledErrors(std::move(ec), lld::errs(), std::string());
return false;
}
@@ -1210,10 +1211,8 @@ bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly,
if (auto ec = ctx.writeFile(*merged)) {
// FIXME: This should be passed to logAllUnhandledErrors but it needs
// to be passed a Twine instead of a string.
- *errorHandler().errorOS << "Failed to write file '" << ctx.outputPath()
- << "': ";
- logAllUnhandledErrors(std::move(ec), *errorHandler().errorOS,
- std::string());
+ lld::errs() << "Failed to write file '" << ctx.outputPath() << "': ";
+ logAllUnhandledErrors(std::move(ec), lld::errs(), std::string());
return false;
}
diff --git a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
index 44e6a29a0b60..94a105a6f159 100644
--- a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
+++ b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
@@ -304,7 +304,7 @@ private:
// also probably be sorted by frequency.
assert(personalities.size() <= 4);
- // TODO: Find commmon encodings for use by compressed pages.
+ // TODO: Find common encodings for use by compressed pages.
std::vector<uint32_t> commonEncodings;
// Now sort the entries by final address and fixup the compact encoding to
diff --git a/lld/lib/ReaderWriter/MachO/File.h b/lld/lib/ReaderWriter/MachO/File.h
index 1cc1c4109dce..072702973f81 100644
--- a/lld/lib/ReaderWriter/MachO/File.h
+++ b/lld/lib/ReaderWriter/MachO/File.h
@@ -135,7 +135,7 @@ public:
_undefAtoms[name] = atom;
}
- /// Search this file for an the atom from 'section' that covers
+ /// Search this file for the atom from 'section' that covers
/// 'offsetInSect'. Returns nullptr is no atom found.
MachODefinedAtom *findAtomCoveringAddress(const Section &section,
uint64_t offsetInSect,
diff --git a/lld/lib/ReaderWriter/MachO/GOTPass.cpp b/lld/lib/ReaderWriter/MachO/GOTPass.cpp
index 514dd4e09da8..0f80dfa19d09 100644
--- a/lld/lib/ReaderWriter/MachO/GOTPass.cpp
+++ b/lld/lib/ReaderWriter/MachO/GOTPass.cpp
@@ -109,7 +109,7 @@ private:
assert(target != nullptr);
if (!shouldReplaceTargetWithGOTAtom(target, canBypassGOT)) {
- // Update reference kind to reflect that target is a direct accesss.
+ // Update reference kind to reflect that target is a direct access.
_archHandler.updateReferenceToGOT(ref, false);
} else {
// Replace the target with a reference to a GOT entry.
diff --git a/lld/lib/ReaderWriter/MachO/LayoutPass.cpp b/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
index 8db6ffb958a4..775d3b0bad3a 100644
--- a/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
+++ b/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
@@ -241,8 +241,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc,
return leftOrdinal < rightOrdinal;
}
- llvm::errs() << "Unordered: <" << left->name() << "> <"
- << right->name() << ">\n";
+ llvm::errs() << "Unordered: <" << left->name() << "> <" << right->name()
+ << ">\n";
llvm_unreachable("Atoms with Same Ordinal!");
}
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index 221d895a40d0..0be1c10a7ab0 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -830,7 +830,7 @@ void MachOLinkingContext::addExportSymbol(StringRef sym) {
}
// Only i386 MacOSX uses old ABI, so don't change those.
if ((_os != OS::macOSX) || (_arch != arch_x86)) {
- // ObjC has two differnent ABIs. Be nice and allow one export list work for
+ // ObjC has two different ABIs. Be nice and allow one export list work for
// both ABIs by renaming symbols.
if (sym.startswith(".objc_class_name_")) {
std::string abi2className("_OBJC_CLASS_$_");
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index ab7ea7e07f23..17b45b9ca827 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -1267,7 +1267,7 @@ void TrieNode::addSymbol(const Export& entry,
edge._child->addSymbol(entry, allocator, allNodes);
return;
}
- // See if string has commmon prefix with existing edge.
+ // See if string has common prefix with existing edge.
for (int n=edgeStr.size()-1; n > 0; --n) {
if (partialStr.substr(0, n).equals(edgeStr.substr(0, n))) {
// Splice in new node: was A -> C, now A -> B -> C
@@ -1351,7 +1351,7 @@ bool TrieNode::updateOffset(uint32_t& offset) {
nodeSize += llvm::getULEB128Size(nodeSize);
}
// Compute size of all child edges.
- ++nodeSize; // Byte for number of chidren.
+ ++nodeSize; // Byte for number of children.
for (TrieEdge &edge : _children) {
nodeSize += edge._subString.size() + 1 // String length.
+ llvm::getULEB128Size(edge._child->_trieOffset); // Offset len.
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index 1a4603be77c0..db11f73748d8 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -1491,7 +1491,7 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
void Util::fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
NormalizedFile &file) {
- for (const auto &ref : *atom) {
+ for (const Reference *ref : *atom) {
const DefinedAtom *da = dyn_cast<DefinedAtom>(ref->target());
if (da == nullptr)
return;
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index f34857b99676..3347bb13508e 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -253,7 +253,7 @@ void atomFromSymbol(DefinedAtom::ContentType atomType, const Section &section,
? DefinedAtom::mergeAsWeak : DefinedAtom::mergeNo;
bool thumb = (symbolDescFlags & N_ARM_THUMB_DEF);
if (atomType == DefinedAtom::typeUnknown) {
- // Mach-O needs a segment and section name. Concatentate those two
+ // Mach-O needs a segment and section name. Concatenate those two
// with a / separator (e.g. "seg/sect") to fit into the lld model
// of just a section name.
std::string segSectName = section.segmentName.str()
@@ -316,7 +316,7 @@ llvm::Error processSymboledSection(DefinedAtom::ContentType atomType,
});
// Debug logging of symbols.
- //for (const Symbol *sym : symbols)
+ // for (const Symbol *sym : symbols)
// llvm::errs() << " sym: "
// << llvm::format("0x%08llx ", (uint64_t)sym->value)
// << ", " << sym->name << "\n";
@@ -326,7 +326,7 @@ llvm::Error processSymboledSection(DefinedAtom::ContentType atomType,
return llvm::Error::success();
if (symbols.empty()) {
- // Section has no symbols, put all content in one anoymous atom.
+ // Section has no symbols, put all content in one anonymous atom.
atomFromSymbol(atomType, section, file, section.address, StringRef(),
0, Atom::scopeTranslationUnit,
section.address + section.content.size(),
@@ -471,7 +471,7 @@ llvm::Error processSection(DefinedAtom::ContentType atomType,
"is not zero terminated.");
}
if (customSectionName) {
- // Mach-O needs a segment and section name. Concatentate those two
+ // Mach-O needs a segment and section name. Concatenate those two
// with a / separator (e.g. "seg/sect") to fit into the lld model
// of just a section name.
std::string segSectName = section.segmentName.str()
@@ -879,11 +879,11 @@ readCompUnit(const NormalizedFile &normalizedFile,
llvm::dwarf::DwarfFormat Format = llvm::dwarf::DwarfFormat::DWARF32;
auto infoData = dataExtractorFromSection(normalizedFile, info);
uint32_t length = infoData.getU32(&offset);
- if (length == 0xffffffff) {
+ if (length == llvm::dwarf::DW_LENGTH_DWARF64) {
Format = llvm::dwarf::DwarfFormat::DWARF64;
infoData.getU64(&offset);
}
- else if (length > 0xffffff00)
+ else if (length >= llvm::dwarf::DW_LENGTH_lo_reserved)
return llvm::make_error<GenericError>("Malformed DWARF in " + path);
uint16_t version = infoData.getU16(&offset);
@@ -1460,7 +1460,7 @@ normalizedObjectToAtoms(MachOFile *file,
}
// Create atoms from undefined symbols.
for (auto &sym : normalizedFile.undefinedSymbols) {
- // Undefinded symbols with n_value != 0 are actually tentative definitions.
+ // Undefined symbols with n_value != 0 are actually tentative definitions.
if (sym.value == Hex64(0)) {
file->addUndefinedAtom(sym.name, copyRefs);
} else {
diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
index 77936399c1af..23c20aa2ba1c 100644
--- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
+++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
@@ -121,7 +121,7 @@ public:
StringRef newName = copyString(buffer.str());
_refNames[&atom] = newName;
DEBUG_WITH_TYPE("WriterYAML",
- llvm::dbgs() << "name collsion: creating ref-name: '"
+ llvm::dbgs() << "name collision: creating ref-name: '"
<< newName << "' ("
<< (const void *)newName.data()
<< ", " << newName.size() << ")\n");
@@ -135,7 +135,7 @@ public:
StringRef newName2 = copyString(buffer2.str());
_refNames[prevAtom] = newName2;
DEBUG_WITH_TYPE("WriterYAML",
- llvm::dbgs() << "name collsion: creating ref-name: '"
+ llvm::dbgs() << "name collision: creating ref-name: '"
<< newName2 << "' ("
<< (const void *)newName2.data() << ", "
<< newName2.size() << ")\n");