Index: llvm/lib/MC/ELFObjectWriter.cpp =================================================================== --- llvm/lib/MC/ELFObjectWriter.cpp +++ llvm/lib/MC/ELFObjectWriter.cpp @@ -215,9 +215,6 @@ }; class ELFObjectWriter : public MCObjectWriter { - raw_pwrite_stream &OS; - bool IsLittleEndian; - /// The target specific ELF writer instance. std::unique_ptr TargetObjectWriter; @@ -233,10 +230,8 @@ unsigned Type) const; public: - ELFObjectWriter(std::unique_ptr MOTW, - raw_pwrite_stream &OS, bool IsLittleEndian) - : OS(OS), IsLittleEndian(IsLittleEndian), - TargetObjectWriter(std::move(MOTW)) {} + ELFObjectWriter(std::unique_ptr MOTW) + : TargetObjectWriter(std::move(MOTW)) {} void reset() override { Relocations.clear(); @@ -256,16 +251,27 @@ const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) override; - uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override { - return ELFWriter(*this, OS, IsLittleEndian).writeObject(Asm, Layout); - } - void executePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout) override; friend struct ELFWriter; }; +class ELFSingleObjectWriter : public ELFObjectWriter { + raw_pwrite_stream &OS; + bool IsLittleEndian; + +public: + ELFSingleObjectWriter(std::unique_ptr MOTW, + raw_pwrite_stream &OS, bool IsLittleEndian) + : ELFObjectWriter(std::move(MOTW)), OS(OS), + IsLittleEndian(IsLittleEndian) {} + + uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override { + return ELFWriter(*this, OS, IsLittleEndian).writeObject(Asm, Layout); + } +}; + } // end anonymous namespace void ELFWriter::align(unsigned Alignment) { @@ -1380,6 +1386,6 @@ std::unique_ptr llvm::createELFObjectWriter(std::unique_ptr MOTW, raw_pwrite_stream &OS, bool IsLittleEndian) { - return llvm::make_unique(std::move(MOTW), OS, - IsLittleEndian); + return llvm::make_unique(std::move(MOTW), OS, + IsLittleEndian); }