aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ReaderWriter
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ReaderWriter')
-rw-r--r--lib/ReaderWriter/FileArchive.cpp2
-rw-r--r--lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp50
-rw-r--r--lib/ReaderWriter/MachO/CompactUnwindPass.cpp2
-rw-r--r--lib/ReaderWriter/MachO/DebugInfo.h1
-rw-r--r--lib/ReaderWriter/MachO/GOTPass.cpp2
-rw-r--r--lib/ReaderWriter/MachO/LayoutPass.cpp2
-rw-r--r--lib/ReaderWriter/MachO/MachOLinkingContext.cpp10
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp4
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp14
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp20
-rw-r--r--lib/ReaderWriter/MachO/ObjCPass.cpp2
-rw-r--r--lib/ReaderWriter/MachO/ShimPass.cpp2
-rw-r--r--lib/ReaderWriter/MachO/TLVPass.cpp2
-rw-r--r--lib/ReaderWriter/YAML/ReaderWriterYAML.cpp2
14 files changed, 76 insertions, 39 deletions
diff --git a/lib/ReaderWriter/FileArchive.cpp b/lib/ReaderWriter/FileArchive.cpp
index b09bf34dc47c..98f4d06ee210 100644
--- a/lib/ReaderWriter/FileArchive.cpp
+++ b/lib/ReaderWriter/FileArchive.cpp
@@ -210,7 +210,7 @@ public:
const Registry &reg) const override {
StringRef path = mb->getBufferIdentifier();
std::unique_ptr<File> ret =
- llvm::make_unique<FileArchive>(std::move(mb), reg, path, _logLoading);
+ std::make_unique<FileArchive>(std::move(mb), reg, path, _logLoading);
return std::move(ret);
}
diff --git a/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp b/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
index 316b5bbc6f4f..687407049d4b 100644
--- a/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
+++ b/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
@@ -181,6 +181,20 @@ public:
FindAddressForAtom addressForAtom,
normalized::Relocations &relocs) override;
+ bool isDataInCodeTransition(Reference::KindValue refKind) override {
+ return refKind == modeCode || refKind == modeData;
+ }
+
+ Reference::KindValue dataInCodeTransitionStart(
+ const MachODefinedAtom &atom) override {
+ return modeData;
+ }
+
+ Reference::KindValue dataInCodeTransitionEnd(
+ const MachODefinedAtom &atom) override {
+ return modeCode;
+ }
+
private:
static const Registry::KindStrings _sKindStrings[];
static const StubInfo _sStubInfo;
@@ -188,6 +202,9 @@ private:
enum X86_64Kind: Reference::KindValue {
invalid, /// for error condition
+ modeCode, /// Content starting at this offset is code.
+ modeData, /// Content starting at this offset is data.
+
// Kinds found in mach-o .o files:
branch32, /// ex: call _foo
ripRel32, /// ex: movq _foo(%rip), %rax
@@ -242,24 +259,34 @@ private:
};
const Registry::KindStrings ArchHandler_x86_64::_sKindStrings[] = {
- LLD_KIND_STRING_ENTRY(invalid), LLD_KIND_STRING_ENTRY(branch32),
- LLD_KIND_STRING_ENTRY(ripRel32), LLD_KIND_STRING_ENTRY(ripRel32Minus1),
- LLD_KIND_STRING_ENTRY(ripRel32Minus2), LLD_KIND_STRING_ENTRY(ripRel32Minus4),
+ LLD_KIND_STRING_ENTRY(invalid),
+ LLD_KIND_STRING_ENTRY(modeCode),
+ LLD_KIND_STRING_ENTRY(modeData),
+ LLD_KIND_STRING_ENTRY(branch32),
+ LLD_KIND_STRING_ENTRY(ripRel32),
+ LLD_KIND_STRING_ENTRY(ripRel32Minus1),
+ LLD_KIND_STRING_ENTRY(ripRel32Minus2),
+ LLD_KIND_STRING_ENTRY(ripRel32Minus4),
LLD_KIND_STRING_ENTRY(ripRel32Anon),
LLD_KIND_STRING_ENTRY(ripRel32Minus1Anon),
LLD_KIND_STRING_ENTRY(ripRel32Minus2Anon),
LLD_KIND_STRING_ENTRY(ripRel32Minus4Anon),
LLD_KIND_STRING_ENTRY(ripRel32GotLoad),
LLD_KIND_STRING_ENTRY(ripRel32GotLoadNowLea),
- LLD_KIND_STRING_ENTRY(ripRel32Got), LLD_KIND_STRING_ENTRY(ripRel32Tlv),
+ LLD_KIND_STRING_ENTRY(ripRel32Got),
+ LLD_KIND_STRING_ENTRY(ripRel32Tlv),
LLD_KIND_STRING_ENTRY(lazyPointer),
LLD_KIND_STRING_ENTRY(lazyImmediateLocation),
- LLD_KIND_STRING_ENTRY(pointer64), LLD_KIND_STRING_ENTRY(pointer64Anon),
- LLD_KIND_STRING_ENTRY(delta32), LLD_KIND_STRING_ENTRY(delta64),
- LLD_KIND_STRING_ENTRY(delta32Anon), LLD_KIND_STRING_ENTRY(delta64Anon),
+ LLD_KIND_STRING_ENTRY(pointer64),
+ LLD_KIND_STRING_ENTRY(pointer64Anon),
+ LLD_KIND_STRING_ENTRY(delta32),
+ LLD_KIND_STRING_ENTRY(delta64),
+ LLD_KIND_STRING_ENTRY(delta32Anon),
+ LLD_KIND_STRING_ENTRY(delta64Anon),
LLD_KIND_STRING_ENTRY(negDelta64),
LLD_KIND_STRING_ENTRY(negDelta32),
- LLD_KIND_STRING_ENTRY(imageOffset), LLD_KIND_STRING_ENTRY(imageOffsetGot),
+ LLD_KIND_STRING_ENTRY(imageOffset),
+ LLD_KIND_STRING_ENTRY(imageOffsetGot),
LLD_KIND_STRING_ENTRY(unwindFDEToFunction),
LLD_KIND_STRING_ENTRY(unwindInfoToEhFrame),
LLD_KIND_STRING_ENTRY(tlvInitSectionOffset),
@@ -601,6 +628,8 @@ void ArchHandler_x86_64::applyFixupFinal(
case negDelta32:
*loc32 = fixupAddress - targetAddress + ref.addend();
return;
+ case modeCode:
+ case modeData:
case lazyPointer:
// Do nothing
return;
@@ -720,6 +749,8 @@ void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,
case unwindInfoToEhFrame:
llvm_unreachable("fixup implies __unwind_info");
return;
+ case modeCode:
+ case modeData:
case unwindFDEToFunction:
// Do nothing for now
return;
@@ -743,6 +774,9 @@ void ArchHandler_x86_64::appendSectionRelocations(
assert(ref.kindArch() == Reference::KindArch::x86_64);
uint32_t sectionOffset = atomSectionOffset + ref.offsetInAtom();
switch (static_cast<X86_64Kind>(ref.kindValue())) {
+ case modeCode:
+ case modeData:
+ return;
case branch32:
appendReloc(relocs, sectionOffset, symbolIndexForAtom(*ref.target()), 0,
X86_64_RELOC_BRANCH | rPcRel | rExtern | rLength4);
diff --git a/lib/ReaderWriter/MachO/CompactUnwindPass.cpp b/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
index de5adb088799..44e6a29a0b60 100644
--- a/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
+++ b/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
@@ -573,7 +573,7 @@ private:
void addCompactUnwindPass(PassManager &pm, const MachOLinkingContext &ctx) {
assert(ctx.needsCompactUnwindPass());
- pm.add(llvm::make_unique<CompactUnwindPass>(ctx));
+ pm.add(std::make_unique<CompactUnwindPass>(ctx));
}
} // end namesapce mach_o
diff --git a/lib/ReaderWriter/MachO/DebugInfo.h b/lib/ReaderWriter/MachO/DebugInfo.h
index 959e10f9a073..591dd1ebad86 100644
--- a/lib/ReaderWriter/MachO/DebugInfo.h
+++ b/lib/ReaderWriter/MachO/DebugInfo.h
@@ -12,6 +12,7 @@
#include "lld/Core/Atom.h"
#include <vector>
+#include "llvm/Support/Allocator.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/lib/ReaderWriter/MachO/GOTPass.cpp b/lib/ReaderWriter/MachO/GOTPass.cpp
index bc66d49eafb9..514dd4e09da8 100644
--- a/lib/ReaderWriter/MachO/GOTPass.cpp
+++ b/lib/ReaderWriter/MachO/GOTPass.cpp
@@ -176,7 +176,7 @@ private:
void addGOTPass(PassManager &pm, const MachOLinkingContext &ctx) {
assert(ctx.needsGOTPass());
- pm.add(llvm::make_unique<GOTPass>(ctx));
+ pm.add(std::make_unique<GOTPass>(ctx));
}
} // end namesapce mach_o
diff --git a/lib/ReaderWriter/MachO/LayoutPass.cpp b/lib/ReaderWriter/MachO/LayoutPass.cpp
index 2718dfcf743f..8db6ffb958a4 100644
--- a/lib/ReaderWriter/MachO/LayoutPass.cpp
+++ b/lib/ReaderWriter/MachO/LayoutPass.cpp
@@ -478,7 +478,7 @@ llvm::Error LayoutPass::perform(SimpleFile &mergedFile) {
}
void addLayoutPass(PassManager &pm, const MachOLinkingContext &ctx) {
- pm.add(llvm::make_unique<LayoutPass>(
+ pm.add(std::make_unique<LayoutPass>(
ctx.registry(), [&](const DefinedAtom * left, const DefinedAtom * right,
bool & leftBeforeRight) ->bool {
return ctx.customAtomOrderer(left, right, leftBeforeRight);
diff --git a/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index 38456024c9f8..221d895a40d0 100644
--- a/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -802,9 +802,9 @@ void MachOLinkingContext::addSectCreateSection(
std::unique_ptr<MemoryBuffer> content) {
if (!_sectCreateFile) {
- auto sectCreateFile = llvm::make_unique<mach_o::SectCreateFile>();
+ auto sectCreateFile = std::make_unique<mach_o::SectCreateFile>();
_sectCreateFile = sectCreateFile.get();
- getNodes().push_back(llvm::make_unique<FileNode>(std::move(sectCreateFile)));
+ getNodes().push_back(std::make_unique<FileNode>(std::move(sectCreateFile)));
}
assert(_sectCreateFile && "sectcreate file does not exist.");
@@ -897,8 +897,8 @@ static void addDependencyInfoHelper(llvm::raw_fd_ostream *DepInfo,
std::error_code MachOLinkingContext::createDependencyFile(StringRef path) {
std::error_code ec;
- _dependencyInfo = std::unique_ptr<llvm::raw_fd_ostream>(new
- llvm::raw_fd_ostream(path, ec, llvm::sys::fs::F_None));
+ _dependencyInfo = std::unique_ptr<llvm::raw_fd_ostream>(
+ new llvm::raw_fd_ostream(path, ec, llvm::sys::fs::OF_None));
if (ec) {
_dependencyInfo.reset();
return ec;
@@ -1019,7 +1019,7 @@ void MachOLinkingContext::finalizeInputFiles() {
return !isLibrary(a) && isLibrary(b);
});
size_t numLibs = std::count_if(elements.begin(), elements.end(), isLibrary);
- elements.push_back(llvm::make_unique<GroupEnd>(numLibs));
+ elements.push_back(std::make_unique<GroupEnd>(numLibs));
}
llvm::Error MachOLinkingContext::handleLoadedFile(File &file) {
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
index 38b365374f36..963f1227fa44 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
@@ -542,7 +542,7 @@ public:
loadFile(std::unique_ptr<MemoryBuffer> mb,
const Registry &registry) const override {
std::unique_ptr<File> ret =
- llvm::make_unique<MachOFile>(std::move(mb), &_ctx);
+ std::make_unique<MachOFile>(std::move(mb), &_ctx);
return std::move(ret);
}
@@ -568,7 +568,7 @@ public:
loadFile(std::unique_ptr<MemoryBuffer> mb,
const Registry &registry) const override {
std::unique_ptr<File> ret =
- llvm::make_unique<MachODylibFile>(std::move(mb), &_ctx);
+ std::make_unique<MachODylibFile>(std::move(mb), &_ctx);
return std::move(ret);
}
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index da27c7cadf96..ab7ea7e07f23 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -626,17 +626,19 @@ llvm::Error MachOFileLayout::writeSingleSegmentLoadCommand(uint8_t *&lc) {
+ _file.sections.size() * sizeof(typename T::section);
uint8_t *next = lc + seg->cmdsize;
memset(seg->segname, 0, 16);
+ seg->flags = 0;
seg->vmaddr = 0;
- seg->vmsize = _file.sections.back().address
- + _file.sections.back().content.size();
seg->fileoff = _endOfLoadCommands;
- seg->filesize = _sectInfo[&_file.sections.back()].fileOffset +
- _file.sections.back().content.size() -
- _sectInfo[&_file.sections.front()].fileOffset;
seg->maxprot = VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE;
seg->initprot = VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE;
seg->nsects = _file.sections.size();
- seg->flags = 0;
+ if (seg->nsects) {
+ seg->vmsize = _file.sections.back().address
+ + _file.sections.back().content.size();
+ seg->filesize = _sectInfo[&_file.sections.back()].fileOffset +
+ _file.sections.back().content.size() -
+ _sectInfo[&_file.sections.front()].fileOffset;
+ }
if (_swap)
swapStruct(*seg);
typename T::section *sout = reinterpret_cast<typename T::section*>
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index 879f07fb4760..f34857b99676 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -717,7 +717,7 @@ llvm::Error parseStabs(MachOFile &file,
// FIXME: Kill this off when we can move to sane yaml parsing.
std::unique_ptr<BumpPtrAllocator> allocator;
if (copyRefs)
- allocator = llvm::make_unique<BumpPtrAllocator>();
+ allocator = std::make_unique<BumpPtrAllocator>();
enum { start, inBeginEnd } state = start;
@@ -812,7 +812,7 @@ llvm::Error parseStabs(MachOFile &file,
stabsList.push_back(stab);
}
- file.setDebugInfo(llvm::make_unique<StabsDebugInfo>(std::move(stabsList)));
+ file.setDebugInfo(std::make_unique<StabsDebugInfo>(std::move(stabsList)));
// FIXME: Kill this off when we fix YAML memory ownership.
file.debugInfo()->setAllocator(std::move(allocator));
@@ -832,10 +832,10 @@ dataExtractorFromSection(const NormalizedFile &normalizedFile,
// FIXME: Cribbed from llvm-dwp -- should share "lightweight CU DIE
// inspection" code if possible.
-static uint32_t getCUAbbrevOffset(llvm::DataExtractor abbrevData,
+static uint64_t getCUAbbrevOffset(llvm::DataExtractor abbrevData,
uint64_t abbrCode) {
uint64_t curCode;
- uint32_t offset = 0;
+ uint64_t offset = 0;
while ((curCode = abbrevData.getULEB128(&offset)) != abbrCode) {
// Tag
abbrevData.getULEB128(&offset);
@@ -853,13 +853,13 @@ static uint32_t getCUAbbrevOffset(llvm::DataExtractor abbrevData,
static Expected<const char *>
getIndexedString(const NormalizedFile &normalizedFile,
llvm::dwarf::Form form, llvm::DataExtractor infoData,
- uint32_t &infoOffset, const Section &stringsSection) {
+ uint64_t &infoOffset, const Section &stringsSection) {
if (form == llvm::dwarf::DW_FORM_string)
return infoData.getCStr(&infoOffset);
if (form != llvm::dwarf::DW_FORM_strp)
return llvm::make_error<GenericError>(
"string field encoded without DW_FORM_strp");
- uint32_t stringOffset = infoData.getU32(&infoOffset);
+ uint64_t stringOffset = infoData.getU32(&infoOffset);
llvm::DataExtractor stringsData =
dataExtractorFromSection(normalizedFile, stringsSection);
return stringsData.getCStr(&stringOffset);
@@ -875,7 +875,7 @@ readCompUnit(const NormalizedFile &normalizedFile,
StringRef path) {
// FIXME: Cribbed from llvm-dwp -- should share "lightweight CU DIE
// inspection" code if possible.
- uint32_t offset = 0;
+ uint64_t offset = 0;
llvm::dwarf::DwarfFormat Format = llvm::dwarf::DwarfFormat::DWARF32;
auto infoData = dataExtractorFromSection(normalizedFile, info);
uint32_t length = infoData.getU32(&offset);
@@ -897,7 +897,7 @@ readCompUnit(const NormalizedFile &normalizedFile,
uint32_t abbrCode = infoData.getULEB128(&offset);
auto abbrevData = dataExtractorFromSection(normalizedFile, abbrev);
- uint32_t abbrevOffset = getCUAbbrevOffset(abbrevData, abbrCode);
+ uint64_t abbrevOffset = getCUAbbrevOffset(abbrevData, abbrCode);
uint64_t tag = abbrevData.getULEB128(&abbrevOffset);
if (tag != llvm::dwarf::DW_TAG_compile_unit)
return llvm::make_error<GenericError>("top level DIE is not a compile unit");
@@ -974,11 +974,11 @@ llvm::Error parseDebugInfo(MachOFile &file,
// memory ownership.
std::unique_ptr<BumpPtrAllocator> allocator;
if (copyRefs) {
- allocator = llvm::make_unique<BumpPtrAllocator>();
+ allocator = std::make_unique<BumpPtrAllocator>();
tuOrErr->name = copyDebugString(tuOrErr->name, *allocator);
tuOrErr->path = copyDebugString(tuOrErr->path, *allocator);
}
- file.setDebugInfo(llvm::make_unique<DwarfDebugInfo>(std::move(*tuOrErr)));
+ file.setDebugInfo(std::make_unique<DwarfDebugInfo>(std::move(*tuOrErr)));
if (copyRefs)
file.debugInfo()->setAllocator(std::move(allocator));
} else
diff --git a/lib/ReaderWriter/MachO/ObjCPass.cpp b/lib/ReaderWriter/MachO/ObjCPass.cpp
index df121f0e1d5d..02a95b5aa0c0 100644
--- a/lib/ReaderWriter/MachO/ObjCPass.cpp
+++ b/lib/ReaderWriter/MachO/ObjCPass.cpp
@@ -124,7 +124,7 @@ private:
void addObjCPass(PassManager &pm, const MachOLinkingContext &ctx) {
- pm.add(llvm::make_unique<ObjCPass>(ctx));
+ pm.add(std::make_unique<ObjCPass>(ctx));
}
} // end namespace mach_o
diff --git a/lib/ReaderWriter/MachO/ShimPass.cpp b/lib/ReaderWriter/MachO/ShimPass.cpp
index b0775ad5fc26..a5b34cfe8de6 100644
--- a/lib/ReaderWriter/MachO/ShimPass.cpp
+++ b/lib/ReaderWriter/MachO/ShimPass.cpp
@@ -121,7 +121,7 @@ private:
void addShimPass(PassManager &pm, const MachOLinkingContext &ctx) {
- pm.add(llvm::make_unique<ShimPass>(ctx));
+ pm.add(std::make_unique<ShimPass>(ctx));
}
} // end namespace mach_o
diff --git a/lib/ReaderWriter/MachO/TLVPass.cpp b/lib/ReaderWriter/MachO/TLVPass.cpp
index 89b655e1f888..5f457b863d90 100644
--- a/lib/ReaderWriter/MachO/TLVPass.cpp
+++ b/lib/ReaderWriter/MachO/TLVPass.cpp
@@ -133,7 +133,7 @@ private:
void addTLVPass(PassManager &pm, const MachOLinkingContext &ctx) {
assert(ctx.needsTLVPass());
- pm.add(llvm::make_unique<TLVPass>(ctx));
+ pm.add(std::make_unique<TLVPass>(ctx));
}
} // end namesapce mach_o
diff --git a/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
index 5feff2a0514a..77936399c1af 100644
--- a/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
+++ b/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
@@ -1299,7 +1299,7 @@ public:
llvm::Error writeFile(const lld::File &file, StringRef outPath) override {
// Create stream to path.
std::error_code ec;
- llvm::raw_fd_ostream out(outPath, ec, llvm::sys::fs::F_Text);
+ llvm::raw_fd_ostream out(outPath, ec, llvm::sys::fs::OF_Text);
if (ec)
return llvm::errorCodeToError(ec);