LLVM 22.0.0git
MCWinCOFFObjectWriter.h
Go to the documentation of this file.
1//===- llvm/MC/MCWinCOFFObjectWriter.h - Win COFF Object Writer -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_MC_MCWINCOFFOBJECTWRITER_H
10#define LLVM_MC_MCWINCOFFOBJECTWRITER_H
11
13#include <memory>
14
15namespace llvm {
16
17class MCAsmBackend;
18class MCContext;
19class MCFixup;
20class MCValue;
22
24 virtual void anchor();
25
26 const unsigned Machine;
27
28protected:
29 MCWinCOFFObjectTargetWriter(unsigned Machine_);
30
31public:
32 virtual ~MCWinCOFFObjectTargetWriter() = default;
33
34 Triple::ObjectFormatType getFormat() const override { return Triple::COFF; }
35 static bool classof(const MCObjectTargetWriter *W) {
36 return W->getFormat() == Triple::COFF;
37 }
38
39 unsigned getMachine() const { return Machine; }
40 virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
41 const MCFixup &Fixup, bool IsCrossSection,
42 const MCAsmBackend &MAB) const = 0;
43 virtual bool recordRelocation(const MCFixup &) const { return true; }
44};
45
46class WinCOFFWriter;
47
48class WinCOFFObjectWriter final : public MCObjectWriter {
49 friend class WinCOFFWriter;
50
51 std::unique_ptr<MCWinCOFFObjectTargetWriter> TargetObjectWriter;
52 std::unique_ptr<WinCOFFWriter> ObjWriter, DwoWriter;
53 bool IncrementalLinkerCompatible = false;
54
55public:
56 WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
58 WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
60
61 // MCObjectWriter interface implementation.
62 void reset() override;
63 void setAssembler(MCAssembler *Asm) override;
65 IncrementalLinkerCompatible = Value;
66 }
67 void executePostLayoutBinding() override;
69 const MCFragment &FB, bool InSet,
70 bool IsPCRel) const override;
71 void recordRelocation(const MCFragment &F, const MCFixup &Fixup,
72 MCValue Target, uint64_t &FixedValue) override;
73 uint64_t writeObject() override;
74 int getSectionNumber(const MCSection &Section) const;
75};
76
77/// Construct a new Win COFF writer instance.
78///
79/// \param MOTW - The target specific WinCOFF writer subclass.
80/// \param OS - The stream to write to.
81/// \returns The constructed object writer.
82std::unique_ptr<MCObjectWriter>
83createWinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
84 raw_pwrite_stream &OS);
85
86std::unique_ptr<MCObjectWriter>
87createWinCOFFDwoObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
88 raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS);
89} // end namespace llvm
90
91#endif // LLVM_MC_MCWINCOFFOBJECTWRITER_H
#define F(x, y, z)
Definition MD5.cpp:55
PowerPC TLS Dynamic Call Fixup
Generic interface to target specific assembler backends.
Context object for machine code objects.
Definition MCContext.h:83
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:61
Base class for classes that define behaviour that is specific to both the target and the object forma...
MCObjectWriter()=default
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:521
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
virtual bool recordRelocation(const MCFixup &) const
static bool classof(const MCObjectTargetWriter *W)
virtual ~MCWinCOFFObjectTargetWriter()=default
virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target, const MCFixup &Fixup, bool IsCrossSection, const MCAsmBackend &MAB) const =0
Triple::ObjectFormatType getFormat() const override
Target - Wrapper for Target specific information.
LLVM Value Representation.
Definition Value.h:75
void recordRelocation(const MCFragment &F, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) override
Record a relocation entry.
void reset() override
lifetime management
int getSectionNumber(const MCSection &Section) const
void setAssembler(MCAssembler *Asm) override
WinCOFFObjectWriter(std::unique_ptr< MCWinCOFFObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
void executePostLayoutBinding() override
Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...
uint64_t writeObject() override
Write the object file and returns the number of bytes written.
void setIncrementalLinkerCompatible(bool Value)
bool isSymbolRefDifferenceFullyResolvedImpl(const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override
An abstract base class for streams implementations that also support a pwrite operation.
This is an optimization pass for GlobalISel generic memory operations.
std::unique_ptr< MCObjectWriter > createWinCOFFDwoObjectWriter(std::unique_ptr< MCWinCOFFObjectTargetWriter > MOTW, raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS)
std::unique_ptr< MCObjectWriter > createWinCOFFObjectWriter(std::unique_ptr< MCWinCOFFObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
Construct a new Win COFF writer instance.