/// Emit this directive in @p OutStream using the information available
/// in the given @p ObjWriter and @p Layout to get the address of the
/// arguments within the object file.
- /// This function is currently specialized for T = MCSymbol.
void Emit_impl(raw_ostream &OutStream, const MachObjectWriter &ObjWriter,
const MCAsmLayout &Layout) const;
/// the given @p Layout.
uint64_t getEmitSize(const MachObjectWriter &ObjWriter,
const MCAsmLayout &Layout) const {
- std::string Buffer;
- raw_string_ostream OutStream(Buffer);
+ 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() { flush(); }
+ };
+
+ raw_counting_ostream OutStream;
Emit_impl(OutStream, ObjWriter, Layout);
return OutStream.tell();
}