From 438390fae1f0f6125b914e5f1bd4ef2e7deb8c05 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 21 May 2018 18:23:50 +0000 Subject: MC: Have the object writers return the number of bytes written. NFCI. This removes the last external use of the stream. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47042 llvm-svn: 332863 --- llvm/lib/MC/ELFObjectWriter.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'llvm/lib/MC/ELFObjectWriter.cpp') diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index e5014e64043..9826996c571 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -247,7 +247,7 @@ public: const MCFragment &FB, bool InSet, bool IsPCRel) const override; - void writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override; + uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override; void writeSection(const SectionIndexMapTy &SectionIndexMap, uint32_t GroupSymbolIndex, uint64_t Offset, uint64_t Size, const MCSectionELF &Section); @@ -1205,8 +1205,10 @@ void ELFObjectWriter::writeSectionHeader( } } -void ELFObjectWriter::writeObject(MCAssembler &Asm, - const MCAsmLayout &Layout) { +uint64_t ELFObjectWriter::writeObject(MCAssembler &Asm, + const MCAsmLayout &Layout) { + uint64_t StartOffset = W.OS.tell(); + MCContext &Ctx = Asm.getContext(); MCSectionELF *StrtabSection = Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0); @@ -1334,6 +1336,8 @@ void ELFObjectWriter::writeObject(MCAssembler &Asm, } Stream.pwrite(reinterpret_cast(&NumSections), sizeof(NumSections), NumSectionsOffset); + + return W.OS.tell() - StartOffset; } bool ELFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl( -- cgit v1.2.3