Lines Matching +full:fixed +full:- +full:layout
1 //===-- X86MachObjectWriter.cpp - X86 Mach-O Writer -----------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
58 if (Writer->is64Bit())
98 unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
105 Writer->getFragmentAddress(Asm, Fragment) + Fixup.getOffset();
135 } else if (Target.getSymB()) { // A - B + constant
136 const MCSymbol *A = &Target.getSymA()->getSymbol();
137 if (A->isTemporary())
138 A = &Writer->findAliasedSymbol(*A);
139 const MCSymbol *A_Base = Writer->getAtom(*A);
141 const MCSymbol *B = &Target.getSymB()->getSymbol();
142 if (B->isTemporary())
143 B = &Writer->findAliasedSymbol(*B);
144 const MCSymbol *B_Base = Writer->getAtom(*B);
147 if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None) {
157 Fixup.getLoc(), "unsupported pc-relative relocation of difference");
165 // symbols. This is encoded using the section ordinal and non-extern
178 // non-relocatable expression.
179 if (A->isUndefined() || B->isUndefined()) {
180 StringRef Name = A->isUndefined() ? A->getName() : B->getName();
187 Value += Writer->getSymbolAddress(*A, Asm) -
188 (!A_Base ? 0 : Writer->getSymbolAddress(*A_Base, Asm));
189 Value -= Writer->getSymbolAddress(*B, Asm) -
190 (!B_Base ? 0 : Writer->getSymbolAddress(*B_Base, Asm));
193 Index = A->getFragment()->getParent()->getOrdinal() + 1;
200 Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
205 Index = B->getFragment()->getParent()->getOrdinal() + 1;
208 const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
209 if (Symbol->isTemporary() && Value) {
210 const MCSection &Sec = Symbol->getSection();
212 Symbol->setUsedInReloc();
214 RelSymbol = Writer->getAtom(*Symbol);
219 // have already been fixed up.
220 if (Symbol->isInSection()) {
222 static_cast<const MCSectionMachO &>(*Fragment->getParent());
229 // non-local symbol).
233 Value += Asm.getSymbolOffset(*Symbol) - Asm.getSymbolOffset(*RelSymbol);
234 } else if (Symbol->isInSection() && !Symbol->isVariable()) {
235 // The index is the section ordinal (1-based).
236 Index = Symbol->getFragment()->getParent()->getOrdinal() + 1;
237 Value += Writer->getSymbolAddress(*Symbol, Asm);
240 Value -= FixupAddress + (1 << Log2Size);
241 } else if (Symbol->isVariable()) {
242 const MCExpr *Value = Symbol->getVariableValue();
245 Value->evaluateAsAbsolute(Res, Asm, Writer->getSectionAddressMap());
252 Symbol->getName() + "'");
258 Symbol->getName() + "'");
262 MCSymbolRefExpr::VariantKind Modifier = Target.getSymA()->getKind();
296 switch (-(Target.getConstant() + (1LL << Log2Size))) {
316 // GOTPCREL is allowed as a modifier on non-PCrel instructions, in which
324 Fixup.getLoc(), "TLVP symbol modifier should have been rip-rel");
335 "32-bit absolute addressing is not supported in 64-bit mode");
350 Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
362 unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
366 const MCSymbol *A = &Target.getSymA()->getSymbol();
368 if (!A->getFragment()) {
371 "symbol '" + A->getName() +
376 uint32_t Value = Writer->getSymbolAddress(*A, Asm);
377 uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
382 const MCSymbol *SB = &B->getSymbol();
384 if (!SB->getFragment()) {
387 "symbol '" + SB->getName() +
397 Type = A->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF
399 Value2 = Writer->getSymbolAddress(*SB, Asm);
400 FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
426 Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
428 // If the offset is more than 24-bits, it won't fit in a scattered
429 // relocation offset field, so we fall back to using a non-scattered
448 Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
459 assert(SymA->getKind() == MCSymbolRefExpr::VK_TLVP && !is64Bit() &&
460 "Should only be called with a 32-bit TLVP relocation!");
467 // subtraction from the picbase. For 32-bit pic the addend is the difference
468 // between the picbase and the next address. For 32-bit static the addend is
473 Writer->getFragmentAddress(Asm, Fragment) + Fixup.getOffset();
475 FixedValue = FixupAddress -
476 Writer->getSymbolAddress(SymB->getSymbol(), Asm) +
488 Writer->addRelocation(&SymA->getSymbol(), Fragment->getParent(), MRE);
497 unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
500 // If this is a 32-bit TLVP reloc it's handled a bit differently.
502 Target.getSymA()->getKind() == MCSymbolRefExpr::VK_TLVP) {
519 A = &Target.getSymA()->getSymbol();
530 if (Offset && A && !Writer->doesSymbolRequireExternRelocation(*A) &&
551 if (A->isVariable()) {
553 if (A->getVariableValue()->evaluateAsAbsolute(
554 Res, Asm, Writer->getSectionAddressMap())) {
561 if (Writer->doesSymbolRequireExternRelocation(*A)) {
566 if (!A->isUndefined())
567 FixedValue -= Asm.getSymbolOffset(*A);
569 // The index is the section ordinal (1-based).
570 const MCSection &Sec = A->getSection();
572 FixedValue += Writer->getSectionAddress(&Sec);
575 FixedValue -= Writer->getSectionAddress(Fragment->getParent());
585 Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);