diff options
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCCodeView.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/MC/MCDwarf.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/MC/MCLinkerOptimizationHint.cpp | 26 |
3 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp index 2d8ef442f75..d3f2aa2a80c 100644 --- a/llvm/lib/MC/MCCodeView.cpp +++ b/llvm/lib/MC/MCCodeView.cpp @@ -21,6 +21,7 @@ #include "llvm/MC/MCObjectStreamer.h" #include "llvm/MC/MCValue.h" #include "llvm/Support/COFF.h" +#include "llvm/Support/EndianStream.h" using namespace llvm; using namespace llvm::codeview; diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index 47f002f619b..57252a07d9e 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -22,6 +22,7 @@ #include "llvm/MC/MCSection.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/EndianStream.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/Path.h" diff --git a/llvm/lib/MC/MCLinkerOptimizationHint.cpp b/llvm/lib/MC/MCLinkerOptimizationHint.cpp index 5f6a57980ad..9dd1439f0fb 100644 --- a/llvm/lib/MC/MCLinkerOptimizationHint.cpp +++ b/llvm/lib/MC/MCLinkerOptimizationHint.cpp @@ -10,6 +10,7 @@ #include "llvm/MC/MCLinkerOptimizationHint.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCMachObjectWriter.h" #include "llvm/Support/LEB128.h" using namespace llvm; @@ -31,3 +32,28 @@ void MCLOHDirective::emit_impl(raw_ostream &OutStream, It != EndIt; ++It) encodeULEB128(ObjWriter.getSymbolAddress(**It, Layout), OutStream); } + +void MCLOHDirective::emit(MachObjectWriter &ObjWriter, + const MCAsmLayout &Layout) const { + raw_ostream &OutStream = ObjWriter.getStream(); + emit_impl(OutStream, ObjWriter, Layout); +} + +uint64_t MCLOHDirective::getEmitSize(const MachObjectWriter &ObjWriter, + const MCAsmLayout &Layout) const { + class raw_counting_ostream : public raw_ostream { + uint64_t Count; + + void write_impl(const char *, size_t size) override { Count += size; } + + uint64_t current_pos() const override { return Count; } + + public: + raw_counting_ostream() : Count(0) {} + ~raw_counting_ostream() override { flush(); } + }; + + raw_counting_ostream OutStream; + emit_impl(OutStream, ObjWriter, Layout); + return OutStream.tell(); +} |