Index: lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h @@ -19,7 +19,7 @@ template class AArch64DynamicLibraryWriter : public DynamicLibraryWriter { public: - AArch64DynamicLibraryWriter(AArch64LinkingContext &context, + AArch64DynamicLibraryWriter(AArch64LinkingContext &ctx, AArch64TargetLayout &layout); protected: @@ -42,16 +42,15 @@ }; std::unique_ptr _gotFile; - AArch64LinkingContext &_context; + AArch64LinkingContext &_ctx; AArch64TargetLayout &_AArch64Layout; }; template AArch64DynamicLibraryWriter::AArch64DynamicLibraryWriter( - AArch64LinkingContext &context, AArch64TargetLayout &layout) - : DynamicLibraryWriter(context, layout), - _gotFile(new GOTFile(context)), _context(context), - _AArch64Layout(layout) {} + AArch64LinkingContext &ctx, AArch64TargetLayout &layout) + : DynamicLibraryWriter(ctx, layout), _gotFile(new GOTFile(ctx)), + _ctx(ctx), _AArch64Layout(layout) {} template bool AArch64DynamicLibraryWriter::createImplicitFiles( Index: lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.h +++ lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.h @@ -18,7 +18,7 @@ template class AArch64ExecutableWriter : public ExecutableWriter { public: - AArch64ExecutableWriter(AArch64LinkingContext &context, + AArch64ExecutableWriter(AArch64LinkingContext &ctx, AArch64TargetLayout &layout); protected: @@ -41,22 +41,22 @@ }; std::unique_ptr _gotFile; - AArch64LinkingContext &_context; + AArch64LinkingContext &_ctx; AArch64TargetLayout &_AArch64Layout; }; template AArch64ExecutableWriter::AArch64ExecutableWriter( - AArch64LinkingContext &context, AArch64TargetLayout &layout) - : ExecutableWriter(context, layout), _gotFile(new GOTFile(context)), - _context(context), _AArch64Layout(layout) {} + AArch64LinkingContext &ctx, AArch64TargetLayout &layout) + : ExecutableWriter(ctx, layout), _gotFile(new GOTFile(ctx)), + _ctx(ctx), _AArch64Layout(layout) {} template bool AArch64ExecutableWriter::createImplicitFiles( std::vector> &result) { ExecutableWriter::createImplicitFiles(result); _gotFile->addAtom(*new (_gotFile->_alloc) GLOBAL_OFFSET_TABLEAtom(*_gotFile)); - if (_context.isDynamic()) + if (_ctx.isDynamic()) _gotFile->addAtom(*new (_gotFile->_alloc) DYNAMICAtom(*_gotFile)); result.push_back(std::move(_gotFile)); return true; Index: lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h +++ lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h @@ -23,13 +23,12 @@ template class AArch64TargetLayout : public TargetLayout { public: - AArch64TargetLayout(AArch64LinkingContext &context) - : TargetLayout(context) {} + AArch64TargetLayout(AArch64LinkingContext &ctx) : TargetLayout(ctx) {} }; class AArch64TargetHandler final : public DefaultTargetHandler { public: - AArch64TargetHandler(AArch64LinkingContext &context); + AArch64TargetHandler(AArch64LinkingContext &ctx); AArch64TargetLayout &getTargetLayout() override { return *(_AArch64TargetLayout.get()); @@ -42,18 +41,18 @@ } std::unique_ptr getObjReader() override { - return std::unique_ptr(new AArch64ELFObjectReader(_context)); + return std::unique_ptr(new AArch64ELFObjectReader(_ctx)); } std::unique_ptr getDSOReader() override { - return std::unique_ptr(new AArch64ELFDSOReader(_context)); + return std::unique_ptr(new AArch64ELFDSOReader(_ctx)); } std::unique_ptr getWriter() override; private: static const Registry::KindStrings kindStrings[]; - AArch64LinkingContext &_context; + AArch64LinkingContext &_ctx; std::unique_ptr> _AArch64TargetLayout; std::unique_ptr _AArch64RelocationHandler; }; Index: lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp +++ lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp @@ -16,9 +16,9 @@ using namespace lld; using namespace elf; -AArch64TargetHandler::AArch64TargetHandler(AArch64LinkingContext &context) - : _context(context), - _AArch64TargetLayout(new AArch64TargetLayout(context)), +AArch64TargetHandler::AArch64TargetHandler(AArch64LinkingContext &ctx) + : _ctx(ctx), + _AArch64TargetLayout(new AArch64TargetLayout(ctx)), _AArch64RelocationHandler(new AArch64TargetRelocationHandler()) {} void AArch64TargetHandler::registerRelocationNames(Registry ®istry) { @@ -27,13 +27,13 @@ } std::unique_ptr AArch64TargetHandler::getWriter() { - switch (this->_context.getOutputELFType()) { + switch (this->_ctx.getOutputELFType()) { case llvm::ELF::ET_EXEC: return llvm::make_unique>( - _context, *_AArch64TargetLayout.get()); + _ctx, *_AArch64TargetLayout.get()); case llvm::ELF::ET_DYN: return llvm::make_unique>( - _context, *_AArch64TargetLayout.get()); + _ctx, *_AArch64TargetLayout.get()); case llvm::ELF::ET_REL: llvm_unreachable("TODO: support -r mode"); default: Index: lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h +++ lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h @@ -24,8 +24,7 @@ template class ARMExecutableWriter : public ExecutableWriter { public: - ARMExecutableWriter(ARMLinkingContext &context, - ARMTargetLayout &layout); + ARMExecutableWriter(ARMLinkingContext &ctx, ARMTargetLayout &layout); protected: // Add any runtime files and their atoms to the output @@ -47,15 +46,14 @@ std::error_code setELFHeader() override; private: - ARMLinkingContext &_context; + ARMLinkingContext &_ctx; ARMTargetLayout &_armLayout; }; template -ARMExecutableWriter::ARMExecutableWriter(ARMLinkingContext &context, +ARMExecutableWriter::ARMExecutableWriter(ARMLinkingContext &ctx, ARMTargetLayout &layout) - : ExecutableWriter(context, layout), _context(context), - _armLayout(layout) {} + : ExecutableWriter(ctx, layout), _ctx(ctx), _armLayout(layout) {} template bool ARMExecutableWriter::createImplicitFiles( @@ -85,7 +83,7 @@ unique_bump_ptr> ARMExecutableWriter::createSymbolTable() { return unique_bump_ptr>( - new (this->_alloc) ARMSymbolTable(this->_context)); + new (this->_alloc) ARMSymbolTable(this->_ctx)); } template @@ -105,7 +103,7 @@ return ec; // Fixup entry point for Thumb code. - StringRef entryName = _context.entrySymbolName(); + StringRef entryName = _ctx.entrySymbolName(); if (const AtomLayout *al = _armLayout.findAtomLayoutByName(entryName)) { const auto *ea = dyn_cast(al->_atom); if (ea && ea->codeModel() == DefinedAtom::codeARMThumb) Index: lib/ReaderWriter/ELF/ARM/ARMSymbolTable.h =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMSymbolTable.h +++ lib/ReaderWriter/ELF/ARM/ARMSymbolTable.h @@ -19,15 +19,15 @@ public: typedef llvm::object::Elf_Sym_Impl Elf_Sym; - ARMSymbolTable(const ELFLinkingContext &context); + ARMSymbolTable(const ELFLinkingContext &ctx); void addDefinedAtom(Elf_Sym &sym, const DefinedAtom *da, int64_t addr) override; }; template -ARMSymbolTable::ARMSymbolTable(const ELFLinkingContext &context) - : SymbolTable(context, ".symtab", +ARMSymbolTable::ARMSymbolTable(const ELFLinkingContext &ctx) + : SymbolTable(ctx, ".symtab", DefaultLayout::ORDER_SYMBOL_TABLE) {} template Index: lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h +++ lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h @@ -27,8 +27,7 @@ template class ARMTargetLayout : public TargetLayout { public: - ARMTargetLayout(ARMLinkingContext &context) - : TargetLayout(context) {} + ARMTargetLayout(ARMLinkingContext &ctx) : TargetLayout(ctx) {} uint64_t getTPOffset() { if (_tpOff.hasValue()) @@ -53,7 +52,7 @@ class ARMTargetHandler final : public DefaultTargetHandler { public: - ARMTargetHandler(ARMLinkingContext &context); + ARMTargetHandler(ARMLinkingContext &ctx); ARMTargetLayout &getTargetLayout() override { return *(_armTargetLayout.get()); @@ -66,18 +65,18 @@ } std::unique_ptr getObjReader() override { - return std::unique_ptr(new ARMELFObjectReader(_context)); + return std::unique_ptr(new ARMELFObjectReader(_ctx)); } std::unique_ptr getDSOReader() override { - return std::unique_ptr(new ARMELFDSOReader(_context)); + return std::unique_ptr(new ARMELFDSOReader(_ctx)); } std::unique_ptr getWriter() override; private: static const Registry::KindStrings kindStrings[]; - ARMLinkingContext &_context; + ARMLinkingContext &_ctx; std::unique_ptr> _armTargetLayout; std::unique_ptr _armRelocationHandler; }; Index: lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp +++ lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp @@ -15,11 +15,10 @@ using namespace lld; using namespace elf; -ARMTargetHandler::ARMTargetHandler(ARMLinkingContext &context) - : _context(context), _armTargetLayout( - new ARMTargetLayout(context)), - _armRelocationHandler(new ARMTargetRelocationHandler( - *_armTargetLayout.get())) {} +ARMTargetHandler::ARMTargetHandler(ARMLinkingContext &ctx) + : _ctx(ctx), _armTargetLayout(new ARMTargetLayout(ctx)), + _armRelocationHandler( + new ARMTargetRelocationHandler(*_armTargetLayout.get())) {} void ARMTargetHandler::registerRelocationNames(Registry ®istry) { registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::ARM, @@ -27,10 +26,10 @@ } std::unique_ptr ARMTargetHandler::getWriter() { - switch (this->_context.getOutputELFType()) { + switch (this->_ctx.getOutputELFType()) { case llvm::ELF::ET_EXEC: return llvm::make_unique>( - _context, *_armTargetLayout.get()); + _ctx, *_armTargetLayout.get()); default: llvm_unreachable("unsupported output type"); } Index: lib/ReaderWriter/ELF/Chunk.h =================================================================== --- lib/ReaderWriter/ELF/Chunk.h +++ lib/ReaderWriter/ELF/Chunk.h @@ -45,9 +45,9 @@ /// \brief the ContentType of the chunk enum ContentType : uint8_t{ Unknown, Header, Code, Data, Note, TLS }; - Chunk(StringRef name, Kind kind, const ELFLinkingContext &context) - : _name(name), _kind(kind), _fsize(0), _msize(0), _alignment(0), _order(0), - _ordinal(1), _start(0), _fileoffset(0), _context(context) {} + Chunk(StringRef name, Kind kind, const ELFLinkingContext &ctx) + : _name(name), _kind(kind), _fsize(0), _msize(0), _alignment(0), + _order(0), _ordinal(1), _start(0), _fileoffset(0), _ctx(ctx) {} virtual ~Chunk() {} // The name of the chunk StringRef name() const { return _name; } @@ -93,7 +93,7 @@ uint64_t _ordinal; uint64_t _start; uint64_t _fileoffset; - const ELFLinkingContext &_context; + const ELFLinkingContext &_ctx; }; } // end namespace elf Index: lib/ReaderWriter/ELF/DefaultLayout.h =================================================================== --- lib/ReaderWriter/ELF/DefaultLayout.h +++ lib/ReaderWriter/ELF/DefaultLayout.h @@ -170,8 +170,8 @@ typedef llvm::DenseSet AtomSetT; - DefaultLayout(ELFLinkingContext &context) - : _context(context), _linkerScriptSema(context.linkerScriptSema()) {} + DefaultLayout(ELFLinkingContext &ctx) + : _ctx(ctx), _linkerScriptSema(ctx.linkerScriptSema()) {} /// \brief Return the section order for a input section SectionOrder getSectionOrder(StringRef name, int32_t contentType, @@ -283,7 +283,7 @@ RelocationTable *getDynamicRelocationTable() { if (!_dynamicRelocationTable) { _dynamicRelocationTable = std::move(createRelocationTable( - _context.isRelaOutputFormat() ? ".rela.dyn" : ".rel.dyn", + _ctx.isRelaOutputFormat() ? ".rela.dyn" : ".rel.dyn", ORDER_DYNAMIC_RELOCS)); addSection(_dynamicRelocationTable.get()); } @@ -294,7 +294,7 @@ RelocationTable *getPLTRelocationTable() { if (!_pltRelocationTable) { _pltRelocationTable = std::move(createRelocationTable( - _context.isRelaOutputFormat() ? ".rela.plt" : ".rel.plt", + _ctx.isRelaOutputFormat() ? ".rela.plt" : ".rel.plt", ORDER_DYNAMIC_PLT_RELOCS)); addSection(_pltRelocationTable.get()); } @@ -335,7 +335,7 @@ virtual unique_bump_ptr> createRelocationTable(StringRef name, int32_t order) { return unique_bump_ptr>( - new (_allocator) RelocationTable(_context, name, order)); + new (_allocator) RelocationTable(_ctx, name, order)); } private: @@ -358,7 +358,7 @@ std::vector _absoluteAtoms; AtomSetT _referencedDynAtoms; llvm::StringSet<> _copiedDynSymNames; - ELFLinkingContext &_context; + ELFLinkingContext &_ctx; script::Sema &_linkerScriptSema; }; @@ -570,7 +570,7 @@ AtomSection *DefaultLayout::createSection( StringRef sectionName, int32_t contentType, DefinedAtom::ContentPermissions permissions, SectionOrder sectionOrder) { - return new (_allocator) AtomSection(_context, sectionName, contentType, + return new (_allocator) AtomSection(_ctx, sectionName, contentType, permissions, sectionOrder); } @@ -617,10 +617,10 @@ // Add runtime relocations to the .rela section. for (const auto &reloc : *definedAtom) { bool isLocalReloc = true; - if (_context.isDynamicRelocation(*reloc)) { + if (_ctx.isDynamicRelocation(*reloc)) { getDynamicRelocationTable()->addRelocation(*definedAtom, *reloc); isLocalReloc = false; - } else if (_context.isPLTRelocation(*reloc)) { + } else if (_ctx.isPLTRelocation(*reloc)) { getPLTRelocationTable()->addRelocation(*definedAtom, *reloc); isLocalReloc = false; } @@ -632,7 +632,7 @@ if (isa(reloc->target()) && isLocalReloc) continue; - if (_context.isCopyRelocation(*reloc)) { + if (_ctx.isCopyRelocation(*reloc)) { _copiedDynSymNames.insert(definedAtom->name()); continue; } @@ -716,7 +716,7 @@ template void DefaultLayout::assignSectionsToSegments() { ScopedTask task(getDefaultDomain(), "assignSectionsToSegments"); - ELFLinkingContext::OutputMagic outputMagic = _context.getOutputMagic(); + ELFLinkingContext::OutputMagic outputMagic = _ctx.getOutputMagic(); // sort the sections by their order as defined by the layout sortInputSections(); @@ -752,7 +752,7 @@ int64_t lookupSectionFlag = osi->flags(); if ((!(lookupSectionFlag & llvm::ELF::SHF_WRITE)) && - (_context.mergeRODataToTextSegment())) + (_ctx.mergeRODataToTextSegment())) lookupSectionFlag &= ~llvm::ELF::SHF_EXECINSTR; // Merge string sections into Data segment itself @@ -774,8 +774,8 @@ if (!additionalSegmentInsert.second) { segment = additionalSegmentInsert.first->second; } else { - segment = new (_allocator) - Segment(_context, segmentName, segmentType); + segment = + new (_allocator) Segment(_ctx, segmentName, segmentType); additionalSegmentInsert.first->second = segment; _segments.push_back(segment); } @@ -802,7 +802,7 @@ segment = segmentInsert.first->second; } else { segment = new (_allocator) - Segment(_context, "PT_LOAD", llvm::ELF::PT_LOAD); + Segment(_ctx, "PT_LOAD", llvm::ELF::PT_LOAD); segmentInsert.first->second = segment; _segments.push_back(segment); } @@ -815,9 +815,8 @@ } } } - if (_context.isDynamic() && !_context.isDynamicLibrary()) { - Segment *segment = - new (_allocator) ProgramHeaderSegment(_context); + if (_ctx.isDynamic() && !_ctx.isDynamicLibrary()) { + Segment *segment = new (_allocator) ProgramHeaderSegment(_ctx); _segments.push_back(segment); segment->append(_elfHeader); segment->append(_programHeader); @@ -832,7 +831,7 @@ std::sort(_segments.begin(), _segments.end(), Segment::compareSegments); - uint64_t baseAddress = _context.getBaseAddress(); + uint64_t baseAddress = _ctx.getBaseAddress(); // HACK: This is a super dirty hack. The elf header and program header are // not part of a section, but we need them to be loaded at the base address @@ -1039,7 +1038,7 @@ _linkerScriptSema.getExprs({archivePath, memberPath, sectionName}); for (auto expr : exprs) { auto expChunk = - new (this->_allocator) ExpressionChunk(this->_context, expr); + new (this->_allocator) ExpressionChunk(this->_ctx, expr); segment->append(expChunk); } } Index: lib/ReaderWriter/ELF/DynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/DynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/DynamicLibraryWriter.h @@ -25,9 +25,9 @@ template class DynamicLibraryWriter : public OutputELFWriter { public: - DynamicLibraryWriter(ELFLinkingContext &context, TargetLayout &layout) - : OutputELFWriter(context, layout), - _runtimeFile(new RuntimeFile(context, "C runtime")) {} + DynamicLibraryWriter(ELFLinkingContext &ctx, TargetLayout &layout) + : OutputELFWriter(ctx, layout), + _runtimeFile(new RuntimeFile(ctx, "C runtime")) {} protected: virtual void buildDynamicSymbolTable(const File &file); Index: lib/ReaderWriter/ELF/ELFFile.h =================================================================== --- lib/ReaderWriter/ELF/ELFFile.h +++ lib/ReaderWriter/ELF/ELFFile.h @@ -445,8 +445,8 @@ template class RuntimeFile : public ELFFile { public: typedef llvm::object::Elf_Sym_Impl Elf_Sym; - RuntimeFile(ELFLinkingContext &context, StringRef name) - : ELFFile(name, context) {} + RuntimeFile(ELFLinkingContext &ctx, StringRef name) + : ELFFile(name, ctx) {} /// \brief add a global absolute atom virtual Atom *addAbsoluteAtom(StringRef symbolName) { Index: lib/ReaderWriter/ELF/ExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/ExecutableWriter.h +++ lib/ReaderWriter/ELF/ExecutableWriter.h @@ -25,9 +25,9 @@ template class ExecutableWriter : public OutputELFWriter { public: - ExecutableWriter(ELFLinkingContext &context, TargetLayout &layout) - : OutputELFWriter(context, layout), - _runtimeFile(new RuntimeFile(context, "C runtime")) {} + ExecutableWriter(ELFLinkingContext &ctx, TargetLayout &layout) + : OutputELFWriter(ctx, layout), + _runtimeFile(new RuntimeFile(ctx, "C runtime")) {} protected: virtual void buildDynamicSymbolTable(const File &file); @@ -56,8 +56,8 @@ if (!da) continue; if (da->dynamicExport() != DefinedAtom::dynamicExportAlways && - !this->_context.isDynamicallyExportedSymbol(da->name()) && - !(this->_context.shouldExportDynamic() && + !this->_ctx.isDynamicallyExportedSymbol(da->name()) && + !(this->_ctx.shouldExportDynamic() && da->scope() == Atom::Scope::scopeGlobal)) continue; this->_dynamicSymbolTable->addSymbol(atom->_atom, section->ordinal(), @@ -65,7 +65,7 @@ } // Put weak symbols in the dynamic symbol table. - if (this->_context.isDynamic()) { + if (this->_ctx.isDynamic()) { for (const UndefinedAtom *a : file.undefined()) { if (this->_layout.isReferencedByDefinedAtom(a) && a->canBeNull() != UndefinedAtom::canBeNullNever) @@ -81,7 +81,7 @@ template void ExecutableWriter::addDefaultAtoms() { OutputELFWriter::addDefaultAtoms(); - _runtimeFile->addUndefinedAtom(this->_context.entrySymbolName()); + _runtimeFile->addUndefinedAtom(this->_ctx.entrySymbolName()); _runtimeFile->addAbsoluteAtom("__bss_start"); _runtimeFile->addAbsoluteAtom("__bss_end"); _runtimeFile->addAbsoluteAtom("_end"); @@ -90,7 +90,7 @@ _runtimeFile->addAbsoluteAtom("__preinit_array_end"); _runtimeFile->addAbsoluteAtom("__init_array_start"); _runtimeFile->addAbsoluteAtom("__init_array_end"); - if (this->_context.isRelaOutputFormat()) { + if (this->_ctx.isRelaOutputFormat()) { _runtimeFile->addAbsoluteAtom("__rela_iplt_start"); _runtimeFile->addAbsoluteAtom("__rela_iplt_end"); } else { @@ -114,10 +114,10 @@ template void ExecutableWriter::createDefaultSections() { OutputELFWriter::createDefaultSections(); - if (this->_context.isDynamic()) { + if (this->_ctx.isDynamic()) { _interpSection.reset(new (this->_alloc) InterpSection( - this->_context, ".interp", DefaultLayout::ORDER_INTERP, - this->_context.getInterpreter())); + this->_ctx, ".interp", DefaultLayout::ORDER_INTERP, + this->_ctx.getInterpreter())); this->_layout.addSection(_interpSection.get()); } } @@ -148,7 +148,7 @@ startEnd("preinit_array", ".preinit_array"); startEnd("init_array", ".init_array"); - if (this->_context.isRelaOutputFormat()) + if (this->_ctx.isRelaOutputFormat()) startEnd("rela_iplt", ".rela.plt"); else startEnd("rel_iplt", ".rel.plt"); Index: lib/ReaderWriter/ELF/HeaderChunks.h =================================================================== --- lib/ReaderWriter/ELF/HeaderChunks.h +++ lib/ReaderWriter/ELF/HeaderChunks.h @@ -63,8 +63,8 @@ (ELFT::TargetEndianness == llvm::support::little) ? llvm::ELF::ELFDATA2LSB : llvm::ELF::ELFDATA2MSB; - _eh.e_type = this->_context.getOutputELFType(); - _eh.e_machine = this->_context.getOutputMachine(); + _eh.e_type = this->_ctx.getOutputELFType(); + _eh.e_machine = this->_ctx.getOutputMachine(); } private: @@ -72,8 +72,8 @@ }; template -ELFHeader::ELFHeader(const ELFLinkingContext &context) - : Chunk("elfhdr", Chunk::Kind::ELFHeader, context) { +ELFHeader::ELFHeader(const ELFLinkingContext &ctx) + : Chunk("elfhdr", Chunk::Kind::ELFHeader, ctx) { this->_alignment = ELFT::Is64Bits ? 8 : 4; this->_fsize = sizeof(Elf_Ehdr); this->_msize = sizeof(Elf_Ehdr); @@ -124,8 +124,8 @@ uint64_t _flagsClear; }; - ProgramHeader(const ELFLinkingContext &context) - : Chunk("elfphdr", Chunk::Kind::ProgramHeader, context) { + ProgramHeader(const ELFLinkingContext &ctx) + : Chunk("elfphdr", Chunk::Kind::ProgramHeader, ctx) { this->_alignment = ELFT::Is64Bits ? 8 : 4; resetProgramHeaders(); } @@ -197,7 +197,7 @@ template bool ProgramHeader::addSegment(Segment *segment) { bool allocatedNew = false; - ELFLinkingContext::OutputMagic outputMagic = this->_context.getOutputMagic(); + ELFLinkingContext::OutputMagic outputMagic = this->_ctx.getOutputMagic(); // For segments that are not a loadable segment, we // just pick the values directly from the segment as there // wouldnt be any slices within that @@ -300,9 +300,8 @@ }; template -SectionHeader::SectionHeader(const ELFLinkingContext &context, - int32_t order) - : Chunk("shdr", Chunk::Kind::SectionHeader, context) { +SectionHeader::SectionHeader(const ELFLinkingContext &ctx, int32_t order) + : Chunk("shdr", Chunk::Kind::SectionHeader, ctx) { this->_fsize = 0; this->_alignment = 8; this->setOrder(order); Index: lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h @@ -22,7 +22,7 @@ class HexagonDynamicLibraryWriter : public DynamicLibraryWriter, public HexagonELFWriter { public: - HexagonDynamicLibraryWriter(HexagonLinkingContext &context, + HexagonDynamicLibraryWriter(HexagonLinkingContext &ctx, HexagonTargetLayout &layout); protected: @@ -43,18 +43,18 @@ _hexagonRuntimeFile->addAbsoluteAtom("_DYNAMIC"); } - HexagonLinkingContext &_hexagonLinkingContext; + HexagonLinkingContext &_ctx; HexagonTargetLayout &_hexagonTargetLayout; std::unique_ptr> _hexagonRuntimeFile; }; template HexagonDynamicLibraryWriter::HexagonDynamicLibraryWriter( - HexagonLinkingContext &context, HexagonTargetLayout &layout) - : DynamicLibraryWriter(context, layout), - HexagonELFWriter(context, layout), _hexagonLinkingContext(context), + HexagonLinkingContext &ctx, HexagonTargetLayout &layout) + : DynamicLibraryWriter(ctx, layout), + HexagonELFWriter(ctx, layout), _ctx(ctx), _hexagonTargetLayout(layout), - _hexagonRuntimeFile(new HexagonRuntimeFile(context)) {} + _hexagonRuntimeFile(new HexagonRuntimeFile(ctx)) {} template bool HexagonDynamicLibraryWriter::createImplicitFiles( Index: lib/ReaderWriter/ELF/Hexagon/HexagonELFWriters.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonELFWriters.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonELFWriters.h @@ -20,9 +20,9 @@ template class HexagonELFWriter { public: - HexagonELFWriter(HexagonLinkingContext &context, + HexagonELFWriter(HexagonLinkingContext &ctx, HexagonTargetLayout &targetLayout) - : _hexagonLinkingContext(context), _hexagonTargetLayout(targetLayout) {} + : _ctx(ctx), _hexagonTargetLayout(targetLayout) {} protected: bool setELFHeader(ELFHeader &elfHeader) { @@ -34,7 +34,7 @@ } void finalizeHexagonRuntimeAtomValues() { - if (_hexagonLinkingContext.isDynamic()) { + if (_ctx.isDynamic()) { auto gotAtomIter = _hexagonTargetLayout.findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_"); auto gotpltSection = _hexagonTargetLayout.findOutputSection(".got.plt"); @@ -52,7 +52,7 @@ } private: - HexagonLinkingContext &_hexagonLinkingContext; + HexagonLinkingContext &_ctx; HexagonTargetLayout &_hexagonTargetLayout; }; Index: lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h @@ -20,8 +20,8 @@ template class HexagonRuntimeFile : public RuntimeFile { public: - HexagonRuntimeFile(HexagonLinkingContext &context) - : RuntimeFile(context, "Hexagon runtime file") {} + HexagonRuntimeFile(HexagonLinkingContext &ctx) + : RuntimeFile(ctx, "Hexagon runtime file") {} }; } // elf } // lld Index: lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h @@ -23,7 +23,7 @@ class HexagonExecutableWriter : public ExecutableWriter, public HexagonELFWriter { public: - HexagonExecutableWriter(HexagonLinkingContext &context, + HexagonExecutableWriter(HexagonLinkingContext &ctx, HexagonTargetLayout &layout); protected: @@ -41,24 +41,23 @@ private: void addDefaultAtoms() { _hexagonRuntimeFile->addAbsoluteAtom("_SDA_BASE_"); - if (this->_context.isDynamic()) { + if (this->_ctx.isDynamic()) { _hexagonRuntimeFile->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_"); _hexagonRuntimeFile->addAbsoluteAtom("_DYNAMIC"); } } - HexagonLinkingContext &_hexagonLinkingContext; + HexagonLinkingContext &_ctx; HexagonTargetLayout &_hexagonTargetLayout; std::unique_ptr> _hexagonRuntimeFile; }; template HexagonExecutableWriter::HexagonExecutableWriter( - HexagonLinkingContext &context, HexagonTargetLayout &layout) - : ExecutableWriter(context, layout), - HexagonELFWriter(context, layout), _hexagonLinkingContext(context), - _hexagonTargetLayout(layout), - _hexagonRuntimeFile(new HexagonRuntimeFile(context)) {} + HexagonLinkingContext &ctx, HexagonTargetLayout &layout) + : ExecutableWriter(ctx, layout), HexagonELFWriter(ctx, layout), + _ctx(ctx), _hexagonTargetLayout(layout), + _hexagonRuntimeFile(new HexagonRuntimeFile(ctx)) {} template bool HexagonExecutableWriter::createImplicitFiles( Index: lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h @@ -20,9 +20,9 @@ template class SDataSection : public AtomSection { public: - SDataSection(const HexagonLinkingContext &context) + SDataSection(const HexagonLinkingContext &ctx) : AtomSection( - context, ".sdata", DefinedAtom::typeDataFast, 0, + ctx, ".sdata", DefinedAtom::typeDataFast, 0, HexagonTargetLayout::ORDER_SDATA) { this->_type = SHT_PROGBITS; this->_flags = SHF_ALLOC | SHF_WRITE; Index: lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h @@ -118,13 +118,11 @@ } std::unique_ptr getObjReader() override { - return std::unique_ptr( - new HexagonELFObjectReader(_hexagonLinkingContext)); + return std::unique_ptr(new HexagonELFObjectReader(_ctx)); } std::unique_ptr getDSOReader() override { - return std::unique_ptr( - new HexagonELFDSOReader(_hexagonLinkingContext)); + return std::unique_ptr(new HexagonELFDSOReader(_ctx)); } std::unique_ptr getWriter() override; @@ -132,7 +130,7 @@ private: llvm::BumpPtrAllocator _alloc; static const Registry::KindStrings kindStrings[]; - HexagonLinkingContext &_hexagonLinkingContext; + HexagonLinkingContext &_ctx; std::unique_ptr > _hexagonRuntimeFile; std::unique_ptr> _hexagonTargetLayout; std::unique_ptr _hexagonRelocationHandler; Index: lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp +++ lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp @@ -18,21 +18,21 @@ using llvm::makeArrayRef; -HexagonTargetHandler::HexagonTargetHandler(HexagonLinkingContext &context) - : _hexagonLinkingContext(context), - _hexagonRuntimeFile(new HexagonRuntimeFile(context)), - _hexagonTargetLayout(new HexagonTargetLayout(context)), - _hexagonRelocationHandler(new HexagonTargetRelocationHandler( - *_hexagonTargetLayout.get())) {} +HexagonTargetHandler::HexagonTargetHandler(HexagonLinkingContext &ctx) + : _ctx(ctx), + _hexagonRuntimeFile(new HexagonRuntimeFile(ctx)), + _hexagonTargetLayout(new HexagonTargetLayout(ctx)), + _hexagonRelocationHandler( + new HexagonTargetRelocationHandler(*_hexagonTargetLayout.get())) {} std::unique_ptr HexagonTargetHandler::getWriter() { - switch (_hexagonLinkingContext.getOutputELFType()) { + switch (_ctx.getOutputELFType()) { case llvm::ELF::ET_EXEC: return llvm::make_unique>( - _hexagonLinkingContext, *_hexagonTargetLayout.get()); + _ctx, *_hexagonTargetLayout.get()); case llvm::ELF::ET_DYN: return llvm::make_unique>( - _hexagonLinkingContext, *_hexagonTargetLayout.get()); + _ctx, *_hexagonTargetLayout.get()); case llvm::ELF::ET_REL: llvm_unreachable("TODO: support -r mode"); default: Index: lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h @@ -74,16 +74,16 @@ template unique_bump_ptr> MipsDynamicLibraryWriter::createSymbolTable() { - return unique_bump_ptr>(new ( - this->_alloc) MipsSymbolTable(this->_context)); + return unique_bump_ptr>( + new (this->_alloc) MipsSymbolTable(this->_ctx)); } /// \brief create dynamic table template unique_bump_ptr> MipsDynamicLibraryWriter::createDynamicTable() { - return unique_bump_ptr>(new ( - this->_alloc) MipsDynamicTable(this->_context, _mipsTargetLayout)); + return unique_bump_ptr>( + new (this->_alloc) MipsDynamicTable(this->_ctx, _mipsTargetLayout)); } /// \brief create dynamic symbol table @@ -91,8 +91,8 @@ unique_bump_ptr> MipsDynamicLibraryWriter::createDynamicSymbolTable() { return unique_bump_ptr>( - new (this->_alloc) MipsDynamicSymbolTable( - this->_context, _mipsTargetLayout)); + new (this->_alloc) + MipsDynamicSymbolTable(this->_ctx, _mipsTargetLayout)); } } // namespace elf Index: lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h +++ lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h @@ -56,7 +56,7 @@ if (ec) return ec; - StringRef entryName = this->_context.entrySymbolName(); + StringRef entryName = this->_ctx.entrySymbolName(); if (const AtomLayout *al = this->_layout.findAtomLayoutByName(entryName)) { const auto *ea = cast(al->_atom); if (ea->codeModel() == DefinedAtom::codeMipsMicro || @@ -87,8 +87,8 @@ continue; if (da->dynamicExport() != DefinedAtom::dynamicExportAlways && - !this->_context.isDynamicallyExportedSymbol(da->name()) && - !(this->_context.shouldExportDynamic() && + !this->_ctx.isDynamicallyExportedSymbol(da->name()) && + !(this->_ctx.shouldExportDynamic() && da->scope() == Atom::Scope::scopeGlobal)) continue; @@ -127,16 +127,16 @@ template unique_bump_ptr> MipsExecutableWriter::createSymbolTable() { - return unique_bump_ptr>(new ( - this->_alloc) MipsSymbolTable(this->_context)); + return unique_bump_ptr>( + new (this->_alloc) MipsSymbolTable(this->_ctx)); } /// \brief create dynamic table template unique_bump_ptr> MipsExecutableWriter::createDynamicTable() { - return unique_bump_ptr>(new ( - this->_alloc) MipsDynamicTable(this->_context, _mipsTargetLayout)); + return unique_bump_ptr>( + new (this->_alloc) MipsDynamicTable(this->_ctx, _mipsTargetLayout)); } /// \brief create dynamic symbol table @@ -144,8 +144,8 @@ unique_bump_ptr> MipsExecutableWriter::createDynamicSymbolTable() { return unique_bump_ptr>( - new (this->_alloc) MipsDynamicSymbolTable( - this->_context, _mipsTargetLayout)); + new (this->_alloc) + MipsDynamicSymbolTable(this->_ctx, _mipsTargetLayout)); } } // namespace elf Index: lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h +++ lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h @@ -139,9 +139,9 @@ ELFT::Is64Bits && ELFT::TargetEndianness == llvm::support::little; public: - MipsRelocationTable(const ELFLinkingContext &context, StringRef str, + MipsRelocationTable(const ELFLinkingContext &ctx, StringRef str, int32_t order) - : RelocationTable(context, str, order) {} + : RelocationTable(ctx, str, order) {} protected: void writeRela(ELFWriter *writer, Elf_Rela &r, const DefinedAtom &atom, @@ -150,7 +150,7 @@ r.setSymbolAndType(this->getSymbolIndex(ref.target()), rType, _isMips64EL); r.r_offset = writer->addressOfAtom(&atom) + ref.offsetInAtom(); // The addend is used only by relative relocations - if (this->_context.isRelativeReloc(ref)) + if (this->_ctx.isRelativeReloc(ref)) r.r_addend = writer->addressOfAtom(ref.target()) + ref.addend(); else r.r_addend = 0; Index: lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h +++ lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h @@ -77,9 +77,8 @@ protected: unique_bump_ptr> createRelocationTable(StringRef name, int32_t order) override { - return unique_bump_ptr>( - new (this->_allocator) - MipsRelocationTable(this->_context, name, order)); + return unique_bump_ptr>(new ( + this->_allocator) MipsRelocationTable(this->_ctx, name, order)); } private: Index: lib/ReaderWriter/ELF/OutputELFWriter.h =================================================================== --- lib/ReaderWriter/ELF/OutputELFWriter.h +++ lib/ReaderWriter/ELF/OutputELFWriter.h @@ -35,9 +35,9 @@ template class SymbolFile : public RuntimeFile { public: - SymbolFile(ELFLinkingContext &context) - : RuntimeFile(context, "Dynamic absolute symbols"), - _atomsAdded(false) {} + SymbolFile(ELFLinkingContext &ctx) + : RuntimeFile(ctx, "Dynamic absolute symbols"), _atomsAdded(false) { + } Atom *addAbsoluteAtom(StringRef symbolName) override { auto *a = RuntimeFile::addAbsoluteAtom(symbolName); @@ -59,13 +59,13 @@ class DynamicSymbolFile : public SimpleArchiveLibraryFile { typedef std::function &)> Resolver; public: - DynamicSymbolFile(ELFLinkingContext &context, Resolver resolver) + DynamicSymbolFile(ELFLinkingContext &ctx, Resolver resolver) : SimpleArchiveLibraryFile("Dynamically added runtime symbols"), - _context(context), _resolver(resolver) {} + _ctx(ctx), _resolver(resolver) {} File *find(StringRef sym, bool dataSymbolOnly) override { if (!_file) - _file.reset(new (_alloc) SymbolFile(_context)); + _file.reset(new (_alloc) SymbolFile(_ctx)); assert(!_file->hasAtoms() && "The file shouldn't have atoms yet"); _resolver(sym, *_file); @@ -74,7 +74,7 @@ } private: - ELFLinkingContext &_context; + ELFLinkingContext &_ctx; Resolver _resolver; // The allocator should go before bump pointers because of @@ -99,7 +99,7 @@ typedef Elf_Sym_Impl Elf_Sym; typedef Elf_Dyn_Impl Elf_Dyn; - OutputELFWriter(ELFLinkingContext &context, TargetLayout &layout); + OutputELFWriter(ELFLinkingContext &ctx, TargetLayout &layout); protected: // build the sections that need to be created @@ -184,7 +184,7 @@ llvm::BumpPtrAllocator _alloc; - ELFLinkingContext &_context; + ELFLinkingContext &_ctx; TargetHandler &_targetHandler; typedef llvm::DenseMap AtomToAddress; @@ -215,11 +215,10 @@ // OutputELFWriter //===----------------------------------------------------------------------===// template -OutputELFWriter::OutputELFWriter(ELFLinkingContext &context, +OutputELFWriter::OutputELFWriter(ELFLinkingContext &ctx, TargetLayout &layout) - : _context(context), _targetHandler(context.getTargetHandler()), - _layout(layout), - _scriptFile(new RuntimeFile(context, "Linker script runtime")) {} + : _ctx(ctx), _targetHandler(ctx.getTargetHandler()), _layout(layout), + _scriptFile(new RuntimeFile(ctx, "Linker script runtime")) {} template void OutputELFWriter::buildChunks(const File &file) { @@ -274,20 +273,20 @@ if (isNeededTagRequired(sla)) _soNeeded.insert(sla->loadName()); } - for (const std::unique_ptr &node : _context.getNodes()) { + for (const std::unique_ptr &node : _ctx.getNodes()) { StringRef soname = maybeGetSOName(node.get()); if (!soname.empty()) _soNeeded.insert(soname); } // Never mark the dynamic linker as DT_NEEDED - _soNeeded.erase(sys::path::filename(_context.getInterpreter())); + _soNeeded.erase(sys::path::filename(_ctx.getInterpreter())); for (const auto &loadName : _soNeeded) { Elf_Dyn dyn; dyn.d_tag = DT_NEEDED; dyn.d_un.d_val = _dynamicStringTable->addString(loadName.getKey()); _dynamicTable->addEntry(dyn); } - const auto &rpathList = _context.getRpathList(); + const auto &rpathList = _ctx.getRpathList(); if (!rpathList.empty()) { auto rpath = new (_alloc) std::string(join(rpathList.begin(), rpathList.end(), ":")); @@ -296,8 +295,8 @@ dyn.d_un.d_val = _dynamicStringTable->addString(*rpath); _dynamicTable->addEntry(dyn); } - StringRef soname = _context.sharedObjectName(); - if (!soname.empty() && _context.getOutputELFType() == llvm::ELF::ET_DYN) { + StringRef soname = _ctx.sharedObjectName(); + if (!soname.empty() && _ctx.getOutputELFType() == llvm::ELF::ET_DYN) { Elf_Dyn dyn; dyn.d_tag = DT_SONAME; dyn.d_un.d_val = _dynamicStringTable->addString(soname); @@ -367,7 +366,7 @@ template void OutputELFWriter::addDefaultAtoms() { const llvm::StringSet<> &symbols = - _context.linkerScriptSema().getScriptDefinedSymbols(); + _ctx.linkerScriptSema().getScriptDefinedSymbols(); for (auto &sym : symbols) _scriptFile->addAbsoluteAtom(sym.getKey()); } @@ -380,7 +379,7 @@ auto callback = [this](StringRef sym, RuntimeFile &file) { processUndefinedSymbol(sym, file); }; - auto &ctx = const_cast(_context); + auto &ctx = const_cast(_ctx); ctx.setUndefinesResolver( llvm::make_unique>(ctx, std::move(callback))); // Add script defined symbols @@ -391,28 +390,28 @@ template void OutputELFWriter::finalizeDefaultAtomValues() { const llvm::StringSet<> &symbols = - _context.linkerScriptSema().getScriptDefinedSymbols(); + _ctx.linkerScriptSema().getScriptDefinedSymbols(); for (auto &sym : symbols) { uint64_t res = - _context.linkerScriptSema().getLinkerScriptExprValue(sym.getKey()); + _ctx.linkerScriptSema().getLinkerScriptExprValue(sym.getKey()); auto a = _layout.findAbsoluteAtom(sym.getKey()); (*a)->_virtualAddr = res; } } template void OutputELFWriter::createDefaultSections() { - _elfHeader.reset(new (_alloc) ELFHeader(_context)); - _programHeader.reset(new (_alloc) ProgramHeader(_context)); + _elfHeader.reset(new (_alloc) ELFHeader(_ctx)); + _programHeader.reset(new (_alloc) ProgramHeader(_ctx)); _layout.setHeader(_elfHeader.get()); _layout.setProgramHeader(_programHeader.get()); _symtab = std::move(this->createSymbolTable()); _strtab.reset(new (_alloc) StringTable( - _context, ".strtab", DefaultLayout::ORDER_STRING_TABLE)); + _ctx, ".strtab", DefaultLayout::ORDER_STRING_TABLE)); _shstrtab.reset(new (_alloc) StringTable( - _context, ".shstrtab", DefaultLayout::ORDER_SECTION_STRINGS)); + _ctx, ".shstrtab", DefaultLayout::ORDER_SECTION_STRINGS)); _shdrtab.reset(new (_alloc) SectionHeader( - _context, DefaultLayout::ORDER_SECTION_HEADERS)); + _ctx, DefaultLayout::ORDER_SECTION_HEADERS)); _layout.addSection(_symtab.get()); _layout.addSection(_strtab.get()); _layout.addSection(_shstrtab.get()); @@ -426,19 +425,19 @@ if (!section || section->outputSectionName() != ".eh_frame") continue; _ehFrameHeader.reset(new (_alloc) EHFrameHeader( - _context, ".eh_frame_hdr", _layout, + _ctx, ".eh_frame_hdr", _layout, DefaultLayout::ORDER_EH_FRAMEHDR)); _layout.addSection(_ehFrameHeader.get()); break; } - if (_context.isDynamic()) { + if (_ctx.isDynamic()) { _dynamicTable = std::move(createDynamicTable()); _dynamicStringTable.reset(new (_alloc) StringTable( - _context, ".dynstr", DefaultLayout::ORDER_DYNAMIC_STRINGS, true)); + _ctx, ".dynstr", DefaultLayout::ORDER_DYNAMIC_STRINGS, true)); _dynamicSymbolTable = std::move(createDynamicSymbolTable()); _hashTable.reset(new (_alloc) HashSection( - _context, ".hash", DefaultLayout::ORDER_HASH)); + _ctx, ".hash", DefaultLayout::ORDER_HASH)); // Set the hash table in the dynamic symbol table so that the entries in the // hash table can be created _dynamicSymbolTable->setHashTable(_hashTable.get()); @@ -463,16 +462,15 @@ unique_bump_ptr> OutputELFWriter::createSymbolTable() { return unique_bump_ptr>(new (_alloc) SymbolTable( - this->_context, ".symtab", DefaultLayout::ORDER_SYMBOL_TABLE)); + this->_ctx, ".symtab", DefaultLayout::ORDER_SYMBOL_TABLE)); } /// \brief create dynamic table template unique_bump_ptr> OutputELFWriter::createDynamicTable() { - return unique_bump_ptr>( - new (_alloc) DynamicTable( - this->_context, _layout, ".dynamic", DefaultLayout::ORDER_DYNAMIC)); + return unique_bump_ptr>(new (_alloc) DynamicTable( + this->_ctx, _layout, ".dynamic", DefaultLayout::ORDER_DYNAMIC)); } /// \brief create dynamic symbol table @@ -480,9 +478,9 @@ unique_bump_ptr> OutputELFWriter::createDynamicSymbolTable() { return unique_bump_ptr>( - new (_alloc) DynamicSymbolTable( - this->_context, _layout, ".dynsym", - DefaultLayout::ORDER_DYNAMIC_SYMBOLS)); + new (_alloc) + DynamicSymbolTable(this->_ctx, _layout, ".dynsym", + DefaultLayout::ORDER_DYNAMIC_SYMBOLS)); } template @@ -498,7 +496,7 @@ _layout.assignSectionsToSegments(); // Create the dynamic table entries - if (_context.isDynamic()) { + if (_ctx.isDynamic()) { _dynamicTable->createDefaultEntries(); buildDynamicSymbolTable(file); } @@ -517,7 +515,7 @@ // Create symbol table and section string table // Do it only if -s is not specified. - if (!_context.stripSymbols()) + if (!_ctx.stripSymbols()) buildStaticSymbolTable(file); // Finalize the layout by calling the finalize() functions @@ -530,15 +528,15 @@ // for sections with no segments assignSectionsWithNoSegments(); - if (_context.isDynamic()) + if (_ctx.isDynamic()) _dynamicTable->updateDynamicTable(); return std::error_code(); } template std::error_code OutputELFWriter::setELFHeader() { - _elfHeader->e_type(_context.getOutputELFType()); - _elfHeader->e_machine(_context.getOutputMachine()); + _elfHeader->e_type(_ctx.getOutputELFType()); + _elfHeader->e_machine(_ctx.getOutputMachine()); _elfHeader->e_ident(ELF::EI_VERSION, 1); _elfHeader->e_ident(ELF::EI_OSABI, 0); _elfHeader->e_version(1); @@ -549,7 +547,7 @@ _elfHeader->e_shentsize(_shdrtab->entsize()); _elfHeader->e_shnum(_shdrtab->numHeaders()); _elfHeader->e_shstrndx(_shstrtab->ordinal()); - if (const auto *al = _layout.findAtomLayoutByName(_context.entrySymbolName())) + if (const auto *al = _layout.findAtomLayoutByName(_ctx.entrySymbolName())) _elfHeader->e_entry(al->_virtualAddr); else _elfHeader->e_entry(0); Index: lib/ReaderWriter/ELF/SectionChunks.h =================================================================== --- lib/ReaderWriter/ELF/SectionChunks.h +++ lib/ReaderWriter/ELF/SectionChunks.h @@ -39,10 +39,10 @@ /// \brief An ELF section. template class Section : public Chunk { public: - Section(const ELFLinkingContext &context, StringRef sectionName, + Section(const ELFLinkingContext &ctx, StringRef sectionName, StringRef chunkName, typename Chunk::Kind k = Chunk::Kind::ELFSection) - : Chunk(chunkName, k, context), _outputSection(nullptr), _flags(0), + : Chunk(chunkName, k, ctx), _outputSection(nullptr), _flags(0), _entSize(0), _type(0), _link(0), _info(0), _isFirstSectionInOutputSection(false), _segmentType(SHT_NULL), _inputSectionName(sectionName), _outputSectionName(sectionName) {} @@ -159,9 +159,9 @@ /// \brief A section containing atoms. template class AtomSection : public Section { public: - AtomSection(const ELFLinkingContext &context, StringRef sectionName, + AtomSection(const ELFLinkingContext &ctx, StringRef sectionName, int32_t contentType, int32_t permissions, int32_t order) - : Section(context, sectionName, "AtomSection", + : Section(ctx, sectionName, "AtomSection", Chunk::Kind::AtomSection), _contentType(contentType), _contentPermissions(permissions), _isLoadedInMemory(true) { @@ -283,10 +283,8 @@ void printError(const std::string &errorStr, const AtomLayout &atom, const Reference &ref) const { StringRef kindValStr; - if (!this->_context.registry().referenceKindToString(ref.kindNamespace(), - ref.kindArch(), - ref.kindValue(), - kindValStr)) { + if (!this->_ctx.registry().referenceKindToString( + ref.kindNamespace(), ref.kindArch(), ref.kindValue(), kindValStr)) { kindValStr = "unknown"; } @@ -429,7 +427,7 @@ uint8_t *atomContent = chunkBuffer + ai->_fileOffset; std::memcpy(atomContent, content.data(), contentSize); const TargetRelocationHandler &relHandler = - this->_context.template getTargetHandler().getRelocationHandler(); + this->_ctx.template getTargetHandler().getRelocationHandler(); for (const auto ref : *definedAtom) { if (std::error_code ec = relHandler.applyRelocation(*writer, buffer, *ai, *ref)) { @@ -599,9 +597,9 @@ }; template -StringTable::StringTable(const ELFLinkingContext &context, - const char *str, int32_t order, bool dynamic) - : Section(context, str, "StringTable") { +StringTable::StringTable(const ELFLinkingContext &ctx, const char *str, + int32_t order, bool dynamic) + : Section(ctx, str, "StringTable") { // the string table has a NULL entry for which // add an empty string _strings.push_back(""); @@ -653,7 +651,7 @@ public: typedef llvm::object::Elf_Sym_Impl Elf_Sym; - SymbolTable(const ELFLinkingContext &context, const char *str, int32_t order); + SymbolTable(const ELFLinkingContext &ctx, const char *str, int32_t order); /// \brief set the number of entries that would exist in the symbol /// table for the current link @@ -723,9 +721,9 @@ /// ELF Symbol Table template -SymbolTable::SymbolTable(const ELFLinkingContext &context, - const char *str, int32_t order) - : Section(context, str, "SymbolTable") { +SymbolTable::SymbolTable(const ELFLinkingContext &ctx, const char *str, + int32_t order) + : Section(ctx, str, "SymbolTable") { this->setOrder(order); Elf_Sym symbol; std::memset(&symbol, 0, sizeof(Elf_Sym)); @@ -907,9 +905,9 @@ template class DynamicSymbolTable : public SymbolTable { public: - DynamicSymbolTable(const ELFLinkingContext &context, - TargetLayout &layout, const char *str, int32_t order) - : SymbolTable(context, str, order), _hashTable(nullptr), + DynamicSymbolTable(const ELFLinkingContext &ctx, TargetLayout &layout, + const char *str, int32_t order) + : SymbolTable(ctx, str, order), _hashTable(nullptr), _layout(layout) { this->_type = SHT_DYNSYM; this->_flags = SHF_ALLOC; @@ -956,14 +954,13 @@ typedef llvm::object::Elf_Rel_Impl Elf_Rel; typedef llvm::object::Elf_Rel_Impl Elf_Rela; - RelocationTable(const ELFLinkingContext &context, StringRef str, - int32_t order) - : Section(context, str, "RelocationTable"), _symbolTable(nullptr) { + RelocationTable(const ELFLinkingContext &ctx, StringRef str, int32_t order) + : Section(ctx, str, "RelocationTable"), _symbolTable(nullptr) { this->setOrder(order); this->_flags = SHF_ALLOC; // Set the alignment properly depending on the target architecture this->_alignment = ELFT::Is64Bits ? 8 : 4; - if (context.isRelaOutputFormat()) { + if (ctx.isRelaOutputFormat()) { this->_entSize = sizeof(Elf_Rela); this->_type = SHT_RELA; } else { @@ -1019,7 +1016,7 @@ uint8_t *chunkBuffer = buffer.getBufferStart(); uint8_t *dest = chunkBuffer + this->fileOffset(); for (const auto &rel : _relocs) { - if (this->_context.isRelaOutputFormat()) { + if (this->_ctx.isRelaOutputFormat()) { auto &r = *reinterpret_cast(dest); writeRela(writer, r, *rel.first, *rel.second); DEBUG_WITH_TYPE("ELFRelocationTable", @@ -1049,7 +1046,7 @@ r.setSymbolAndType(getSymbolIndex(ref.target()), ref.kindValue(), false); r.r_offset = writer->addressOfAtom(&atom) + ref.offsetInAtom(); // The addend is used only by relative relocations - if (this->_context.isRelativeReloc(ref)) + if (this->_ctx.isRelativeReloc(ref)) r.r_addend = writer->addressOfAtom(ref.target()) + ref.addend(); else r.r_addend = 0; @@ -1077,9 +1074,9 @@ typedef llvm::object::Elf_Dyn_Impl Elf_Dyn; typedef std::vector EntriesT; - DynamicTable(const ELFLinkingContext &context, TargetLayout &layout, + DynamicTable(const ELFLinkingContext &ctx, TargetLayout &layout, StringRef str, int32_t order) - : Section(context, str, "DynamicSection"), _layout(layout) { + : Section(ctx, str, "DynamicSection"), _layout(layout) { this->setOrder(order); this->_entSize = sizeof(Elf_Dyn); this->_alignment = ELFT::Is64Bits ? 8 : 4; @@ -1113,7 +1110,7 @@ } virtual void createDefaultEntries() { - bool isRela = this->_context.isRelaOutputFormat(); + bool isRela = this->_ctx.isRelaOutputFormat(); Elf_Dyn dyn; dyn.d_un.d_val = 0; @@ -1280,14 +1277,14 @@ HashSection *_hashTable; const AtomLayout *getInitAtomLayout() { - auto al = _layout.findAtomLayoutByName(this->_context.initFunction()); + auto al = _layout.findAtomLayoutByName(this->_ctx.initFunction()); if (al && isa(al->_atom)) return al; return nullptr; } const AtomLayout *getFiniAtomLayout() { - auto al = _layout.findAtomLayoutByName(this->_context.finiFunction()); + auto al = _layout.findAtomLayoutByName(this->_ctx.finiFunction()); if (al && isa(al->_atom)) return al; return nullptr; @@ -1296,9 +1293,9 @@ template class InterpSection : public Section { public: - InterpSection(const ELFLinkingContext &context, StringRef str, int32_t order, + InterpSection(const ELFLinkingContext &ctx, StringRef str, int32_t order, StringRef interp) - : Section(context, str, "Dynamic:Interp"), _interp(interp) { + : Section(ctx, str, "Dynamic:Interp"), _interp(interp) { this->setOrder(order); this->_alignment = 1; // + 1 for null term. @@ -1346,8 +1343,8 @@ }; public: - HashSection(const ELFLinkingContext &context, StringRef name, int32_t order) - : Section(context, name, "Dynamic:Hash"), _symbolTable(nullptr) { + HashSection(const ELFLinkingContext &ctx, StringRef name, int32_t order) + : Section(ctx, name, "Dynamic:Hash"), _symbolTable(nullptr) { this->setOrder(order); this->_entSize = 4; this->_type = SHT_HASH; @@ -1449,9 +1446,9 @@ template class EHFrameHeader : public Section { public: - EHFrameHeader(const ELFLinkingContext &context, StringRef name, + EHFrameHeader(const ELFLinkingContext &ctx, StringRef name, TargetLayout &layout, int32_t order) - : Section(context, name, "EHFrameHeader"), _ehFrameOffset(0), + : Section(ctx, name, "EHFrameHeader"), _ehFrameOffset(0), _layout(layout) { this->setOrder(order); this->_entSize = 0; Index: lib/ReaderWriter/ELF/SegmentChunks.h =================================================================== --- lib/ReaderWriter/ELF/SegmentChunks.h +++ lib/ReaderWriter/ELF/SegmentChunks.h @@ -100,7 +100,7 @@ typedef typename std::vector *>::iterator SliceIter; typedef typename std::vector *>::iterator SectionIter; - Segment(const ELFLinkingContext &context, StringRef name, + Segment(const ELFLinkingContext &ctx, StringRef name, const Layout::SegmentType type); /// \brief the Order of segments that appear in the output file @@ -209,7 +209,7 @@ } } - int pageSize() const { return this->_context.getPageSize(); } + int pageSize() const { return this->_ctx.getPageSize(); } int rawflags() const { return _atomflags; } @@ -304,8 +304,8 @@ /// The segment doesn't contain any slice template class ProgramHeaderSegment : public Segment { public: - ProgramHeaderSegment(const ELFLinkingContext &context) - : Segment(context, "PHDR", llvm::ELF::PT_PHDR) { + ProgramHeaderSegment(const ELFLinkingContext &ctx) + : Segment(ctx, "PHDR", llvm::ELF::PT_PHDR) { this->_alignment = 8; this->_flags = (llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR); } @@ -326,13 +326,13 @@ }; template -Segment::Segment(const ELFLinkingContext &context, StringRef name, +Segment::Segment(const ELFLinkingContext &ctx, StringRef name, const Layout::SegmentType type) - : Chunk(name, Chunk::Kind::ELFSegment, context), - _segmentType(type), _flags(0), _atomflags(0) { + : Chunk(name, Chunk::Kind::ELFSegment, ctx), _segmentType(type), + _flags(0), _atomflags(0) { this->_alignment = 0; this->_fsize = 0; - _outputMagic = context.getOutputMagic(); + _outputMagic = ctx.getOutputMagic(); } // This function actually is used, but not in all instantiations of Segment. @@ -419,8 +419,8 @@ uint64_t fileOffset = startOffset; uint64_t curSliceFileOffset = fileOffset; bool isDataPageAlignedForNMagic = false; - bool alignSegments = this->_context.alignSegments(); - uint64_t p_align = this->_context.getPageSize(); + bool alignSegments = this->_ctx.alignSegments(); + uint64_t p_align = this->_ctx.getPageSize(); uint64_t lastVirtualAddress = 0; this->setFileOffset(startOffset); @@ -455,7 +455,7 @@ } } else if (!isDataPageAlignedForNMagic && needAlign(section)) { fileOffset = - llvm::RoundUpToAlignment(fileOffset, this->_context.getPageSize()); + llvm::RoundUpToAlignment(fileOffset, this->_ctx.getPageSize()); isDataPageAlignedForNMagic = true; } if (isFirstSection) { @@ -493,7 +493,7 @@ uint64_t startAddr = addr; SegmentSlice *slice = nullptr; uint64_t tlsStartAddr = 0; - bool alignSegments = this->_context.alignSegments(); + bool alignSegments = this->_ctx.alignSegments(); StringRef prevOutputSectionName = StringRef(); for (auto si = _sections.begin(); si != _sections.end(); ++si) { @@ -508,12 +508,12 @@ // Align to a page only if the output is not // OutputMagic::NMAGIC/OutputMagic::OMAGIC startAddr = - llvm::RoundUpToAlignment(startAddr, this->_context.getPageSize()); + llvm::RoundUpToAlignment(startAddr, this->_ctx.getPageSize()); else if (!isDataPageAlignedForNMagic && needAlign(*si)) { // If the linker outputmagic is set to OutputMagic::NMAGIC, align the // Data to a page boundary. startAddr = - llvm::RoundUpToAlignment(startAddr, this->_context.getPageSize()); + llvm::RoundUpToAlignment(startAddr, this->_ctx.getPageSize()); isDataPageAlignedForNMagic = true; } // align the startOffset to the section alignment @@ -549,8 +549,7 @@ // If the linker outputmagic is set to OutputMagic::NMAGIC, align the // Data // to a page boundary - curAddr = - llvm::RoundUpToAlignment(curAddr, this->_context.getPageSize()); + curAddr = llvm::RoundUpToAlignment(curAddr, this->_ctx.getPageSize()); isDataPageAlignedForNMagic = true; } uint64_t newAddr = llvm::RoundUpToAlignment(curAddr, (*si)->alignment()); @@ -577,8 +576,7 @@ // a separate segment, so that memory is not used up while running. // Dont create a slice, if the new section falls in the same output // section as the previous section. - if (autoCreateSlice && - ((newAddr - curAddr) > this->_context.getPageSize()) && + if (autoCreateSlice && ((newAddr - curAddr) > this->_ctx.getPageSize()) && (_outputMagic != ELFLinkingContext::OutputMagic::NMAGIC && _outputMagic != ELFLinkingContext::OutputMagic::OMAGIC)) { auto sliceIter = Index: lib/ReaderWriter/ELF/TargetLayout.h =================================================================== --- lib/ReaderWriter/ELF/TargetLayout.h +++ lib/ReaderWriter/ELF/TargetLayout.h @@ -20,7 +20,7 @@ /// be changed in the final layout template class TargetLayout : public DefaultLayout { public: - TargetLayout(ELFLinkingContext &context) : DefaultLayout(context) {} + TargetLayout(ELFLinkingContext &ctx) : DefaultLayout(ctx) {} }; } // end namespace elf } // end namespace lld Index: lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h @@ -18,7 +18,7 @@ template class X86DynamicLibraryWriter : public DynamicLibraryWriter { public: - X86DynamicLibraryWriter(X86LinkingContext &context, + X86DynamicLibraryWriter(X86LinkingContext &ctx, X86TargetLayout &layout); protected: @@ -41,15 +41,15 @@ }; std::unique_ptr _gotFile; - X86LinkingContext &_context; + X86LinkingContext &_ctx; X86TargetLayout &_x86Layout; }; template X86DynamicLibraryWriter::X86DynamicLibraryWriter( - X86LinkingContext &context, X86TargetLayout &layout) - : DynamicLibraryWriter(context, layout), - _gotFile(new GOTFile(context)), _context(context), _x86Layout(layout) {} + X86LinkingContext &ctx, X86TargetLayout &layout) + : DynamicLibraryWriter(ctx, layout), _gotFile(new GOTFile(ctx)), + _ctx(ctx), _x86Layout(layout) {} template bool X86DynamicLibraryWriter::createImplicitFiles( Index: lib/ReaderWriter/ELF/X86/X86ExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/X86/X86ExecutableWriter.h +++ lib/ReaderWriter/ELF/X86/X86ExecutableWriter.h @@ -18,8 +18,7 @@ template class X86ExecutableWriter : public ExecutableWriter { public: - X86ExecutableWriter(X86LinkingContext &context, - X86TargetLayout &layout); + X86ExecutableWriter(X86LinkingContext &ctx, X86TargetLayout &layout); protected: // Add any runtime files and their atoms to the output @@ -34,15 +33,14 @@ } private: - X86LinkingContext &_context; + X86LinkingContext &_ctx; X86TargetLayout &_x86Layout; }; template -X86ExecutableWriter::X86ExecutableWriter(X86LinkingContext &context, +X86ExecutableWriter::X86ExecutableWriter(X86LinkingContext &ctx, X86TargetLayout &layout) - : ExecutableWriter(context, layout), _context(context), - _x86Layout(layout) {} + : ExecutableWriter(ctx, layout), _ctx(ctx), _x86Layout(layout) {} template bool X86ExecutableWriter::createImplicitFiles( Index: lib/ReaderWriter/ELF/X86/X86TargetHandler.h =================================================================== --- lib/ReaderWriter/ELF/X86/X86TargetHandler.h +++ lib/ReaderWriter/ELF/X86/X86TargetHandler.h @@ -23,13 +23,13 @@ template class X86TargetLayout : public TargetLayout { public: - X86TargetLayout(X86LinkingContext &context) : TargetLayout(context) {} + X86TargetLayout(X86LinkingContext &ctx) : TargetLayout(ctx) {} }; class X86TargetHandler final : public DefaultTargetHandler { public: - X86TargetHandler(X86LinkingContext &context); + X86TargetHandler(X86LinkingContext &ctx); X86TargetLayout &getTargetLayout() override { return *(_x86TargetLayout.get()); @@ -42,18 +42,18 @@ } std::unique_ptr getObjReader() override { - return llvm::make_unique(_x86LinkingContext); + return llvm::make_unique(_ctx); } std::unique_ptr getDSOReader() override { - return llvm::make_unique(_x86LinkingContext); + return llvm::make_unique(_ctx); } std::unique_ptr getWriter() override; protected: static const Registry::KindStrings kindStrings[]; - X86LinkingContext &_x86LinkingContext; + X86LinkingContext &_ctx; std::unique_ptr> _x86TargetLayout; std::unique_ptr _x86RelocationHandler; }; Index: lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp +++ lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp @@ -19,13 +19,13 @@ using namespace llvm::ELF; std::unique_ptr X86TargetHandler::getWriter() { - switch (_x86LinkingContext.getOutputELFType()) { + switch (_ctx.getOutputELFType()) { case llvm::ELF::ET_EXEC: return llvm::make_unique>( - _x86LinkingContext, *_x86TargetLayout.get()); + _ctx, *_x86TargetLayout.get()); case llvm::ELF::ET_DYN: return llvm::make_unique>( - _x86LinkingContext, *_x86TargetLayout.get()); + _ctx, *_x86TargetLayout.get()); case llvm::ELF::ET_REL: llvm_unreachable("TODO: support -r mode"); default: @@ -47,7 +47,6 @@ kindStrings); } -X86TargetHandler::X86TargetHandler(X86LinkingContext &context) - : _x86LinkingContext(context), - _x86TargetLayout(new X86TargetLayout(context)), +X86TargetHandler::X86TargetHandler(X86LinkingContext &ctx) + : _ctx(ctx), _x86TargetLayout(new X86TargetLayout(ctx)), _x86RelocationHandler(new X86TargetRelocationHandler()) {} Index: lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h @@ -19,7 +19,7 @@ class X86_64DynamicLibraryWriter : public DynamicLibraryWriter { public: - X86_64DynamicLibraryWriter(X86_64LinkingContext &context, + X86_64DynamicLibraryWriter(X86_64LinkingContext &ctx, X86_64TargetLayout &layout); protected: @@ -45,8 +45,8 @@ }; X86_64DynamicLibraryWriter::X86_64DynamicLibraryWriter( - X86_64LinkingContext &context, X86_64TargetLayout &layout) - : DynamicLibraryWriter(context, layout), _gotFile(new GOTFile(context)) {} + X86_64LinkingContext &ctx, X86_64TargetLayout &layout) + : DynamicLibraryWriter(ctx, layout), _gotFile(new GOTFile(ctx)) {} bool X86_64DynamicLibraryWriter::createImplicitFiles( std::vector> &result) { Index: lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h +++ lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h @@ -18,10 +18,8 @@ class X86_64ExecutableWriter : public ExecutableWriter { public: - X86_64ExecutableWriter(X86_64LinkingContext &context, - X86_64TargetLayout &layout) - : ExecutableWriter(context, layout), _gotFile(new GOTFile(context)), - _context(context) {} + X86_64ExecutableWriter(X86_64LinkingContext &ctx, X86_64TargetLayout &layout) + : ExecutableWriter(ctx, layout), _gotFile(new GOTFile(ctx)), _ctx(ctx) {} protected: // Add any runtime files and their atoms to the output @@ -30,7 +28,7 @@ ExecutableWriter::createImplicitFiles(result); _gotFile->addAtom(*new (_gotFile->_alloc) GLOBAL_OFFSET_TABLEAtom(*_gotFile)); - if (_context.isDynamic()) + if (_ctx.isDynamic()) _gotFile->addAtom(*new (_gotFile->_alloc) DYNAMICAtom(*_gotFile)); result.push_back(std::move(_gotFile)); return true; @@ -52,7 +50,7 @@ }; std::unique_ptr _gotFile; - X86_64LinkingContext &_context; + X86_64LinkingContext &_ctx; }; } // namespace elf Index: lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h +++ lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h @@ -22,8 +22,7 @@ namespace elf { class X86_64TargetLayout : public TargetLayout { public: - X86_64TargetLayout(X86_64LinkingContext &context) - : TargetLayout(context) {} + X86_64TargetLayout(X86_64LinkingContext &ctx) : TargetLayout(ctx) {} void finalizeOutputSectionLayout() override { sortOutputSectionByPriority(".init_array", ".init_array"); @@ -34,7 +33,7 @@ class X86_64TargetHandler : public DefaultTargetHandler { public: - X86_64TargetHandler(X86_64LinkingContext &context); + X86_64TargetHandler(X86_64LinkingContext &ctx); X86_64TargetLayout &getTargetLayout() override { return *(_x86_64TargetLayout.get()); @@ -47,18 +46,18 @@ } std::unique_ptr getObjReader() override { - return llvm::make_unique(_context); + return llvm::make_unique(_ctx); } std::unique_ptr getDSOReader() override { - return llvm::make_unique(_context); + return llvm::make_unique(_ctx); } std::unique_ptr getWriter() override; protected: static const Registry::KindStrings kindStrings[]; - X86_64LinkingContext &_context; + X86_64LinkingContext &_ctx; std::unique_ptr _x86_64TargetLayout; std::unique_ptr _x86_64RelocationHandler; }; Index: lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp +++ lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp @@ -16,8 +16,8 @@ using namespace lld; using namespace elf; -X86_64TargetHandler::X86_64TargetHandler(X86_64LinkingContext &context) - : _context(context), _x86_64TargetLayout(new X86_64TargetLayout(context)), +X86_64TargetHandler::X86_64TargetHandler(X86_64LinkingContext &ctx) + : _ctx(ctx), _x86_64TargetLayout(new X86_64TargetLayout(ctx)), _x86_64RelocationHandler( new X86_64TargetRelocationHandler(*_x86_64TargetLayout.get())) {} @@ -27,13 +27,13 @@ } std::unique_ptr X86_64TargetHandler::getWriter() { - switch (this->_context.getOutputELFType()) { + switch (this->_ctx.getOutputELFType()) { case llvm::ELF::ET_EXEC: return llvm::make_unique( - _context, *_x86_64TargetLayout.get()); + _ctx, *_x86_64TargetLayout.get()); case llvm::ELF::ET_DYN: return llvm::make_unique( - _context, *_x86_64TargetLayout.get()); + _ctx, *_x86_64TargetLayout.get()); case llvm::ELF::ET_REL: llvm_unreachable("TODO: support -r mode"); default: