summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter
diff options
context:
space:
mode:
Diffstat (limited to 'lld/lib/ReaderWriter')
-rw-r--r--lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp2
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp27
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp18
-rw-r--r--lld/lib/ReaderWriter/MachO/WriterMachO.cpp2
4 files changed, 24 insertions, 25 deletions
diff --git a/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp b/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
index e212f48ed79..94d4fadb500 100644
--- a/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
+++ b/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
@@ -33,7 +33,7 @@ public:
CRuntimeFile(const MachOLinkingContext &context)
: SimpleFile("C runtime"), _undefMain(*this, context.entrySymbolName()) {
// only main executables need _main
- if (context.outputFileType() == llvm::MachO::MH_EXECUTE) {
+ if (context.outputMachOType() == llvm::MachO::MH_EXECUTE) {
this->addAtom(_undefMain);
}
}
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index 8be2d767cfc..b1e2929c709 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -119,7 +119,7 @@ uint32_t MachOLinkingContext::cpuSubtypeFromArch(Arch arch) {
}
MachOLinkingContext::MachOLinkingContext()
- : _outputFileType(MH_EXECUTE), _outputFileTypeStatic(false),
+ : _outputMachOType(MH_EXECUTE), _outputMachOTypeStatic(false),
_doNothing(false), _arch(arch_unknown), _os(OS::macOSX), _osMinVersion(0),
_pageZeroSize(0), _pageSize(4096), _compatibilityVersion(0),
_currentVersion(0), _deadStrippableDylib(false), _printAtoms(false),
@@ -129,12 +129,12 @@ MachOLinkingContext::~MachOLinkingContext() {}
void MachOLinkingContext::configure(HeaderFileType type, Arch arch, OS os,
uint32_t minOSVersion) {
- _outputFileType = type;
+ _outputMachOType = type;
_arch = arch;
_os = os;
_osMinVersion = minOSVersion;
- switch (_outputFileType) {
+ switch (_outputMachOType) {
case llvm::MachO::MH_EXECUTE:
// If targeting newer OS, use _main
if (minOS("10.8", "6.0")) {
@@ -211,7 +211,7 @@ bool MachOLinkingContext::is64Bit() const {
}
bool MachOLinkingContext::outputTypeHasEntry() const {
- switch (_outputFileType) {
+ switch (_outputMachOType) {
case MH_EXECUTE:
case MH_DYLINKER:
case MH_PRELOAD:
@@ -240,16 +240,16 @@ bool MachOLinkingContext::minOS(StringRef mac, StringRef iOS) const {
}
bool MachOLinkingContext::addEntryPointLoadCommand() const {
- if ((_outputFileType == MH_EXECUTE) && !_outputFileTypeStatic) {
+ if ((_outputMachOType == MH_EXECUTE) && !_outputMachOTypeStatic) {
return minOS("10.8", "6.0");
}
return false;
}
bool MachOLinkingContext::addUnixThreadLoadCommand() const {
- switch (_outputFileType) {
+ switch (_outputMachOType) {
case MH_EXECUTE:
- if (_outputFileTypeStatic)
+ if (_outputMachOTypeStatic)
return true;
else
return !minOS("10.8", "6.0");
@@ -265,24 +265,24 @@ bool MachOLinkingContext::addUnixThreadLoadCommand() const {
bool MachOLinkingContext::validateImpl(raw_ostream &diagnostics) {
// TODO: if -arch not specified, look at arch of first .o file.
- if (_currentVersion && _outputFileType != MH_DYLIB) {
+ if (_currentVersion && _outputMachOType != MH_DYLIB) {
diagnostics << "error: -current_version can only be used with dylibs\n";
return false;
}
- if (_compatibilityVersion && _outputFileType != MH_DYLIB) {
+ if (_compatibilityVersion && _outputMachOType != MH_DYLIB) {
diagnostics
<< "error: -compatibility_version can only be used with dylibs\n";
return false;
}
- if (_deadStrippableDylib && _outputFileType != MH_DYLIB) {
+ if (_deadStrippableDylib && _outputMachOType != MH_DYLIB) {
diagnostics
<< "error: -mark_dead_strippable_dylib can only be used with dylibs.\n";
return false;
}
- if (!_bundleLoader.empty() && outputFileType() != MH_BUNDLE) {
+ if (!_bundleLoader.empty() && outputMachOType() != MH_BUNDLE) {
diagnostics
<< "error: -bundle_loader can only be used with Mach-O bundles\n";
return false;
@@ -292,7 +292,7 @@ bool MachOLinkingContext::validateImpl(raw_ostream &diagnostics) {
}
void MachOLinkingContext::addPasses(PassManager &pm) {
- if (outputFileType() != MH_OBJECT) {
+ if (outputMachOType() != MH_OBJECT) {
pm.add(std::unique_ptr<Pass>(new mach_o::GOTPass));
pm.add(std::unique_ptr<Pass>(new mach_o::StubsPass(*this)));
}
@@ -300,9 +300,8 @@ void MachOLinkingContext::addPasses(PassManager &pm) {
}
Writer &MachOLinkingContext::writer() const {
- if (!_writer) {
+ if (!_writer)
_writer = createWriterMachO(*this);
- }
return *_writer;
}
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index e441b9b3db5..726092ccf2d 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -263,7 +263,7 @@ SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) {
auto pos = _sectionMap.find(type);
if ( pos != _sectionMap.end() )
return pos->second;
- bool rMode = (_context.outputFileType() == llvm::MachO::MH_OBJECT);
+ bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT);
return rMode ? getRelocatableSection(type) : getFinalSection(type);
} else {
// This atom needs to be in a custom section.
@@ -365,7 +365,7 @@ bool Util::TextSectionSorter::operator()(const SectionInfo *left,
void Util::organizeSections() {
- if (_context.outputFileType() == llvm::MachO::MH_OBJECT) {
+ if (_context.outputMachOType() == llvm::MachO::MH_OBJECT) {
// Leave sections ordered as normalized file specified.
uint32_t sectionIndex = 1;
for (SectionInfo *si : _sectionInfos) {
@@ -373,7 +373,7 @@ void Util::organizeSections() {
}
} else {
// Main executables, need a zero-page segment
- if (_context.outputFileType() == llvm::MachO::MH_EXECUTE)
+ if (_context.outputMachOType() == llvm::MachO::MH_EXECUTE)
segmentForName("__PAGEZERO");
// Group sections into segments.
for (SectionInfo *si : _sectionInfos) {
@@ -442,7 +442,7 @@ void Util::layoutSectionsInTextSegment(SegmentInfo *seg, uint64_t &addr) {
void Util::assignAddressesToSections() {
uint64_t address = 0; // FIXME
- if (_context.outputFileType() != llvm::MachO::MH_OBJECT) {
+ if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) {
for (SegmentInfo *seg : _segmentInfos) {
if (seg->name.equals("__PAGEZERO")) {
seg->size = _context.pageZeroSize();
@@ -538,7 +538,7 @@ void Util::appendSection(SectionInfo *si, NormalizedFile &file) {
void Util::copySections(NormalizedFile &file) {
file.sections.reserve(_sectionInfos.size());
// For final linked images, write sections grouped by segment.
- if (_context.outputFileType() != llvm::MachO::MH_OBJECT) {
+ if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) {
for (SegmentInfo *sgi : _segmentInfos) {
for (SectionInfo *si : sgi->sections) {
appendSection(si, file);
@@ -622,7 +622,7 @@ bool Util::AtomSorter::operator()(const AtomAndIndex &left,
bool Util::belongsInGlobalSymbolsSection(const DefinedAtom* atom) {
// ScopeLinkageUnit symbols are in globals area of symbol table
// in object files, but in locals area for final linked images.
- if (_context.outputFileType() == llvm::MachO::MH_OBJECT)
+ if (_context.outputMachOType() == llvm::MachO::MH_OBJECT)
return (atom->scope() != Atom::scopeTranslationUnit);
else
return (atom->scope() == Atom::scopeGlobal);
@@ -826,7 +826,7 @@ void Util::appendReloc(const DefinedAtom *atom, const Reference *ref,
}
void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) {
- if (_context.outputFileType() != llvm::MachO::MH_OBJECT)
+ if (_context.outputMachOType() != llvm::MachO::MH_OBJECT)
return;
for (SectionInfo *si : _sectionInfos) {
@@ -842,7 +842,7 @@ void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) {
void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
NormalizedFile &nFile) {
- if (_context.outputFileType() == llvm::MachO::MH_OBJECT)
+ if (_context.outputMachOType() == llvm::MachO::MH_OBJECT)
return;
uint8_t segmentIndex;
@@ -918,7 +918,7 @@ normalizedFromAtoms(const lld::File &atomFile,
std::unique_ptr<NormalizedFile> f(new NormalizedFile());
NormalizedFile &normFile = *f.get();
f->arch = context.arch();
- f->fileType = context.outputFileType();
+ f->fileType = context.outputMachOType();
f->flags = util.fileFlags();
util.copySegmentInfo(normFile);
util.copySections(normFile);
diff --git a/lld/lib/ReaderWriter/MachO/WriterMachO.cpp b/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
index 90eff174c4d..f76bfffbca9 100644
--- a/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
+++ b/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
@@ -46,7 +46,7 @@ public:
}
bool createImplicitFiles(std::vector<std::unique_ptr<File> > &r) override {
- if (_context.outputFileType() == llvm::MachO::MH_EXECUTE) {
+ if (_context.outputMachOType() == llvm::MachO::MH_EXECUTE) {
// When building main executables, add _main as required entry point.
r.emplace_back(new CRuntimeFile(_context));
}
OpenPOWER on IntegriCloud