[lld] r234645 - Do s/_context/_ctx/g globally.
Rui Ueyama
ruiu at google.com
Fri Apr 10 14:41:00 PDT 2015
Author: ruiu
Date: Fri Apr 10 16:40:59 2015
New Revision: 234645
URL: http://llvm.org/viewvc/llvm-project?rev=234645&view=rev
Log:
Do s/_context/_ctx/g globally.
I believe this patch eliminates all remaining uses of _context
or _linkingContext variable names. Consistent naming improves
readability.
Modified:
lld/trunk/include/lld/Core/SymbolTable.h
lld/trunk/include/lld/ReaderWriter/YamlContext.h
lld/trunk/lib/Core/SymbolTable.cpp
lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp
lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
Modified: lld/trunk/include/lld/Core/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/SymbolTable.h?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/SymbolTable.h (original)
+++ lld/trunk/include/lld/Core/SymbolTable.h Fri Apr 10 16:40:59 2015
@@ -105,7 +105,7 @@ private:
bool addByName(const Atom &);
bool addByContent(const DefinedAtom &);
- LinkingContext &_context;
+ LinkingContext &_ctx;
AtomToAtom _replacedAtoms;
NameToAtom _nameTable;
NameToAtom _groupTable;
Modified: lld/trunk/include/lld/ReaderWriter/YamlContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/YamlContext.h?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/YamlContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/YamlContext.h Fri Apr 10 16:40:59 2015
@@ -31,10 +31,10 @@ using lld::mach_o::normalized::Normalize
/// different context info. This struct supports all clients.
struct YamlContext {
YamlContext()
- : _linkingContext(nullptr), _registry(nullptr), _file(nullptr),
+ : _ctx(nullptr), _registry(nullptr), _file(nullptr),
_normalizeMachOFile(nullptr) {}
- const LinkingContext *_linkingContext;
+ const LinkingContext *_ctx;
const Registry *_registry;
File *_file;
NormalizedFile *_normalizeMachOFile;
Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Fri Apr 10 16:40:59 2015
@@ -28,7 +28,7 @@
#include <vector>
namespace lld {
-SymbolTable::SymbolTable(LinkingContext &context) : _context(context) {}
+SymbolTable::SymbolTable(LinkingContext &context) : _ctx(context) {}
bool SymbolTable::add(const UndefinedAtom &atom) { return addByName(atom); }
@@ -185,7 +185,7 @@ bool SymbolTable::addByName(const Atom &
// fallthrough
}
case MCR_Error:
- if (!_context.getAllowDuplicates()) {
+ if (!_ctx.getAllowDuplicates()) {
llvm::errs() << "Duplicate symbols: "
<< existing->name()
<< ":"
@@ -207,8 +207,7 @@ bool SymbolTable::addByName(const Atom &
const UndefinedAtom* newUndef = cast<UndefinedAtom>(&newAtom);
bool sameCanBeNull = (existingUndef->canBeNull() == newUndef->canBeNull());
- if (!sameCanBeNull &&
- _context.warnIfCoalesableAtomsHaveDifferentCanBeNull()) {
+ if (!sameCanBeNull && _ctx.warnIfCoalesableAtomsHaveDifferentCanBeNull()) {
llvm::errs() << "lld warning: undefined symbol "
<< existingUndef->name()
<< " has different weakness in "
@@ -244,14 +243,14 @@ bool SymbolTable::addByName(const Atom &
(curShLib->canBeNullAtRuntime() == newShLib->canBeNullAtRuntime());
bool sameName = curShLib->loadName().equals(newShLib->loadName());
if (sameName && !sameNullness &&
- _context.warnIfCoalesableAtomsHaveDifferentCanBeNull()) {
+ _ctx.warnIfCoalesableAtomsHaveDifferentCanBeNull()) {
// FIXME: need diagonstics interface for writing warning messages
llvm::errs() << "lld warning: shared library symbol "
<< curShLib->name() << " has different weakness in "
<< curShLib->file().path() << " and in "
<< newShLib->file().path();
}
- if (!sameName && _context.warnIfCoalesableAtomsHaveDifferentLoadName()) {
+ if (!sameName && _ctx.warnIfCoalesableAtomsHaveDifferentLoadName()) {
// FIXME: need diagonstics interface for writing warning messages
llvm::errs() << "lld warning: shared library symbol "
<< curShLib->name() << " has different load path in "
@@ -268,7 +267,7 @@ bool SymbolTable::addByName(const Atom &
}
// Give context a chance to change which is kept.
- _context.notifySymbolTableCoalesce(existing, &newAtom, useNew);
+ _ctx.notifySymbolTableCoalesce(existing, &newAtom, useNew);
if (useNew) {
// Update name table to use new atom.
Modified: lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp Fri Apr 10 16:40:59 2015
@@ -272,9 +272,9 @@ private:
class CompactUnwindPass : public Pass {
public:
CompactUnwindPass(const MachOLinkingContext &context)
- : _context(context), _archHandler(_context.archHandler()),
+ : _ctx(context), _archHandler(_ctx.archHandler()),
_file("<mach-o Compact Unwind Pass>"),
- _isBig(MachOLinkingContext::isBigEndian(_context.arch())) {}
+ _isBig(MachOLinkingContext::isBigEndian(_ctx.arch())) {}
private:
void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
@@ -515,7 +515,7 @@ private:
return entry;
}
- const MachOLinkingContext &_context;
+ const MachOLinkingContext &_ctx;
mach_o::ArchHandler &_archHandler;
MachOFile _file;
bool _isBig;
Modified: lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp Fri Apr 10 16:40:59 2015
@@ -92,8 +92,8 @@ private:
class GOTPass : public Pass {
public:
GOTPass(const MachOLinkingContext &context)
- : _context(context), _archHandler(_context.archHandler()),
- _file("<mach-o GOT Pass>") { }
+ : _ctx(context), _archHandler(_ctx.archHandler()),
+ _file("<mach-o GOT Pass>") {}
private:
void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
@@ -154,7 +154,7 @@ private:
auto pos = _targetToGOT.find(target);
if (pos == _targetToGOT.end()) {
GOTEntryAtom *gotEntry = new (_file.allocator())
- GOTEntryAtom(_file, _context.is64Bit(), target->name());
+ GOTEntryAtom(_file, _ctx.is64Bit(), target->name());
_targetToGOT[target] = gotEntry;
const ArchHandler::ReferenceInfo &nlInfo = _archHandler.stubInfo().
nonLazyPointerReferenceToBinder;
@@ -165,8 +165,7 @@ private:
return pos->second;
}
-
- const MachOLinkingContext &_context;
+ const MachOLinkingContext &_ctx;
mach_o::ArchHandler &_archHandler;
MachOFile _file;
llvm::DenseMap<const Atom*, const GOTEntryAtom*> _targetToGOT;
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Fri Apr 10 16:40:59 2015
@@ -94,7 +94,7 @@ SegmentInfo::SegmentInfo(StringRef n)
class Util {
public:
Util(const MachOLinkingContext &ctxt)
- : _context(ctxt), _archHandler(ctxt.archHandler()), _entryAtom(nullptr) {}
+ : _ctx(ctxt), _archHandler(ctxt.archHandler()), _entryAtom(nullptr) {}
~Util();
void assignAtomsToSections(const lld::File &atomFile);
@@ -156,7 +156,7 @@ private:
static unsigned weight(const SectionInfo *);
};
- const MachOLinkingContext &_context;
+ const MachOLinkingContext &_ctx;
mach_o::ArchHandler &_archHandler;
llvm::BumpPtrAllocator _allocator;
std::vector<SectionInfo*> _sectionInfos;
@@ -205,9 +205,8 @@ SectionInfo *Util::getRelocatableSection
}
}
// Otherwise allocate new SectionInfo object.
- SectionInfo *sect = new (_allocator) SectionInfo(segmentName, sectionName,
- sectionType, _context,
- sectionAttrs);
+ SectionInfo *sect = new (_allocator)
+ SectionInfo(segmentName, sectionName, sectionType, _ctx, sectionAttrs);
_sectionInfos.push_back(sect);
_sectionMap[type] = sect;
return sect;
@@ -276,11 +275,8 @@ SectionInfo *Util::getFinalSection(Defin
}
}
// Otherwise allocate new SectionInfo object.
- SectionInfo *sect = new (_allocator) SectionInfo(p.segmentName,
- p.sectionName,
- p.sectionType,
- _context,
- sectionAttrs);
+ SectionInfo *sect = new (_allocator) SectionInfo(
+ p.segmentName, p.sectionName, p.sectionType, _ctx, sectionAttrs);
_sectionInfos.push_back(sect);
_sectionMap[atomType] = sect;
return sect;
@@ -297,7 +293,7 @@ SectionInfo *Util::sectionForAtom(const
auto pos = _sectionMap.find(type);
if ( pos != _sectionMap.end() )
return pos->second;
- bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT);
+ bool rMode = (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT);
return rMode ? getRelocatableSection(type) : getFinalSection(type);
} else {
// This atom needs to be in a custom section.
@@ -314,8 +310,8 @@ SectionInfo *Util::sectionForAtom(const
assert(seperatorIndex != StringRef::npos);
StringRef segName = customName.slice(0, seperatorIndex);
StringRef sectName = customName.drop_front(seperatorIndex + 1);
- SectionInfo *sect = new (_allocator) SectionInfo(segName, sectName,
- S_REGULAR, _context);
+ SectionInfo *sect =
+ new (_allocator) SectionInfo(segName, sectName, S_REGULAR, _ctx);
_customSections.push_back(sect);
_sectionInfos.push_back(sect);
return sect;
@@ -403,14 +399,14 @@ bool Util::TextSectionSorter::operator()
void Util::organizeSections() {
- if (_context.outputMachOType() == llvm::MachO::MH_OBJECT) {
+ if (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT) {
// Leave sections ordered as normalized file specified.
uint32_t sectionIndex = 1;
for (SectionInfo *si : _sectionInfos) {
si->finalSectionIndex = sectionIndex++;
}
} else {
- switch (_context.outputMachOType()){
+ switch (_ctx.outputMachOType()) {
case llvm::MachO::MH_EXECUTE:
// Main executables, need a zero-page segment
segmentForName("__PAGEZERO");
@@ -459,7 +455,7 @@ void Util::layoutSectionsInSegment(Segme
sect->address = llvm::RoundUpToAlignment(addr, sect->alignment);
addr = sect->address + sect->size;
}
- seg->size = llvm::RoundUpToAlignment(addr - seg->address,_context.pageSize());
+ seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize());
}
@@ -476,35 +472,35 @@ void Util::layoutSectionsInTextSegment(s
}
int64_t padding = taddr - hlcSize;
while (padding < 0)
- padding += _context.pageSize();
+ padding += _ctx.pageSize();
// Start assigning section address starting at padded offset.
addr += (padding + hlcSize);
for (SectionInfo *sect : seg->sections) {
sect->address = llvm::RoundUpToAlignment(addr, sect->alignment);
addr = sect->address + sect->size;
}
- seg->size = llvm::RoundUpToAlignment(addr - seg->address,_context.pageSize());
+ seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize());
}
void Util::assignAddressesToSections(const NormalizedFile &file) {
size_t hlcSize = headerAndLoadCommandsSize(file);
uint64_t address = 0;
- if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) {
+ if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) {
for (SegmentInfo *seg : _segmentInfos) {
if (seg->name.equals("__PAGEZERO")) {
- seg->size = _context.pageZeroSize();
+ seg->size = _ctx.pageZeroSize();
address += seg->size;
}
else if (seg->name.equals("__TEXT")) {
- // _context.baseAddress() == 0 implies it was either unspecified or
+ // _ctx.baseAddress() == 0 implies it was either unspecified or
// pageZeroSize is also 0. In either case resetting address is safe.
- address = _context.baseAddress() ? _context.baseAddress() : address;
+ address = _ctx.baseAddress() ? _ctx.baseAddress() : address;
layoutSectionsInTextSegment(hlcSize, seg, address);
} else
layoutSectionsInSegment(seg, address);
- address = llvm::RoundUpToAlignment(address, _context.pageSize());
+ address = llvm::RoundUpToAlignment(address, _ctx.pageSize());
}
DEBUG_WITH_TYPE("WriterMachO-norm",
llvm::dbgs() << "assignAddressesToSections()\n";
@@ -567,7 +563,7 @@ void Util::appendSection(SectionInfo *si
}
void Util::copySectionContent(NormalizedFile &file) {
- const bool r = (_context.outputMachOType() == llvm::MachO::MH_OBJECT);
+ const bool r = (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT);
// Utility function for ArchHandler to find address of atom in output file.
auto addrForAtom = [&] (const Atom &atom) -> uint64_t {
@@ -598,8 +594,8 @@ void Util::copySectionContent(Normalized
uint8_t *atomContent = reinterpret_cast<uint8_t*>
(§ionContent[ai.offsetInSection]);
_archHandler.generateAtomContent(*ai.atom, r, addrForAtom,
- sectionAddrForAtom,
- _context.baseAddress(), atomContent);
+ sectionAddrForAtom, _ctx.baseAddress(),
+ atomContent);
}
}
}
@@ -608,7 +604,7 @@ void Util::copySectionContent(Normalized
void Util::copySectionInfo(NormalizedFile &file) {
file.sections.reserve(_sectionInfos.size());
// For final linked images, write sections grouped by segment.
- if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) {
+ if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) {
for (SegmentInfo *sgi : _segmentInfos) {
for (SectionInfo *si : sgi->sections) {
appendSection(si, file);
@@ -624,7 +620,7 @@ void Util::copySectionInfo(NormalizedFil
void Util::updateSectionInfo(NormalizedFile &file) {
file.sections.reserve(_sectionInfos.size());
- if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) {
+ if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) {
// For final linked images, sections grouped by segment.
for (SegmentInfo *sgi : _segmentInfos) {
Segment *normSeg = &file.segments[sgi->normalizedSegmentIndex];
@@ -645,7 +641,7 @@ void Util::updateSectionInfo(NormalizedF
}
void Util::copyEntryPointAddress(NormalizedFile &nFile) {
- if (_context.outputTypeHasEntry()) {
+ if (_ctx.outputTypeHasEntry()) {
if (_archHandler.isThumbFunction(*_entryAtom))
nFile.entryAddress = (_atomToAddress[_entryAtom] | 1);
else
@@ -656,13 +652,13 @@ void Util::copyEntryPointAddress(Normali
void Util::buildAtomToAddressMap() {
DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs()
<< "assign atom addresses:\n");
- const bool lookForEntry = _context.outputTypeHasEntry();
+ const bool lookForEntry = _ctx.outputTypeHasEntry();
for (SectionInfo *sect : _sectionInfos) {
for (const AtomInfo &info : sect->atomsAndOffsets) {
_atomToAddress[info.atom] = sect->address + info.offsetInSection;
if (lookForEntry && (info.atom->contentType() == DefinedAtom::typeCode) &&
(info.atom->size() != 0) &&
- info.atom->name() == _context.entrySymbolName()) {
+ info.atom->name() == _ctx.entrySymbolName()) {
_entryAtom = info.atom;
}
DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs()
@@ -673,7 +669,7 @@ void Util::buildAtomToAddressMap() {
}
}
for (const Atom *atom : _machHeaderAliasAtoms) {
- _atomToAddress[atom] = _context.baseAddress();
+ _atomToAddress[atom] = _ctx.baseAddress();
DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs()
<< " address="
<< llvm::format("0x%016X", _atomToAddress[atom])
@@ -720,20 +716,20 @@ bool Util::AtomSorter::operator()(const
std::error_code Util::getSymbolTableRegion(const DefinedAtom* atom,
bool &inGlobalsRegion,
SymbolScope &scope) {
- bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT);
+ bool rMode = (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT);
switch (atom->scope()) {
case Atom::scopeTranslationUnit:
scope = 0;
inGlobalsRegion = false;
return std::error_code();
case Atom::scopeLinkageUnit:
- if ((_context.exportMode() == MachOLinkingContext::ExportMode::whiteList)
- && _context.exportSymbolNamed(atom->name())) {
+ if ((_ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) &&
+ _ctx.exportSymbolNamed(atom->name())) {
return make_dynamic_error_code(Twine("cannot export hidden symbol ")
+ atom->name());
}
if (rMode) {
- if (_context.keepPrivateExterns()) {
+ if (_ctx.keepPrivateExterns()) {
// -keep_private_externs means keep in globals region as N_PEXT.
scope = N_PEXT | N_EXT;
inGlobalsRegion = true;
@@ -745,8 +741,8 @@ std::error_code Util::getSymbolTableRegi
inGlobalsRegion = false;
return std::error_code();
case Atom::scopeGlobal:
- if (_context.exportRestrictMode()) {
- if (_context.exportSymbolNamed(atom->name())) {
+ if (_ctx.exportRestrictMode()) {
+ if (_ctx.exportSymbolNamed(atom->name())) {
scope = N_EXT;
inGlobalsRegion = true;
return std::error_code();
@@ -767,7 +763,7 @@ std::error_code Util::getSymbolTableRegi
std::error_code Util::addSymbols(const lld::File &atomFile,
NormalizedFile &file) {
- bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT);
+ bool rMode = (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT);
// Mach-O symbol table has three regions: locals, globals, undefs.
// Add all local (non-global) symbols in address order
@@ -953,8 +949,8 @@ void Util::addDependentDylibs(const lld:
DependentDylib depInfo;
depInfo.path = loadPath;
depInfo.kind = llvm::MachO::LC_LOAD_DYLIB;
- depInfo.currentVersion = _context.dylibCurrentVersion(loadPath);
- depInfo.compatVersion = _context.dylibCompatVersion(loadPath);
+ depInfo.currentVersion = _ctx.dylibCurrentVersion(loadPath);
+ depInfo.compatVersion = _ctx.dylibCompatVersion(loadPath);
nFile.dependentDylibs.push_back(depInfo);
} else {
if ( slAtom->canBeNullAtRuntime() )
@@ -968,7 +964,7 @@ void Util::addDependentDylibs(const lld:
DylibInfo &info = _dylibInfo[dep.path];
if (info.hasWeak && !info.hasNonWeak)
dep.kind = llvm::MachO::LC_LOAD_WEAK_DYLIB;
- else if (_context.isUpwardDylib(dep.path))
+ else if (_ctx.isUpwardDylib(dep.path))
dep.kind = llvm::MachO::LC_LOAD_UPWARD_DYLIB;
}
}
@@ -1005,7 +1001,7 @@ uint32_t Util::sectionIndexForAtom(const
}
void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) {
- if (_context.outputMachOType() != llvm::MachO::MH_OBJECT)
+ if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT)
return;
@@ -1085,7 +1081,7 @@ void Util::buildDataInCodeArray(const ll
void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
NormalizedFile &nFile) {
- if (_context.outputMachOType() == llvm::MachO::MH_OBJECT)
+ if (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT)
return;
uint8_t segmentIndex;
@@ -1141,7 +1137,7 @@ void Util::addRebaseAndBindingInfo(const
}
void Util::addExportInfo(const lld::File &atomFile, NormalizedFile &nFile) {
- if (_context.outputMachOType() == llvm::MachO::MH_OBJECT)
+ if (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT)
return;
for (SectionInfo *sect : _sectionInfos) {
@@ -1149,8 +1145,8 @@ void Util::addExportInfo(const lld::File
const DefinedAtom *atom = info.atom;
if (atom->scope() != Atom::scopeGlobal)
continue;
- if (_context.exportRestrictMode()) {
- if (!_context.exportSymbolNamed(atom->name()))
+ if (_ctx.exportRestrictMode()) {
+ if (!_ctx.exportSymbolNamed(atom->name()))
continue;
}
Export exprt;
@@ -1170,10 +1166,10 @@ void Util::addExportInfo(const lld::File
uint32_t Util::fileFlags() {
// FIXME: these need to determined at runtime.
- if (_context.outputMachOType() == MH_OBJECT) {
+ if (_ctx.outputMachOType() == MH_OBJECT) {
return MH_SUBSECTIONS_VIA_SYMBOLS;
} else {
- if ((_context.outputMachOType() == MH_EXECUTE) && _context.PIE())
+ if ((_ctx.outputMachOType() == MH_EXECUTE) && _ctx.PIE())
return MH_DYLDLINK | MH_NOUNDEFS | MH_TWOLEVEL | MH_PIE;
else
return MH_DYLDLINK | MH_NOUNDEFS | MH_TWOLEVEL;
Modified: lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp Fri Apr 10 16:40:59 2015
@@ -41,11 +41,8 @@ namespace mach_o {
class ShimPass : public Pass {
public:
ShimPass(const MachOLinkingContext &context)
- : _context(context)
- , _archHandler(_context.archHandler())
- , _stubInfo(_archHandler.stubInfo())
- , _file("<mach-o shim pass>") {
- }
+ : _ctx(context), _archHandler(_ctx.archHandler()),
+ _stubInfo(_archHandler.stubInfo()), _file("<mach-o shim pass>") {}
void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
// Scan all references in all atoms.
@@ -111,7 +108,7 @@ private:
}
}
- const MachOLinkingContext &_context;
+ const MachOLinkingContext &_ctx;
mach_o::ArchHandler &_archHandler;
const ArchHandler::StubInfo &_stubInfo;
MachOFile _file;
Modified: lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp Fri Apr 10 16:40:59 2015
@@ -206,8 +206,8 @@ private:
class StubsPass : public Pass {
public:
StubsPass(const MachOLinkingContext &context)
- : _context(context), _archHandler(_context.archHandler()),
- _stubInfo(_archHandler.stubInfo()), _file("<mach-o Stubs pass>") { }
+ : _ctx(context), _archHandler(_ctx.archHandler()),
+ _stubInfo(_archHandler.stubInfo()), _file("<mach-o Stubs pass>") {}
void perform(std::unique_ptr<SimpleFile> &mergedFile) override {
// Skip this pass if output format uses text relocations instead of stubs.
@@ -245,9 +245,9 @@ public:
SimpleDefinedAtom *helperCommonAtom =
new (_file.allocator()) StubHelperCommonAtom(_file, _stubInfo);
SimpleDefinedAtom *helperCacheNLPAtom =
- new (_file.allocator()) NonLazyPointerAtom(_file, _context.is64Bit());
+ new (_file.allocator()) NonLazyPointerAtom(_file, _ctx.is64Bit());
SimpleDefinedAtom *helperBinderNLPAtom =
- new (_file.allocator()) NonLazyPointerAtom(_file, _context.is64Bit());
+ new (_file.allocator()) NonLazyPointerAtom(_file, _ctx.is64Bit());
addReference(helperCommonAtom, _stubInfo.stubHelperCommonReferenceToCache,
helperCacheNLPAtom);
addOptReference(
@@ -285,7 +285,7 @@ public:
for (const Atom *target : targetsNeedingStubs) {
StubAtom *stub = new (_file.allocator()) StubAtom(_file, _stubInfo);
LazyPointerAtom *lp =
- new (_file.allocator()) LazyPointerAtom(_file, _context.is64Bit());
+ new (_file.allocator()) LazyPointerAtom(_file, _ctx.is64Bit());
StubHelperAtom *helper =
new (_file.allocator()) StubHelperAtom(_file, _stubInfo);
@@ -355,7 +355,7 @@ private:
typedef llvm::DenseMap<const Atom*,
llvm::SmallVector<const Reference *, 8>> TargetToUses;
- const MachOLinkingContext &_context;
+ const MachOLinkingContext &_ctx;
mach_o::ArchHandler &_archHandler;
const ArchHandler::StubInfo &_stubInfo;
MachOFile _file;
Modified: lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp Fri Apr 10 16:40:59 2015
@@ -26,18 +26,18 @@ namespace mach_o {
class MachOWriter : public Writer {
public:
- MachOWriter(const MachOLinkingContext &ctxt) : _context(ctxt) { }
+ MachOWriter(const MachOLinkingContext &ctxt) : _ctx(ctxt) {}
std::error_code writeFile(const lld::File &file, StringRef path) override {
// Construct empty normalized file from atoms.
ErrorOr<std::unique_ptr<NormalizedFile>> nFile =
- normalized::normalizedFromAtoms(file, _context);
+ normalized::normalizedFromAtoms(file, _ctx);
if (std::error_code ec = nFile.getError())
return ec;
// For testing, write out yaml form of normalized file.
- if (_context.printAtoms()) {
- std::unique_ptr<Writer> yamlWriter = createWriterYAML(_context);
+ if (_ctx.printAtoms()) {
+ std::unique_ptr<Writer> yamlWriter = createWriterYAML(_ctx);
yamlWriter->writeFile(file, "-");
}
@@ -47,17 +47,17 @@ public:
void createImplicitFiles(std::vector<std::unique_ptr<File>> &r) override {
// When building main executables, add _main as required entry point.
- if (_context.outputTypeHasEntry())
- r.emplace_back(new CEntryFile(_context));
+ if (_ctx.outputTypeHasEntry())
+ r.emplace_back(new CEntryFile(_ctx));
// If this can link with dylibs, need helper function (dyld_stub_binder).
- if (_context.needsStubsPass())
- r.emplace_back(new StubHelperFile(_context));
+ if (_ctx.needsStubsPass())
+ r.emplace_back(new StubHelperFile(_ctx));
// Final linked images can access a symbol for their mach_header.
- if (_context.outputMachOType() != llvm::MachO::MH_OBJECT)
- r.emplace_back(new MachHeaderAliasFile(_context));
+ if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT)
+ r.emplace_back(new MachHeaderAliasFile(_ctx));
}
private:
- const MachOLinkingContext &_context;
+ const MachOLinkingContext &_ctx;
};
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Fri Apr 10 16:40:59 2015
@@ -104,15 +104,15 @@ public:
class DOSStubChunk : public HeaderChunk {
public:
explicit DOSStubChunk(const PECOFFLinkingContext &ctx)
- : HeaderChunk(), _context(ctx) {
+ : HeaderChunk(), _ctx(ctx) {
// Minimum size of DOS stub is 64 bytes. The next block (PE header) needs to
// be aligned on 8 byte boundary.
- size_t size = std::max(_context.getDosStub().size(), (size_t)64);
+ size_t size = std::max(_ctx.getDosStub().size(), (size_t)64);
_size = llvm::RoundUpToAlignment(size, 8);
}
void write(uint8_t *buffer) override {
- ArrayRef<uint8_t> array = _context.getDosStub();
+ ArrayRef<uint8_t> array = _ctx.getDosStub();
std::memcpy(buffer, array.data(), array.size());
auto *header = reinterpret_cast<llvm::object::dos_header *>(buffer);
header->AddressOfRelocationTable = sizeof(llvm::object::dos_header);
@@ -120,7 +120,7 @@ public:
}
private:
- const PECOFFLinkingContext &_context;
+ const PECOFFLinkingContext &_ctx;
};
/// A PEHeaderChunk represents PE header including COFF header.
Modified: lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp?rev=234645&r1=234644&r2=234645&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp Fri Apr 10 16:40:59 2015
@@ -1230,7 +1230,7 @@ namespace yaml {
class Writer : public lld::Writer {
public:
- Writer(const LinkingContext &context) : _context(context) {}
+ Writer(const LinkingContext &context) : _ctx(context) {}
std::error_code writeFile(const lld::File &file, StringRef outPath) override {
// Create stream to path.
@@ -1241,8 +1241,8 @@ public:
// Create yaml Output writer, using yaml options for context.
YamlContext yamlContext;
- yamlContext._linkingContext = &_context;
- yamlContext._registry = &_context.registry();
+ yamlContext._ctx = &_ctx;
+ yamlContext._registry = &_ctx.registry();
llvm::yaml::Output yout(out, &yamlContext);
// Write yaml output.
@@ -1253,7 +1253,7 @@ public:
}
private:
- const LinkingContext &_context;
+ const LinkingContext &_ctx;
};
} // end namespace yaml
More information about the llvm-commits
mailing list