summaryrefslogtreecommitdiff
path: root/lld/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lld/lib')
-rw-r--r--lld/lib/Core/Error.cpp5
-rw-r--r--lld/lib/Core/Resolver.cpp2
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp20
-rw-r--r--lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp2
-rw-r--r--lld/lib/ReaderWriter/MachO/Atoms.h4
-rw-r--r--lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp4
-rw-r--r--lld/lib/ReaderWriter/MachO/File.h72
-rw-r--r--lld/lib/ReaderWriter/MachO/GOTPass.cpp4
-rw-r--r--lld/lib/ReaderWriter/MachO/LayoutPass.cpp9
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp20
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp21
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp12
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp26
-rw-r--r--lld/lib/ReaderWriter/MachO/TLVPass.cpp4
-rw-r--r--lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp6
15 files changed, 155 insertions, 56 deletions
diff --git a/lld/lib/Core/Error.cpp b/lld/lib/Core/Error.cpp
index f138a81efaab..a4f4b1b8af48 100644
--- a/lld/lib/Core/Error.cpp
+++ b/lld/lib/Core/Error.cpp
@@ -62,7 +62,7 @@ public:
int add(std::string msg) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
- // Value zero is always the successs value.
+ // Value zero is always the success value.
if (_messages.empty())
_messages.push_back("Success");
_messages.push_back(msg);
@@ -78,7 +78,8 @@ private:
static dynamic_error_category categorySingleton;
std::error_code make_dynamic_error_code(StringRef msg) {
- return std::error_code(categorySingleton.add(msg), categorySingleton);
+ return std::error_code(categorySingleton.add(std::string(msg)),
+ categorySingleton);
}
char GenericError::ID = 0;
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index d1c3d8159f58..17a46056f00c 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -298,7 +298,7 @@ void Resolver::updateReferences() {
for (const OwningAtomPtr<Atom> &atom : _atoms) {
if (const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(atom.get())) {
for (const Reference *ref : *defAtom) {
- // A reference of type kindAssociate should't be updated.
+ // A reference of type kindAssociate shouldn't be updated.
// Instead, an atom having such reference will be removed
// if the target atom is coalesced away, so that they will
// go away as a group.
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 062e945bbd83..1a57def4ebbe 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -147,11 +147,11 @@ std::vector<std::unique_ptr<File>> loadFile(MachOLinkingContext &ctx,
static std::string canonicalizePath(StringRef path) {
char sep = llvm::sys::path::get_separator().front();
if (sep != '/') {
- std::string fixedPath = path;
+ std::string fixedPath = std::string(path);
std::replace(fixedPath.begin(), fixedPath.end(), sep, '/');
return fixedPath;
} else {
- return path;
+ return std::string(path);
}
}
@@ -650,12 +650,12 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
// Handle -exported_symbols_list <file>
for (auto expFile : parsedArgs.filtered(OPT_exported_symbols_list)) {
- if (ctx.exportMode() == MachOLinkingContext::ExportMode::blackList) {
+ if (ctx.exportMode() == MachOLinkingContext::ExportMode::unexported) {
error("-exported_symbols_list cannot be combined with "
"-unexported_symbol[s_list]");
return false;
}
- ctx.setExportMode(MachOLinkingContext::ExportMode::whiteList);
+ ctx.setExportMode(MachOLinkingContext::ExportMode::exported);
if (std::error_code ec = parseExportsList(expFile->getValue(), ctx)) {
error(ec.message() + ", processing '-exported_symbols_list " +
expFile->getValue());
@@ -665,23 +665,23 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
// Handle -exported_symbol <symbol>
for (auto symbol : parsedArgs.filtered(OPT_exported_symbol)) {
- if (ctx.exportMode() == MachOLinkingContext::ExportMode::blackList) {
+ if (ctx.exportMode() == MachOLinkingContext::ExportMode::unexported) {
error("-exported_symbol cannot be combined with "
"-unexported_symbol[s_list]");
return false;
}
- ctx.setExportMode(MachOLinkingContext::ExportMode::whiteList);
+ ctx.setExportMode(MachOLinkingContext::ExportMode::exported);
ctx.addExportSymbol(symbol->getValue());
}
// Handle -unexported_symbols_list <file>
for (auto expFile : parsedArgs.filtered(OPT_unexported_symbols_list)) {
- if (ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) {
+ if (ctx.exportMode() == MachOLinkingContext::ExportMode::exported) {
error("-unexported_symbols_list cannot be combined with "
"-exported_symbol[s_list]");
return false;
}
- ctx.setExportMode(MachOLinkingContext::ExportMode::blackList);
+ ctx.setExportMode(MachOLinkingContext::ExportMode::unexported);
if (std::error_code ec = parseExportsList(expFile->getValue(), ctx)) {
error(ec.message() + ", processing '-unexported_symbols_list " +
expFile->getValue());
@@ -691,12 +691,12 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
// Handle -unexported_symbol <symbol>
for (auto symbol : parsedArgs.filtered(OPT_unexported_symbol)) {
- if (ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) {
+ if (ctx.exportMode() == MachOLinkingContext::ExportMode::exported) {
error("-unexported_symbol cannot be combined with "
"-exported_symbol[s_list]");
return false;
}
- ctx.setExportMode(MachOLinkingContext::ExportMode::blackList);
+ ctx.setExportMode(MachOLinkingContext::ExportMode::unexported);
ctx.addExportSymbol(symbol->getValue());
}
diff --git a/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp b/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
index a424edf4985a..bee081aec067 100644
--- a/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
+++ b/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
@@ -61,7 +61,7 @@ public:
/// Used by GOTPass to update GOT References.
void updateReferenceToGOT(const Reference *ref, bool targetNowGOT) override {
- // If GOT slot was instanciated, transform:
+ // If GOT slot was instantiated, transform:
// gotPage21/gotOffset12 -> page21/offset12scale8
// If GOT slot optimized away, transform:
// gotPage21/gotOffset12 -> page21/addOffset12
diff --git a/lld/lib/ReaderWriter/MachO/Atoms.h b/lld/lib/ReaderWriter/MachO/Atoms.h
index b8bca1959cfb..c61aaa88e8df 100644
--- a/lld/lib/ReaderWriter/MachO/Atoms.h
+++ b/lld/lib/ReaderWriter/MachO/Atoms.h
@@ -112,8 +112,8 @@ class MachOTentativeDefAtom : public SimpleDefinedAtom {
public:
MachOTentativeDefAtom(const File &f, const StringRef name, Scope scope,
uint64_t size, DefinedAtom::Alignment align)
- : SimpleDefinedAtom(f), _name(name), _scope(scope), _size(size),
- _align(align) {}
+ : SimpleDefinedAtom(f), _name(std::string(name)), _scope(scope),
+ _size(size), _align(align) {}
~MachOTentativeDefAtom() override = default;
diff --git a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
index 94a105a6f159..f3636feb217b 100644
--- a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
+++ b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
@@ -576,5 +576,5 @@ void addCompactUnwindPass(PassManager &pm, const MachOLinkingContext &ctx) {
pm.add(std::make_unique<CompactUnwindPass>(ctx));
}
-} // end namesapce mach_o
-} // end namesapce lld
+} // end namespace mach_o
+} // end namespace lld
diff --git a/lld/lib/ReaderWriter/MachO/File.h b/lld/lib/ReaderWriter/MachO/File.h
index 072702973f81..8d59656beab5 100644
--- a/lld/lib/ReaderWriter/MachO/File.h
+++ b/lld/lib/ReaderWriter/MachO/File.h
@@ -17,6 +17,8 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Format.h"
+#include "llvm/TextAPI/MachO/InterfaceFile.h"
+#include "llvm/TextAPI/MachO/TextAPIReader.h"
#include <unordered_map>
namespace lld {
@@ -322,7 +324,8 @@ public:
void loadReExportedDylibs(FindDylib find) {
for (ReExportedDylib &entry : _reExportedDylibs) {
- entry.file = find(entry.path);
+ if (!entry.file)
+ entry.file = find(entry.path);
}
}
@@ -339,7 +342,7 @@ public:
return std::error_code();
}
-private:
+protected:
OwningAtomPtr<SharedLibraryAtom> exports(StringRef name,
StringRef installName) const {
// First, check if requested symbol is directly implemented by this dylib.
@@ -373,6 +376,7 @@ private:
struct ReExportedDylib {
ReExportedDylib(StringRef p) : path(p), file(nullptr) { }
+ ReExportedDylib(StringRef p, MachODylibFile *file) : path(p), file(file) { }
StringRef path;
MachODylibFile *file;
};
@@ -393,6 +397,70 @@ private:
mutable std::unordered_map<StringRef, AtomAndFlags> _nameToAtom;
};
+class TAPIFile : public MachODylibFile {
+public:
+
+ TAPIFile(std::unique_ptr<MemoryBuffer> mb, MachOLinkingContext *ctx)
+ : MachODylibFile(std::move(mb), ctx) {}
+
+ std::error_code doParse() override {
+
+ llvm::Expected<std::unique_ptr<llvm::MachO::InterfaceFile>> result =
+ llvm::MachO::TextAPIReader::get(*_mb);
+ if (!result)
+ return std::make_error_code(std::errc::invalid_argument);
+
+ std::unique_ptr<llvm::MachO::InterfaceFile> interface{std::move(*result)};
+ return loadFromInterface(*interface);
+ }
+
+private:
+ std::error_code loadFromInterface(llvm::MachO::InterfaceFile &interface) {
+ llvm::MachO::Architecture arch;
+ switch(_ctx->arch()) {
+ case MachOLinkingContext::arch_x86:
+ arch = llvm::MachO::AK_i386;
+ break;
+ case MachOLinkingContext::arch_x86_64:
+ arch = llvm::MachO::AK_x86_64;
+ break;
+ case MachOLinkingContext::arch_arm64:
+ arch = llvm::MachO::AK_arm64;
+ break;
+ default:
+ return std::make_error_code(std::errc::invalid_argument);
+ }
+
+ setInstallName(interface.getInstallName().copy(allocator()));
+ // TODO(compnerd) filter out symbols based on the target platform
+ for (const auto symbol : interface.symbols())
+ if (symbol->getArchitectures().has(arch))
+ addExportedSymbol(symbol->getName(), symbol->isWeakDefined(), true);
+
+ for (const llvm::MachO::InterfaceFileRef &reexport :
+ interface.reexportedLibraries())
+ addReExportedDylib(reexport.getInstallName().copy(allocator()));
+
+ for (const auto& document : interface.documents()) {
+ for (auto& reexport : _reExportedDylibs) {
+ if (reexport.path != document->getInstallName())
+ continue;
+ assert(!reexport.file);
+ _ownedFiles.push_back(std::make_unique<TAPIFile>(
+ MemoryBuffer::getMemBuffer("", _mb->getBufferIdentifier()), _ctx));
+ reexport.file = _ownedFiles.back().get();
+ std::error_code err = _ownedFiles.back()->loadFromInterface(*document);
+ if (err)
+ return err;
+ }
+ }
+
+ return std::error_code();
+ }
+
+ std::vector<std::unique_ptr<TAPIFile>> _ownedFiles;
+};
+
} // end namespace mach_o
} // end namespace lld
diff --git a/lld/lib/ReaderWriter/MachO/GOTPass.cpp b/lld/lib/ReaderWriter/MachO/GOTPass.cpp
index 0f80dfa19d09..10e611c1bd2b 100644
--- a/lld/lib/ReaderWriter/MachO/GOTPass.cpp
+++ b/lld/lib/ReaderWriter/MachO/GOTPass.cpp
@@ -179,5 +179,5 @@ void addGOTPass(PassManager &pm, const MachOLinkingContext &ctx) {
pm.add(std::make_unique<GOTPass>(ctx));
}
-} // end namesapce mach_o
-} // end namesapce lld
+} // end namespace mach_o
+} // end namespace lld
diff --git a/lld/lib/ReaderWriter/MachO/LayoutPass.cpp b/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
index 775d3b0bad3a..e92fdf1b4913 100644
--- a/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
+++ b/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
@@ -461,10 +461,11 @@ llvm::Error LayoutPass::perform(SimpleFile &mergedFile) {
});
std::vector<LayoutPass::SortKey> vec = decorate(atomRange);
- sort(llvm::parallel::par, vec.begin(), vec.end(),
- [&](const LayoutPass::SortKey &l, const LayoutPass::SortKey &r) -> bool {
- return compareAtoms(l, r, _customSorter);
- });
+ llvm::parallelSort(
+ vec,
+ [&](const LayoutPass::SortKey &l, const LayoutPass::SortKey &r) -> bool {
+ return compareAtoms(l, r, _customSorter);
+ });
LLVM_DEBUG(checkTransitivity(vec, _customSorter));
undecorate(atomRange, vec);
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index 0be1c10a7ab0..acd919e4d411 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -540,6 +540,12 @@ MachOLinkingContext::searchDirForLibrary(StringRef path,
return llvm::None;
}
+ // Search for stub library
+ fullPath.assign(path);
+ llvm::sys::path::append(fullPath, Twine("lib") + libName + ".tbd");
+ if (fileExists(fullPath))
+ return fullPath.str().copy(_allocator);
+
// Search for dynamic library
fullPath.assign(path);
llvm::sys::path::append(fullPath, Twine("lib") + libName + ".dylib");
@@ -604,7 +610,7 @@ bool MachOLinkingContext::validateImpl() {
}
// If -exported_symbols_list used, all exported symbols must be defined.
- if (_exportMode == ExportMode::whiteList) {
+ if (_exportMode == ExportMode::exported) {
for (const auto &symbol : _exportedSymbols)
addInitialUndefinedSymbol(symbol.getKey());
}
@@ -618,7 +624,7 @@ bool MachOLinkingContext::validateImpl() {
if (needsStubsPass())
addDeadStripRoot(binderSymbolName());
// If using -exported_symbols_list, make all exported symbols live.
- if (_exportMode == ExportMode::whiteList) {
+ if (_exportMode == ExportMode::exported) {
setGlobalsAreDeadStripRoots(false);
for (const auto &symbol : _exportedSymbols)
addDeadStripRoot(symbol.getKey());
@@ -852,9 +858,9 @@ bool MachOLinkingContext::exportSymbolNamed(StringRef sym) const {
case ExportMode::globals:
llvm_unreachable("exportSymbolNamed() should not be called in this mode");
break;
- case ExportMode::whiteList:
+ case ExportMode::exported:
return _exportedSymbols.count(sym);
- case ExportMode::blackList:
+ case ExportMode::unexported:
return !_exportedSymbols.count(sym);
}
llvm_unreachable("_exportMode unknown enum value");
@@ -863,11 +869,11 @@ bool MachOLinkingContext::exportSymbolNamed(StringRef sym) const {
std::string MachOLinkingContext::demangle(StringRef symbolName) const {
// Only try to demangle symbols if -demangle on command line
if (!demangleSymbols())
- return symbolName;
+ return std::string(symbolName);
// Only try to demangle symbols that look like C++ symbols
if (!symbolName.startswith("__Z"))
- return symbolName;
+ return std::string(symbolName);
SmallString<256> symBuff;
StringRef nullTermSym = Twine(symbolName).toNullTerminatedStringRef(symBuff);
@@ -882,7 +888,7 @@ std::string MachOLinkingContext::demangle(StringRef symbolName) const {
return result;
}
- return symbolName;
+ return std::string(symbolName);
}
static void addDependencyInfoHelper(llvm::raw_fd_ostream *DepInfo,
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
index 963f1227fa44..87601ca1be8b 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
@@ -576,6 +576,26 @@ private:
MachOLinkingContext &_ctx;
};
+class MachOTAPIReader : public Reader {
+public:
+ MachOTAPIReader(MachOLinkingContext &ctx) : _ctx(ctx) {}
+
+ bool canParse(file_magic magic, MemoryBufferRef mb) const override {
+ return magic == file_magic::tapi_file;
+ }
+
+ ErrorOr<std::unique_ptr<File>>
+ loadFile(std::unique_ptr<MemoryBuffer> mb,
+ const Registry &registry) const override {
+ std::unique_ptr<File> ret =
+ std::make_unique<TAPIFile>(std::move(mb), &_ctx);
+ return std::move(ret);
+ }
+
+private:
+ MachOLinkingContext &_ctx;
+};
+
} // namespace normalized
} // namespace mach_o
@@ -583,6 +603,7 @@ void Registry::addSupportMachOObjects(MachOLinkingContext &ctx) {
MachOLinkingContext::Arch arch = ctx.arch();
add(std::unique_ptr<Reader>(new mach_o::normalized::MachOObjectReader(ctx)));
add(std::unique_ptr<Reader>(new mach_o::normalized::MachODylibReader(ctx)));
+ add(std::unique_ptr<Reader>(new mach_o::normalized::MachOTAPIReader(ctx)));
addKindTable(Reference::KindNamespace::mach_o, ctx.archHandler().kindArch(),
ctx.archHandler().kindStrings());
add(std::unique_ptr<YamlIOTaggedDocumentHandler>(
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index db11f73748d8..42ac711bc9dc 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -990,7 +990,7 @@ llvm::Error Util::getSymbolTableRegion(const DefinedAtom* atom,
inGlobalsRegion = false;
return llvm::Error::success();
case Atom::scopeLinkageUnit:
- if ((_ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) &&
+ if ((_ctx.exportMode() == MachOLinkingContext::ExportMode::exported) &&
_ctx.exportSymbolNamed(atom->name())) {
return llvm::make_error<GenericError>(
Twine("cannot export hidden symbol ") + atom->name());
@@ -1037,7 +1037,7 @@ llvm::Error Util::addSymbols(const lld::File &atomFile,
// Add all stabs.
for (auto &stab : _stabs) {
- Symbol sym;
+ lld::mach_o::normalized::Symbol sym;
sym.type = static_cast<NListType>(stab.type);
sym.scope = 0;
sym.sect = stab.other;
@@ -1066,7 +1066,7 @@ llvm::Error Util::addSymbols(const lld::File &atomFile,
AtomAndIndex ai = { atom, sect->finalSectionIndex, symbolScope };
globals.push_back(ai);
} else {
- Symbol sym;
+ lld::mach_o::normalized::Symbol sym;
sym.name = atom->name();
sym.type = N_SECT;
sym.scope = symbolScope;
@@ -1082,7 +1082,7 @@ llvm::Error Util::addSymbols(const lld::File &atomFile,
char tmpName[16];
sprintf(tmpName, "L%04u", tempNum++);
StringRef tempRef(tmpName);
- Symbol sym;
+ lld::mach_o::normalized::Symbol sym;
sym.name = tempRef.copy(file.ownedAllocations);
sym.type = N_SECT;
sym.scope = 0;
@@ -1099,7 +1099,7 @@ llvm::Error Util::addSymbols(const lld::File &atomFile,
std::sort(globals.begin(), globals.end(), AtomSorter());
const uint32_t globalStartIndex = file.localSymbols.size();
for (AtomAndIndex &ai : globals) {
- Symbol sym;
+ lld::mach_o::normalized::Symbol sym;
sym.name = ai.atom->name();
sym.type = N_SECT;
sym.scope = ai.scope;
@@ -1124,7 +1124,7 @@ llvm::Error Util::addSymbols(const lld::File &atomFile,
std::sort(undefs.begin(), undefs.end(), AtomSorter());
const uint32_t start = file.globalSymbols.size() + file.localSymbols.size();
for (AtomAndIndex &ai : undefs) {
- Symbol sym;
+ lld::mach_o::normalized::Symbol sym;
uint16_t desc = 0;
if (!rMode) {
uint8_t ordinal = 0;
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index 3347bb13508e..0a59e24c47a8 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -223,10 +223,11 @@ Atom::Scope atomScope(uint8_t scope) {
llvm_unreachable("unknown scope value!");
}
-void appendSymbolsInSection(const std::vector<Symbol> &inSymbols,
- uint32_t sectionIndex,
- SmallVector<const Symbol *, 64> &outSyms) {
- for (const Symbol &sym : inSymbols) {
+void appendSymbolsInSection(
+ const std::vector<lld::mach_o::normalized::Symbol> &inSymbols,
+ uint32_t sectionIndex,
+ SmallVector<const lld::mach_o::normalized::Symbol *, 64> &outSyms) {
+ for (const lld::mach_o::normalized::Symbol &sym : inSymbols) {
// Only look at definition symbols.
if ((sym.type & N_TYPE) != N_SECT)
continue;
@@ -286,13 +287,14 @@ llvm::Error processSymboledSection(DefinedAtom::ContentType atomType,
}
// Find all symbols in this section.
- SmallVector<const Symbol *, 64> symbols;
+ SmallVector<const lld::mach_o::normalized::Symbol *, 64> symbols;
appendSymbolsInSection(normalizedFile.globalSymbols, sectIndex, symbols);
appendSymbolsInSection(normalizedFile.localSymbols, sectIndex, symbols);
// Sort symbols.
std::sort(symbols.begin(), symbols.end(),
- [](const Symbol *lhs, const Symbol *rhs) -> bool {
+ [](const lld::mach_o::normalized::Symbol *lhs,
+ const lld::mach_o::normalized::Symbol *rhs) -> bool {
if (lhs == rhs)
return false;
// First by address.
@@ -300,7 +302,7 @@ llvm::Error processSymboledSection(DefinedAtom::ContentType atomType,
uint64_t rhsAddr = rhs->value;
if (lhsAddr != rhsAddr)
return lhsAddr < rhsAddr;
- // If same address, one is an alias so sort by scope.
+ // If same address, one is an alias so sort by scope.
Atom::Scope lScope = atomScope(lhs->scope);
Atom::Scope rScope = atomScope(rhs->scope);
if (lScope != rScope)
@@ -339,8 +341,8 @@ llvm::Error processSymboledSection(DefinedAtom::ContentType atomType,
scatterable, copyRefs);
}
- const Symbol *lastSym = nullptr;
- for (const Symbol *sym : symbols) {
+ const lld::mach_o::normalized::Symbol *lastSym = nullptr;
+ for (const lld::mach_o::normalized::Symbol *sym : symbols) {
if (lastSym != nullptr) {
// Ignore any assembler added "ltmpNNN" symbol at start of section
// if there is another symbol at the start.
@@ -550,7 +552,7 @@ llvm::Error convertRelocs(const Section &section,
auto atomBySymbol = [&] (uint32_t symbolIndex, const lld::Atom **result)
-> llvm::Error {
// Find symbol from index.
- const Symbol *sym = nullptr;
+ const lld::mach_o::normalized::Symbol *sym = nullptr;
uint32_t numStabs = normalizedFile.stabsSymbols.size();
uint32_t numLocal = normalizedFile.localSymbols.size();
uint32_t numGlobal = normalizedFile.globalSymbols.size();
@@ -1401,7 +1403,7 @@ llvm::Error parseObjCImageInfo(const Section &sect,
llvm::Expected<std::unique_ptr<lld::File>>
objectToAtoms(const NormalizedFile &normalizedFile, StringRef path,
bool copyRefs) {
- std::unique_ptr<MachOFile> file(new MachOFile(path));
+ auto file = std::make_unique<MachOFile>(path);
if (auto ec = normalizedObjectToAtoms(file.get(), normalizedFile, copyRefs))
return std::move(ec);
return std::unique_ptr<File>(std::move(file));
@@ -1411,7 +1413,7 @@ llvm::Expected<std::unique_ptr<lld::File>>
dylibToAtoms(const NormalizedFile &normalizedFile, StringRef path,
bool copyRefs) {
// Instantiate SharedLibraryFile object.
- std::unique_ptr<MachODylibFile> file(new MachODylibFile(path));
+ auto file = std::make_unique<MachODylibFile>(path);
if (auto ec = normalizedDylibToAtoms(file.get(), normalizedFile, copyRefs))
return std::move(ec);
return std::unique_ptr<File>(std::move(file));
diff --git a/lld/lib/ReaderWriter/MachO/TLVPass.cpp b/lld/lib/ReaderWriter/MachO/TLVPass.cpp
index 5f457b863d90..e0a031cfb07b 100644
--- a/lld/lib/ReaderWriter/MachO/TLVPass.cpp
+++ b/lld/lib/ReaderWriter/MachO/TLVPass.cpp
@@ -136,5 +136,5 @@ void addTLVPass(PassManager &pm, const MachOLinkingContext &ctx) {
pm.add(std::make_unique<TLVPass>(ctx));
}
-} // end namesapce mach_o
-} // end namesapce lld
+} // end namespace mach_o
+} // end namespace lld
diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
index 23c20aa2ba1c..279ffe5e2505 100644
--- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
+++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
@@ -89,7 +89,7 @@ public:
llvm::raw_string_ostream buffer(storage);
buffer << llvm::format("L%03d", _unnamedCounter++);
StringRef newName = copyString(buffer.str());
- _refNames[target] = newName;
+ _refNames[target] = std::string(newName);
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "unnamed atom: creating ref-name: '"
<< newName << "' ("
@@ -119,7 +119,7 @@ public:
llvm::raw_string_ostream buffer(Storage);
buffer << atom.name() << llvm::format(".%03d", ++_collisionCount);
StringRef newName = copyString(buffer.str());
- _refNames[&atom] = newName;
+ _refNames[&atom] = std::string(newName);
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "name collision: creating ref-name: '"
<< newName << "' ("
@@ -133,7 +133,7 @@ public:
llvm::raw_string_ostream buffer2(Storage2);
buffer2 << prevAtom->name() << llvm::format(".%03d", ++_collisionCount);
StringRef newName2 = copyString(buffer2.str());
- _refNames[prevAtom] = newName2;
+ _refNames[prevAtom] = std::string(newName2);
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "name collision: creating ref-name: '"
<< newName2 << "' ("