class MCContext;
class MCFixup;
class MCSection;
-class MCSectionData;
class MCStreamer;
class MCSymbol;
class MCValue;
class raw_ostream;
class StringRef;
-typedef DenseMap<const MCSectionData*, uint64_t> SectionAddrMap;
+typedef DenseMap<const MCSection *, uint64_t> SectionAddrMap;
/// \brief Base class for the full range of assembler expressions which are
/// needed for parsing.
SectionAddrMap &getSectionAddressMap() { return SectionAddress; }
- uint64_t getSectionAddress(const MCSectionData* SD) const {
- return SectionAddress.lookup(SD);
+ uint64_t getSectionAddress(const MCSection *Sec) const {
+ return SectionAddress.lookup(Sec);
}
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const;
Addend += Layout->getSymbolOffset(A->getSymbol()) -
Layout->getSymbolOffset(B->getSymbol());
if (Addrs && (&SecA != &SecB))
- Addend += (Addrs->lookup(&SecA.getSectionData()) -
- Addrs->lookup(&SecB.getSectionData()));
+ Addend += (Addrs->lookup(&SecA) - Addrs->lookup(&SecB));
// Pointers to Thumb symbols need to have their low-bit set to allow
// for interworking.
uint64_t MachObjectWriter::getFragmentAddress(const MCFragment *Fragment,
const MCAsmLayout &Layout) const {
- return getSectionAddress(&Fragment->getParent()->getSectionData()) +
+ return getSectionAddress(Fragment->getParent()) +
Layout.getFragmentOffset(Fragment);
}
return Address;
}
- return getSectionAddress(
- &S.getData().getFragment()->getParent()->getSectionData()) +
+ return getSectionAddress(S.getData().getFragment()->getParent()) +
Layout.getSymbolOffset(S);
}
uint64_t MachObjectWriter::getPaddingSize(const MCSectionData *SD,
const MCAsmLayout &Layout) const {
- uint64_t EndAddr = getSectionAddress(SD) + Layout.getSectionAddressSize(SD);
+ uint64_t EndAddr =
+ getSectionAddress(&SD->getSection()) + Layout.getSectionAddressSize(SD);
unsigned Next = SD->getSection().getLayoutOrder() + 1;
if (Next >= Layout.getSectionOrder().size())
return 0;
WriteBytes(Section.getSectionName(), 16);
WriteBytes(Section.getSegmentName(), 16);
if (is64Bit()) {
- Write64(getSectionAddress(&SD)); // address
+ Write64(getSectionAddress(&SD.getSection())); // address
Write64(SectionSize); // size
} else {
- Write32(getSectionAddress(&SD)); // address
+ Write32(getSectionAddress(&SD.getSection())); // address
Write32(SectionSize); // size
}
Write32(FileOffset);
const MCSectionData *SD = Order[i];
StartAddress =
RoundUpToAlignment(StartAddress, SD->getSection().getAlignment());
- SectionAddress[SD] = StartAddress;
+ SectionAddress[&SD->getSection()] = StartAddress;
StartAddress += Layout.getSectionAddressSize(SD);
// Explicitly pad the section to match the alignment requirements of the
for (MCAssembler::const_iterator it = Asm.begin(),
ie = Asm.end(); it != ie; ++it) {
const MCSectionData &SD = it->getSectionData();
- uint64_t Address = getSectionAddress(&SD);
+ uint64_t Address = getSectionAddress(&*it);
uint64_t Size = Layout.getSectionAddressSize(&SD);
uint64_t FileSize = Layout.getSectionFileSize(&SD);
FileSize += getPaddingSize(&SD, Layout);
const MCSectionData &SD = it->getSectionData();
std::vector<RelAndSymbol> &Relocs = Relocations[&SD];
unsigned NumRelocs = Relocs.size();
- uint64_t SectionStart = SectionDataStart + getSectionAddress(&SD);
+ uint64_t SectionStart = SectionDataStart + getSectionAddress(&*it);
WriteSection(Asm, Layout, SD, SectionStart, RelocTableEnd, NumRelocs);
RelocTableEnd += NumRelocs * sizeof(MachO::any_relocation_info);
}
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
uint32_t Value2 = 0;
- uint64_t SecAddr = Writer->getSectionAddress(
- &A_SD->getFragment()->getParent()->getSectionData());
+ uint64_t SecAddr =
+ Writer->getSectionAddress(A_SD->getFragment()->getParent());
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()->getSectionData());
+ FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr = Writer->getSectionAddress(
- &A_SD->getFragment()->getParent()->getSectionData());
+ uint64_t SecAddr =
+ Writer->getSectionAddress(A_SD->getFragment()->getParent());
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()->getSectionData());
+ FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
// BL/BLX also use external relocations when an internal relocation
// would result in the target being out of range. This gives the linker
// enough information to generate a branch island.
- const MCSectionData &SymSD = Asm.getSectionData(S.getSection());
- Value += Writer->getSectionAddress(&SymSD);
- Value -= Writer->getSectionAddress(&Fragment.getParent()->getSectionData());
+ Value += Writer->getSectionAddress(&S.getSection());
+ Value -= Writer->getSectionAddress(Fragment.getParent());
// If the resultant value would be out of range for an internal relocation,
// use an external instead.
if (Value > Range || Value < -(Range + 1))
} else {
// The index is the section ordinal (1-based).
const MCSection &Sec = A->getSection();
- const MCSectionData &SymSD = Asm.getSectionData(Sec);
Index = Sec.getOrdinal() + 1;
- FixedValue += Writer->getSectionAddress(&SymSD);
+ FixedValue += Writer->getSectionAddress(&Sec);
}
if (IsPCRel)
- FixedValue -=
- Writer->getSectionAddress(&Fragment->getParent()->getSectionData());
+ FixedValue -= Writer->getSectionAddress(Fragment->getParent());
// The type is determined by the fixup kind.
Type = RelocType;
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr = Writer->getSectionAddress(
- &A_SD->getFragment()->getParent()->getSectionData());
+ uint64_t SecAddr =
+ Writer->getSectionAddress(A_SD->getFragment()->getParent());
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()->getSectionData());
+ FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
}
// FIXME: does FixedValue get used??
} else {
// The index is the section ordinal (1-based).
const MCSection &Sec = A->getSection();
- const MCSectionData &SymSD = Asm.getSectionData(Sec);
Index = Sec.getOrdinal() + 1;
- FixedValue += Writer->getSectionAddress(&SymSD);
+ FixedValue += Writer->getSectionAddress(&Sec);
}
if (IsPCRel)
- FixedValue -=
- Writer->getSectionAddress(&Fragment->getParent()->getSectionData());
+ FixedValue -= Writer->getSectionAddress(Fragment->getParent());
}
// struct relocation_info (8 bytes)
false);
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr = Writer->getSectionAddress(
- &A_SD->getFragment()->getParent()->getSectionData());
+ uint64_t SecAddr =
+ Writer->getSectionAddress(A_SD->getFragment()->getParent());
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()->getSectionData());
+ FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
} else {
// The index is the section ordinal (1-based).
const MCSection &Sec = A->getSection();
- const MCSectionData &SymSD = Asm.getSectionData(Sec);
Index = Sec.getOrdinal() + 1;
- FixedValue += Writer->getSectionAddress(&SymSD);
+ FixedValue += Writer->getSectionAddress(&Sec);
}
if (IsPCRel)
- FixedValue -=
- Writer->getSectionAddress(&Fragment->getParent()->getSectionData());
+ FixedValue -= Writer->getSectionAddress(Fragment->getParent());
Type = MachO::GENERIC_RELOC_VANILLA;
}