diff --git a/llvm/include/llvm/MC/MCWinCOFFObjectWriter.h b/llvm/include/llvm/MC/MCWinCOFFObjectWriter.h --- a/llvm/include/llvm/MC/MCWinCOFFObjectWriter.h +++ b/llvm/include/llvm/MC/MCWinCOFFObjectWriter.h @@ -20,37 +20,37 @@ class MCValue; class raw_pwrite_stream; - class MCWinCOFFObjectTargetWriter : public MCObjectTargetWriter { - virtual void anchor(); - - const unsigned Machine; - - protected: - MCWinCOFFObjectTargetWriter(unsigned Machine_); - - public: - virtual ~MCWinCOFFObjectTargetWriter() = default; - - Triple::ObjectFormatType getFormat() const override { return Triple::COFF; } - static bool classof(const MCObjectTargetWriter *W) { - return W->getFormat() == Triple::COFF; - } - - unsigned getMachine() const { return Machine; } - virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target, - const MCFixup &Fixup, bool IsCrossSection, - const MCAsmBackend &MAB) const = 0; - virtual bool recordRelocation(const MCFixup &) const { return true; } - }; - - /// Construct a new Win COFF writer instance. - /// - /// \param MOTW - The target specific WinCOFF writer subclass. - /// \param OS - The stream to write to. - /// \returns The constructed object writer. - std::unique_ptr - createWinCOFFObjectWriter(std::unique_ptr MOTW, - raw_pwrite_stream &OS); +class MCWinCOFFObjectTargetWriter : public MCObjectTargetWriter { + virtual void anchor(); + + const unsigned Machine; + +protected: + MCWinCOFFObjectTargetWriter(unsigned Machine_); + +public: + virtual ~MCWinCOFFObjectTargetWriter() = default; + + Triple::ObjectFormatType getFormat() const override { return Triple::COFF; } + static bool classof(const MCObjectTargetWriter *W) { + return W->getFormat() == Triple::COFF; + } + + unsigned getMachine() const { return Machine; } + virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target, + const MCFixup &Fixup, bool IsCrossSection, + const MCAsmBackend &MAB) const = 0; + virtual bool recordRelocation(const MCFixup &) const { return true; } +}; + +/// Construct a new Win COFF writer instance. +/// +/// \param MOTW - The target specific WinCOFF writer subclass. +/// \param OS - The stream to write to. +/// \returns The constructed object writer. +std::unique_ptr +createWinCOFFObjectWriter(std::unique_ptr MOTW, + raw_pwrite_stream &OS); } // end namespace llvm #endif // LLVM_MC_MCWINCOFFOBJECTWRITER_H diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp --- a/llvm/lib/MC/WinCOFFObjectWriter.cpp +++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp @@ -59,11 +59,7 @@ using name = SmallString; -enum AuxiliaryType { - ATWeakExternal, - ATFile, - ATSectionDefinition -}; +enum AuxiliaryType { ATWeakExternal, ATFile, ATSectionDefinition }; struct AuxSymbol { AuxiliaryType AuxType; @@ -434,8 +430,8 @@ // If no storage class was specified in the streamer, define it here. if (Local->Data.StorageClass == COFF::IMAGE_SYM_CLASS_NULL) { - bool IsExternal = MCSym.isExternal() || - (!MCSym.getFragment() && !MCSym.isVariable()); + bool IsExternal = + MCSym.isExternal() || (!MCSym.getFragment() && !MCSym.isVariable()); Local->Data.StorageClass = IsExternal ? COFF::IMAGE_SYM_CLASS_EXTERNAL : COFF::IMAGE_SYM_CLASS_STATIC; @@ -523,7 +519,7 @@ break; case ATFile: W.OS.write(reinterpret_cast(&i.Aux), - UseBigObj ? COFF::Symbol32Size : COFF::Symbol16Size); + UseBigObj ? COFF::Symbol32Size : COFF::Symbol16Size); break; case ATSectionDefinition: W.write(i.Aux.SectionDefinition.Length); @@ -533,7 +529,8 @@ W.write(static_cast(i.Aux.SectionDefinition.Number)); W.OS << char(i.Aux.SectionDefinition.Selection); W.OS.write_zeros(sizeof(i.Aux.SectionDefinition.unused)); - W.write(static_cast(i.Aux.SectionDefinition.Number >> 16)); + W.write( + static_cast(i.Aux.SectionDefinition.Number >> 16)); if (UseBigObj) W.OS.write_zeros(COFF::Symbol32Size - COFF::Symbol16Size); break; @@ -699,15 +696,15 @@ const MCSymbol &A = Target.getSymA()->getSymbol(); if (!A.isRegistered()) { - Asm.getContext().reportError(Fixup.getLoc(), - Twine("symbol '") + A.getName() + - "' can not be undefined"); + Asm.getContext().reportError(Fixup.getLoc(), Twine("symbol '") + + A.getName() + + "' can not be undefined"); return; } if (A.isTemporary() && A.isUndefined()) { - Asm.getContext().reportError(Fixup.getLoc(), - Twine("assembler label '") + A.getName() + - "' can not be undefined"); + Asm.getContext().reportError(Fixup.getLoc(), Twine("assembler label '") + + A.getName() + + "' can not be undefined"); return; }