29 void recordARMScatteredRelocation(MachObjectWriter *Writer,
30 const MCAssembler &Asm,
31 const MCFragment *Fragment,
32 const MCFixup &
Fixup, MCValue Target,
33 unsigned Type,
unsigned Log2Size,
34 uint64_t &FixedValue);
35 void recordARMScatteredHalfRelocation(MachObjectWriter *Writer,
36 const MCAssembler &Asm,
37 const MCFragment *Fragment,
38 const MCFixup &
Fixup, MCValue Target,
39 uint64_t &FixedValue);
41 bool requiresExternRelocation(MachObjectWriter *Writer,
42 const MCAssembler &Asm,
43 const MCFragment &Fragment,
unsigned RelocType,
44 const MCSymbol &S, uint64_t FixedValue);
47 ARMMachObjectWriter(
bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
48 : MCMachObjectTargetWriter(Is64Bit,
CPUType, CPUSubtype) {}
50 void recordRelocation(MachObjectWriter *Writer, MCAssembler &Asm,
51 const MCFragment *Fragment,
const MCFixup &
Fixup,
52 MCValue Target, uint64_t &FixedValue)
override;
133void ARMMachObjectWriter::recordARMScatteredHalfRelocation(
137 uint32_t FixupOffset =
Asm.getFragmentOffset(*Fragment) +
Fixup.getOffset();
139 if (FixupOffset & 0xff000000) {
142 "' in resulting scattered relocation.");
146 unsigned IsPCRel =
Fixup.isPCRel();
152 if (!
A->getFragment()) {
154 "symbol '" +
A->getName() +
155 "' can not be undefined in a subtraction expression");
162 FixedValue += SecAddr;
164 if (
const MCSymbol *SB =
Target.getSubSym()) {
165 if (!SB->getFragment()) {
167 "symbol '" + SB->getName() +
168 "' can not be undefined in a subtraction expression");
192 unsigned ThumbBit = 0;
193 unsigned MovtBit = 0;
194 switch (
Fixup.getKind()) {
201 if (
Asm.isThumbFunc(
A))
202 FixedValue &= 0xfffffffe;
205 if (
Asm.isThumbFunc(
A))
206 FixedValue &= 0xfffffffe;
215 uint32_t OtherHalf = MovtBit
216 ? (FixedValue & 0xffff) : ((FixedValue & 0xffff0000) >> 16);
218 MachO::any_relocation_info MRE;
219 MRE.
r_word0 = ((OtherHalf << 0) |
229 MachO::any_relocation_info MRE;
230 MRE.
r_word0 = ((FixupOffset << 0) |
240void ARMMachObjectWriter::recordARMScatteredRelocation(
241 MachObjectWriter *Writer,
const MCAssembler &Asm,
242 const MCFragment *Fragment,
const MCFixup &
Fixup, MCValue Target,
243 unsigned Type,
unsigned Log2Size, uint64_t &FixedValue) {
244 uint32_t FixupOffset =
Asm.getFragmentOffset(*Fragment) +
Fixup.getOffset();
246 if (FixupOffset & 0xff000000) {
249 "' in resulting scattered relocation.");
253 unsigned IsPCRel =
Fixup.isPCRel();
258 if (!
A->getFragment()) {
260 "symbol '" +
A->getName() +
261 "' can not be undefined in a subtraction expression");
267 FixedValue += SecAddr;
270 if (
const MCSymbol *SB =
Target.getSubSym()) {
273 if (!SB->getFragment()) {
275 "symbol '" + SB->getName() +
276 "' can not be undefined in a subtraction expression");
289 MachO::any_relocation_info MRE;
299 MachO::any_relocation_info MRE;
300 MRE.
r_word0 = ((FixupOffset << 0) |
309bool ARMMachObjectWriter::requiresExternRelocation(MachObjectWriter *Writer,
310 const MCAssembler &Asm,
311 const MCFragment &Fragment,
314 uint64_t FixedValue) {
318 int64_t
Value = (int64_t)FixedValue;
355void ARMMachObjectWriter::recordRelocation(MachObjectWriter *Writer,
357 const MCFragment *Fragment,
358 const MCFixup &
Fixup, MCValue Target,
359 uint64_t &FixedValue) {
360 unsigned IsPCRel =
Fixup.isPCRel();
377 return recordARMScatteredHalfRelocation(Writer, Asm, Fragment,
Fixup,
379 return recordARMScatteredRelocation(Writer, Asm, Fragment,
Fixup, Target,
380 RelocType, Log2Size, FixedValue);
396 return recordARMScatteredRelocation(Writer, Asm, Fragment,
Fixup, Target,
397 RelocType, Log2Size, FixedValue);
400 uint32_t FixupOffset =
Asm.getFragmentOffset(*Fragment) +
Fixup.getOffset();
403 const MCSymbol *RelSymbol =
nullptr;
410 "not yet implemented");
413 if (
A->isVariable()) {
416 A->getVariableValue()->evaluateAsRelocatable(Val, &Asm);
431 if (requiresExternRelocation(Writer, Asm, *Fragment, RelocType, *
A,
438 if (!
A->isUndefined())
439 FixedValue -=
Asm.getSymbolOffset(*
A);
442 const MCSection &Sec =
A->getSection();
454 MachO::any_relocation_info MRE;
457 (
Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (
Type << 28);
467 switch (
Fixup.getKind()) {
471 Value = (FixedValue >> 16) & 0xffff;
475 Value = FixedValue & 0xffff;
478 MachO::any_relocation_info MREPair;
480 MREPair.
r_word1 = ((0xffffff << 0) |
490std::unique_ptr<MCObjectTargetWriter>
493 return std::make_unique<ARMMachObjectWriter>(Is64Bit, CPUType, CPUSubtype);
500 MCObjectStreamer &getStreamer() {
501 return static_cast<MCObjectStreamer &
>(Streamer);
503 void emitThumbFunc(MCSymbol *Symbol)
override {
506 getStreamer().getAssembler().setIsThumbFunc(Symbol);
507 static_cast<MCSymbolMachO *
>(
Symbol)->setThumbFunc();
513 return new ARMTargetMachOStreamer(S);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool getARMFixupKindMachOInfo(unsigned Kind, unsigned &RelocType, unsigned &Log2Size)
static Error reportError(StringRef Message)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
PowerPC TLS Dynamic Call Fixup
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
MCSection * getParent() const
unsigned getOrdinal() const
Streaming machine code generation interface.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Target specific streamer interface.
const MCSymbol * getAddSym() const
int64_t getConstant() const
const MCSymbol * getSubSym() const
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
bool doesSymbolRequireExternRelocation(const MCSymbol &S)
uint64_t getSectionAddress(const MCSection *Sec) const
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
uint64_t getSymbolAddress(const MCSymbol &S) const
Target - Wrapper for Target specific information.
@ fixup_arm_ldst_pcrel_12
@ ARM_RELOC_LOCAL_SECTDIFF
@ ARM_RELOC_HALF_SECTDIFF
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
MCTargetStreamer * createARMObjectTargetMachOStreamer(MCStreamer &S)
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
std::unique_ptr< MCObjectTargetWriter > createARMMachObjectWriter(bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
Construct an ARM Mach-O object writer.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_1
A one-byte fixup.
@ FK_Data_4
A four-byte fixup.
@ FK_Data_2
A two-byte fixup.