LLVM: include/llvm/MC/MCELFObjectWriter.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_MC_MCELFOBJECTWRITER_H
10#define LLVM_MC_MCELFOBJECTWRITER_H
11
20#include
21#include
22#include
23#include
24
25namespace llvm {
26
34
40
44
49
51};
52
57 const unsigned HasRelocationAddend : 1;
58 const unsigned Is64Bit : 1;
59
60protected:
62 bool HasRelocationAddend_, uint8_t ABIVersion_ = 0);
63
64public:
66
71
73 switch (OSType) {
83 default:
85 }
86 }
87
89 bool IsPCRel) const = 0;
90
94
95 virtual void sortRelocs(std::vector &Relocs);
96
97
98
103 bool is64Bit() const { return Is64Bit; }
104
105
106
107
108#define R_TYPE_SHIFT 0
109#define R_TYPE_MASK 0xffffff00
110#define R_TYPE2_SHIFT 8
111#define R_TYPE2_MASK 0xffff00ff
112#define R_TYPE3_SHIFT 16
113#define R_TYPE3_MASK 0xff00ffff
114#define R_SSYM_SHIFT 24
115#define R_SSYM_MASK 0x00ffffff
116
117
130
131
132 static unsigned setRTypes(unsigned Value1, unsigned Value2, unsigned Value3) {
136 }
140};
141
143 unsigned ELFHeaderEFlags = 0;
144
145public:
149
152
157
166
167 ELFObjectWriter(std::unique_ptr MOTW,
169 ELFObjectWriter(std::unique_ptr MOTW,
172
173 void reset() override;
180 bool IsPCRel) const override;
182
185
187 unsigned Type) const;
188
191
194
195
198
199
201};
202}
203
204#endif
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines the DenseMap class.
#define R_TYPE2_SHIFT
Definition MCELFObjectWriter.h:110
#define R_SSYM_MASK
Definition MCELFObjectWriter.h:115
#define R_TYPE_SHIFT
Definition MCELFObjectWriter.h:108
#define R_TYPE3_SHIFT
Definition MCELFObjectWriter.h:112
#define R_SSYM_SHIFT
Definition MCELFObjectWriter.h:114
PowerPC TLS Dynamic Call Fixup
This file defines the SmallVector class.
std::unique_ptr< MCELFObjectTargetWriter > TargetObjectWriter
Definition MCELFObjectWriter.h:146
ELFObjectWriter(std::unique_ptr< MCELFObjectTargetWriter > MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
void setAssembler(MCAssembler *Asm) override
SmallVector< const MCSymbolELF *, 0 > Weakrefs
Definition MCELFObjectWriter.h:153
bool checkRelocation(SMLoc Loc, const MCSectionELF *From, const MCSectionELF *To)
void markGnuAbi()
Definition MCELFObjectWriter.h:196
unsigned getELFHeaderEFlags() const
Definition MCELFObjectWriter.h:192
void reset() override
lifetime management
void setELFHeaderEFlags(unsigned Flags)
Definition MCELFObjectWriter.h:193
void setOverrideABIVersion(uint8_t V)
Definition MCELFObjectWriter.h:200
bool SeenGnuAbi
Definition MCELFObjectWriter.h:155
std::optional< uint8_t > OverrideABIVersion
Definition MCELFObjectWriter.h:156
uint64_t writeObject() override
Write the object file and returns the number of bytes written.
bool seenGnuAbi() const
Definition MCELFObjectWriter.h:197
DenseMap< const MCSectionELF *, std::vector< ELFRelocationEntry > > Relocations
Definition MCELFObjectWriter.h:150
void executePostLayoutBinding() override
Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...
bool IsLittleEndian
Definition MCELFObjectWriter.h:154
bool isSymbolRefDifferenceFullyResolvedImpl(const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override
SmallVector< Symver, 0 > Symvers
Definition MCELFObjectWriter.h:165
raw_pwrite_stream & OS
Definition MCELFObjectWriter.h:147
bool hasRelocationAddend() const
void recordRelocation(const MCFragment &F, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) override
Record a relocation entry.
raw_pwrite_stream * DwoOS
Definition MCELFObjectWriter.h:148
bool usesRela(const MCTargetOptions *TO, const MCSectionELF &Sec) const
bool useSectionSymbol(const MCValue &Val, const MCSymbolELF *Sym, uint64_t C, unsigned Type) const
DenseMap< const MCSymbolELF *, const MCSymbolELF * > Renames
Definition MCELFObjectWriter.h:151
Context object for machine code objects.
static bool classof(const MCObjectTargetWriter *W)
Definition MCELFObjectWriter.h:68
virtual unsigned getRelocType(const MCFixup &Fixup, const MCValue &Target, bool IsPCRel) const =0
bool hasRelocationAddend() const
Definition MCELFObjectWriter.h:102
Triple::ObjectFormatType getFormat() const override
Definition MCELFObjectWriter.h:67
~MCELFObjectTargetWriter() override=default
uint8_t getABIVersion() const
Definition MCELFObjectWriter.h:100
static unsigned setRTypes(unsigned Value1, unsigned Value2, unsigned Value3)
Definition MCELFObjectWriter.h:132
uint8_t getRType(uint32_t Type) const
Definition MCELFObjectWriter.h:118
uint8_t getRSsym(uint32_t Type) const
Definition MCELFObjectWriter.h:127
uint8_t getOSABI() const
Definition MCELFObjectWriter.h:99
virtual bool needsRelocateWithSymbol(const MCValue &, unsigned Type) const
Definition MCELFObjectWriter.h:91
uint16_t getEMachine() const
Definition MCELFObjectWriter.h:101
static uint8_t getOSABI(Triple::OSType OSType)
Definition MCELFObjectWriter.h:72
unsigned setRSsym(unsigned Value, unsigned Type) const
Definition MCELFObjectWriter.h:137
virtual void sortRelocs(std::vector< ELFRelocationEntry > &Relocs)
MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_, uint16_t EMachine_, bool HasRelocationAddend_, uint8_t ABIVersion_=0)
bool is64Bit() const
Definition MCELFObjectWriter.h:103
uint8_t getRType2(uint32_t Type) const
Definition MCELFObjectWriter.h:121
uint8_t getRType3(uint32_t Type) const
Definition MCELFObjectWriter.h:124
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Base class for classes that define behaviour that is specific to both the target and the object forma...
This represents a section on linux, lots of unix variants and some bare metal systems.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Represents a location in source code.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
An abstract base class for streams implementations that also support a pwrite operation.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
SMLoc Loc
Definition MCELFObjectWriter.h:159
bool KeepOriginalSym
Definition MCELFObjectWriter.h:163
const MCSymbol * Sym
Definition MCELFObjectWriter.h:160
StringRef Name
Definition MCELFObjectWriter.h:161
ELFRelocationEntry(uint64_t Offset, const MCSymbolELF *Symbol, unsigned Type, uint64_t Addend)
Definition MCELFObjectWriter.h:41
uint64_t Offset
Definition MCELFObjectWriter.h:36
uint64_t Addend
Definition MCELFObjectWriter.h:39
unsigned Type
Definition MCELFObjectWriter.h:38
const MCSymbolELF * Symbol
Definition MCELFObjectWriter.h:37
void print(raw_ostream &Out) const
Definition MCELFObjectWriter.h:45
LLVM_DUMP_METHOD void dump() const
Definition MCELFObjectWriter.h:50