FragmentType getKind() const { return Kind; }
- MCSectionData *getParent() const {
- return &Parent->getSectionData();
- }
+ MCSection *getParent() const { return Parent; }
void setParent(MCSection *Value) { Parent = Value; }
const MCSymbol *getAtom() const { return Atom; }
const MCAsmLayout &Layout) {
MCSymbolData &OrigData = MSD.Symbol->getData();
assert((!OrigData.getFragment() ||
- (&OrigData.getFragment()->getParent()->getSection() ==
- &MSD.Symbol->getSection())) &&
+ (OrigData.getFragment()->getParent() == &MSD.Symbol->getSection())) &&
"The symbol's section doesn't match the fragment's symbol");
const MCSymbol *Base = Layout.getBaseSymbol(*MSD.Symbol);
const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
bool &IsPCRel, uint64_t &FixedValue) {
- const MCSectionData *FixupSectionD = Fragment->getParent();
- const MCSectionELF &FixupSection =
- cast<MCSectionELF>(FixupSectionD->getSection());
+ const MCSectionELF &FixupSection = cast<MCSectionELF>(*Fragment->getParent());
uint64_t C = Target.getConstant();
uint64_t FixupOffset = Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
}
bool MCAsmLayout::isFragmentValid(const MCFragment *F) const {
- const MCSectionData &SD = *F->getParent();
+ const MCSectionData &SD = F->getParent()->getSectionData();
const MCFragment *LastValid = LastValidFragment.lookup(&SD);
if (!LastValid)
return false;
// Otherwise, reset the last valid fragment to the previous fragment
// (if this is the first fragment, it will be NULL).
- const MCSectionData &SD = *F->getParent();
+ const MCSectionData &SD = F->getParent()->getSectionData();
LastValidFragment[&SD] = F->getPrevNode();
}
void MCAsmLayout::ensureValid(const MCFragment *F) const {
- MCSectionData &SD = *F->getParent();
+ MCSectionData &SD = F->getParent()->getSectionData();
MCFragment *Cur = LastValidFragment[&SD];
if (!Cur)
// Non-linker visible symbols in sections which can't be atomized have no
// defining atom.
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
- S.getData().getFragment()->getParent()->getSection()))
+ *S.getData().getFragment()->getParent()))
return nullptr;
// Otherwise, return the atom for the containing fragment.
F->Offset = Prev->Offset + getAssembler().computeFragmentSize(*this, *Prev);
else
F->Offset = 0;
- LastValidFragment[F->getParent()] = F;
+ LastValidFragment[&F->getParent()->getSectionData()] = F;
// If bundling is enabled and this fragment has instructions in it, it has to
// obey the bundling restrictions. With padding, we'll have:
if (!Layout)
return;
- const MCSectionData &SecA = *AD.getFragment()->getParent();
- const MCSectionData &SecB = *BD.getFragment()->getParent();
+ const MCSection &SecA = *AD.getFragment()->getParent();
+ const MCSection &SecB = *BD.getFragment()->getParent();
if ((&SecA != &SecB) && !Addrs)
return;
Addend += Layout->getSymbolOffset(A->getSymbol()) -
Layout->getSymbolOffset(B->getSymbol());
if (Addrs && (&SecA != &SecB))
- Addend += (Addrs->lookup(&SecA) - Addrs->lookup(&SecB));
+ Addend += (Addrs->lookup(&SecA.getSectionData()) -
+ Addrs->lookup(&SecB.getSectionData()));
// Pointers to Thumb symbols need to have their low-bit set to allow
// for interworking.
const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB,
bool InSet, bool IsPCRel) const {
const MCSection &SecA = SymA.getSection();
- const MCSection &SecB = FB.getParent()->getSection();
+ const MCSection &SecB = *FB.getParent();
// On ELF and COFF A - B is absolute if A and B are in the same section.
return &SecA == &SecB;
}
uint64_t MachObjectWriter::getFragmentAddress(const MCFragment *Fragment,
const MCAsmLayout &Layout) const {
- return getSectionAddress(Fragment->getParent()) +
- Layout.getFragmentOffset(Fragment);
+ return getSectionAddress(&Fragment->getParent()->getSectionData()) +
+ Layout.getFragmentOffset(Fragment);
}
uint64_t MachObjectWriter::getSymbolAddress(const MCSymbol &S,
return Address;
}
- return getSectionAddress(S.getData().getFragment()->getParent()) +
+ return getSectionAddress(
+ &S.getData().getFragment()->getParent()->getSectionData()) +
Layout.getSymbolOffset(S);
}
// addr(atom(A)) - addr(atom(B)) == 0.
const MCSymbol &SA = findAliasedSymbol(SymA);
const MCSection &SecA = SA.getSection();
- const MCSection &SecB = FB.getParent()->getSection();
+ const MCSection &SecB = *FB.getParent();
if (IsPCRel) {
// The simple (Darwin, except on x86_64) way of dealing with this was to
} else {
const MCSymbolData &BaseData = Assembler.getSymbolData(*Base);
if (BaseData.getFragment()) {
- COFFSection *Sec =
- SectionMap[&BaseData.getFragment()->getParent()->getSection()];
+ COFFSection *Sec = SectionMap[BaseData.getFragment()->getParent()];
if (coff_symbol->Section && coff_symbol->Section != Sec)
report_fatal_error("conflicting sections for symbol");
const MCSymbolData &A_SD = Asm.getSymbolData(A);
- MCSectionData const *SectionData = Fragment->getParent();
+ MCSection *Section = Fragment->getParent();
// Mark this symbol as requiring an entry in the symbol table.
- assert(SectionMap.find(&SectionData->getSection()) != SectionMap.end() &&
+ assert(SectionMap.find(Section) != SectionMap.end() &&
"Section must already have been defined in ExecutePostLayoutBinding!");
assert(SymbolMap.find(&A) != SymbolMap.end() &&
"Symbol must already have been defined in ExecutePostLayoutBinding!");
- COFFSection *coff_section = SectionMap[&SectionData->getSection()];
+ COFFSection *coff_section = SectionMap[Section];
COFFSymbol *coff_symbol = SymbolMap[&A];
const MCSymbolRefExpr *SymB = Target.getSymB();
bool CrossSection = false;
MachO::any_relocation_info MRE;
MRE.r_word0 = FixupOffset;
MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
+ Writer->addRelocation(A_Base, &Fragment->getParent()->getSectionData(),
+ MRE);
return;
} else if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
Target.getSymB()->getKind() != MCSymbolRefExpr::VK_None)
MachO::any_relocation_info MRE;
MRE.r_word0 = FixupOffset;
MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
+ Writer->addRelocation(A_Base, &Fragment->getParent()->getSectionData(),
+ MRE);
RelSymbol = B_Base;
Type = MachO::ARM64_RELOC_SUBTRACTOR;
} else { // A + constant
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
- const MCSectionMachO &Section = static_cast<const MCSectionMachO &>(
- Fragment->getParent()->getSection());
+ const MCSectionMachO &Section =
+ static_cast<const MCSectionMachO &>(*Fragment->getParent());
bool CanUseLocalRelocation =
canUseLocalRelocation(Section, *Symbol, Log2Size);
MRE.r_word0 = FixupOffset;
MRE.r_word1 =
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, &Fragment->getParent()->getSectionData(),
+ MRE);
// Now set up the Addend relocation.
Type = MachO::ARM64_RELOC_ADDEND;
MRE.r_word0 = FixupOffset;
MRE.r_word1 =
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, &Fragment->getParent()->getSectionData(),
+ MRE);
}
MCObjectWriter *llvm::createAArch64MachObjectWriter(raw_pwrite_stream &OS,
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
uint32_t Value2 = 0;
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(
+ &A_SD->getFragment()->getParent()->getSectionData());
FixedValue += SecAddr;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
// Select the appropriate difference relocation type.
Type = MachO::ARM_RELOC_HALF_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(
+ &B_SD->getFragment()->getParent()->getSectionData());
}
// Relocations are written out in reverse order, so the PAIR comes first.
(IsPCRel << 30) |
MachO::R_SCATTERED);
MRE.r_word1 = Value2;
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(),
+ MRE);
}
MachO::any_relocation_info MRE;
(IsPCRel << 30) |
MachO::R_SCATTERED);
MRE.r_word1 = Value;
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(), MRE);
}
void ARMMachObjectWriter::RecordARMScatteredRelocation(MachObjectWriter *Writer,
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr = Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(
+ &A_SD->getFragment()->getParent()->getSectionData());
FixedValue += SecAddr;
uint32_t Value2 = 0;
// Select the appropriate difference relocation type.
Type = MachO::ARM_RELOC_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(
+ &B_SD->getFragment()->getParent()->getSectionData());
}
// Relocations are written out in reverse order, so the PAIR comes first.
(IsPCRel << 30) |
MachO::R_SCATTERED);
MRE.r_word1 = Value2;
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(),
+ MRE);
}
MachO::any_relocation_info MRE;
(IsPCRel << 30) |
MachO::R_SCATTERED);
MRE.r_word1 = Value;
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(), MRE);
}
bool ARMMachObjectWriter::requiresExternRelocation(MachObjectWriter *Writer,
// enough information to generate a branch island.
const MCSectionData &SymSD = Asm.getSectionData(S.getSection());
Value += Writer->getSectionAddress(&SymSD);
- Value -= Writer->getSectionAddress(Fragment.getParent());
+ Value -= Writer->getSectionAddress(&Fragment.getParent()->getSectionData());
// If the resultant value would be out of range for an internal relocation,
// use an external instead.
if (Value > Range || Value < -(Range + 1))
FixedValue += Writer->getSectionAddress(&SymSD);
}
if (IsPCRel)
- FixedValue -= Writer->getSectionAddress(Fragment->getParent());
+ FixedValue -=
+ Writer->getSectionAddress(&Fragment->getParent()->getSectionData());
// The type is determined by the fixup kind.
Type = RelocType;
(Log2Size << 25) |
(MachO::ARM_RELOC_PAIR << 28));
- Writer->addRelocation(nullptr, Fragment->getParent(), MREPair);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(),
+ MREPair);
}
- Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, &Fragment->getParent()->getSectionData(),
+ MRE);
}
MCObjectWriter *llvm::createARMMachObjectWriter(raw_pwrite_stream &OS,
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(
+ &A_SD->getFragment()->getParent()->getSectionData());
FixedValue += SecAddr;
uint32_t Value2 = 0;
// FIXME: is Type correct? see include/llvm/Support/MachO.h
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(
+ &B_SD->getFragment()->getParent()->getSectionData());
}
// FIXME: does FixedValue get used??
MachO::any_relocation_info MRE;
makeScatteredRelocationInfo(MRE, other_half, MachO::GENERIC_RELOC_PAIR,
Log2Size, IsPCRel, Value2);
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(),
+ MRE);
} else {
// If the offset is more than 24-bits, it won't fit in a scattered
// relocation offset field, so we fall back to using a non-scattered
}
MachO::any_relocation_info MRE;
makeScatteredRelocationInfo(MRE, FixupOffset, Type, Log2Size, IsPCRel, Value);
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(), MRE);
return true;
}
FixedValue += Writer->getSectionAddress(&SymSD);
}
if (IsPCRel)
- FixedValue -= Writer->getSectionAddress(Fragment->getParent());
+ FixedValue -=
+ Writer->getSectionAddress(&Fragment->getParent()->getSectionData());
}
// struct relocation_info (8 bytes)
MachO::any_relocation_info MRE;
makeRelocationInfo(MRE, FixupOffset, Index, IsPCRel, Log2Size, false, Type);
- Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, &Fragment->getParent()->getSectionData(),
+ MRE);
}
MCObjectWriter *llvm::createPPCMachObjectWriter(raw_pwrite_stream &OS,
(!B_Base ? 0 : Writer->getSymbolAddress(*B_Base, Layout));
if (!A_Base)
- Index = A_SD.getFragment()->getParent()->getSection().getOrdinal() + 1;
+ Index = A_SD.getFragment()->getParent()->getOrdinal() + 1;
Type = MachO::X86_64_RELOC_UNSIGNED;
MachO::any_relocation_info MRE;
MRE.r_word0 = FixupOffset;
MRE.r_word1 =
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
+ Writer->addRelocation(A_Base, &Fragment->getParent()->getSectionData(),
+ MRE);
if (B_Base)
RelSymbol = B_Base;
else
- Index = B_SD.getFragment()->getParent()->getSection().getOrdinal() + 1;
+ Index = B_SD.getFragment()->getParent()->getOrdinal() + 1;
Type = MachO::X86_64_RELOC_SUBTRACTOR;
} else {
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
// understand x86_64 relocation entries, and expects to find values that
// have already been fixed up.
if (Symbol->isInSection()) {
- const MCSectionMachO &Section = static_cast<const MCSectionMachO&>(
- Fragment->getParent()->getSection());
+ const MCSectionMachO &Section =
+ static_cast<const MCSectionMachO &>(*Fragment->getParent());
if (Section.hasAttribute(MachO::S_ATTR_DEBUG))
RelSymbol = nullptr;
}
Layout.getSymbolOffset(*RelSymbol);
} else if (Symbol->isInSection() && !Symbol->isVariable()) {
// The index is the section ordinal (1-based).
- Index = SD.getFragment()->getParent()->getSection().getOrdinal() + 1;
+ Index = SD.getFragment()->getParent()->getOrdinal() + 1;
Value += Writer->getSymbolAddress(*Symbol, Layout);
if (IsPCRel)
MRE.r_word0 = FixupOffset;
MRE.r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
(IsExtern << 27) | (Type << 28);
- Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, &Fragment->getParent()->getSectionData(),
+ MRE);
}
bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
false);
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr = Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(
+ &A_SD->getFragment()->getParent()->getSectionData());
FixedValue += SecAddr;
uint32_t Value2 = 0;
Type = A_SD->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF :
(unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(
+ &B_SD->getFragment()->getParent()->getSectionData());
}
// Relocations are written out in reverse order, so the PAIR comes first.
(IsPCRel << 30) |
MachO::R_SCATTERED);
MRE.r_word1 = Value2;
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(),
+ MRE);
} else {
// If the offset is more than 24-bits, it won't fit in a scattered
// relocation offset field, so we fall back to using a non-scattered
(IsPCRel << 30) |
MachO::R_SCATTERED);
MRE.r_word1 = Value;
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(), MRE);
return true;
}
MRE.r_word0 = Value;
MRE.r_word1 =
(IsPCRel << 24) | (Log2Size << 25) | (MachO::GENERIC_RELOC_TLV << 28);
- Writer->addRelocation(&Target.getSymA()->getSymbol(), Fragment->getParent(),
- MRE);
+ Writer->addRelocation(&Target.getSymA()->getSymbol(),
+ &Fragment->getParent()->getSectionData(), MRE);
}
void X86MachObjectWriter::RecordX86Relocation(MachObjectWriter *Writer,
FixedValue += Writer->getSectionAddress(&SymSD);
}
if (IsPCRel)
- FixedValue -= Writer->getSectionAddress(Fragment->getParent());
+ FixedValue -=
+ Writer->getSectionAddress(&Fragment->getParent()->getSectionData());
Type = MachO::GENERIC_RELOC_VANILLA;
}
MRE.r_word0 = FixupOffset;
MRE.r_word1 =
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, &Fragment->getParent()->getSectionData(),
+ MRE);
}
MCObjectWriter *llvm::createX86MachObjectWriter(raw_pwrite_stream &OS,