[llvm] r332870 - MC: Extract a derived class from ELFObjectWriter. NFCI.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon May 21 12:30:59 PDT 2018
Author: pcc
Date: Mon May 21 12:30:59 2018
New Revision: 332870
URL: http://llvm.org/viewvc/llvm-project?rev=332870&view=rev
Log:
MC: Extract a derived class from ELFObjectWriter. NFCI.
This class will be used to create regular, non-split ELF files.
Part of PR37466.
Differential Revision: https://reviews.llvm.org/D47049
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=332870&r1=332869&r2=332870&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon May 21 12:30:59 2018
@@ -215,9 +215,6 @@ public:
};
class ELFObjectWriter : public MCObjectWriter {
- raw_pwrite_stream &OS;
- bool IsLittleEndian;
-
/// The target specific ELF writer instance.
std::unique_ptr<MCELFObjectTargetWriter> TargetObjectWriter;
@@ -233,10 +230,8 @@ class ELFObjectWriter : public MCObjectW
unsigned Type) const;
public:
- ELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW,
- raw_pwrite_stream &OS, bool IsLittleEndian)
- : OS(OS), IsLittleEndian(IsLittleEndian),
- TargetObjectWriter(std::move(MOTW)) {}
+ ELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW)
+ : TargetObjectWriter(std::move(MOTW)) {}
void reset() override {
Relocations.clear();
@@ -253,16 +248,27 @@ public:
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<MCELFObjectTargetWriter> 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) {
@@ -1374,6 +1380,6 @@ bool ELFObjectWriter::isSymbolRefDiffere
std::unique_ptr<MCObjectWriter>
llvm::createELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW,
raw_pwrite_stream &OS, bool IsLittleEndian) {
- return llvm::make_unique<ELFObjectWriter>(std::move(MOTW), OS,
- IsLittleEndian);
+ return llvm::make_unique<ELFSingleObjectWriter>(std::move(MOTW), OS,
+ IsLittleEndian);
}
More information about the llvm-commits
mailing list