[llvm] r238162 - Return a MCSection from MCFragment::getParent().
Rafael Espindola
rafael.espindola at gmail.com
Mon May 25 17:36:58 PDT 2015
Author: rafael
Date: Mon May 25 19:36:57 2015
New Revision: 238162
URL: http://llvm.org/viewvc/llvm-project?rev=238162&view=rev
Log:
Return a MCSection from MCFragment::getParent().
Another step in merging MCSectionData and MCSection.
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/MC/MCAssembler.cpp
llvm/trunk/lib/MC/MCExpr.cpp
llvm/trunk/lib/MC/MCObjectWriter.cpp
llvm/trunk/lib/MC/MachObjectWriter.cpp
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Mon May 25 19:36:57 2015
@@ -98,9 +98,7 @@ public:
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; }
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon May 25 19:36:57 2015
@@ -491,8 +491,7 @@ void ELFObjectWriter::WriteSymbol(Symbol
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);
@@ -751,9 +750,7 @@ void ELFObjectWriter::RecordRelocation(M
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();
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Mon May 25 19:36:57 2015
@@ -77,7 +77,7 @@ MCAsmLayout::MCAsmLayout(MCAssembler &As
}
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;
@@ -92,12 +92,12 @@ void MCAsmLayout::invalidateFragmentsFro
// 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)
@@ -421,7 +421,7 @@ const MCSymbol *MCAssembler::getAtom(con
// 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.
@@ -568,7 +568,7 @@ void MCAsmLayout::layoutFragment(MCFragm
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:
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Mon May 25 19:36:57 2015
@@ -491,8 +491,8 @@ static void AttemptToFoldSymbolOffsetDif
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;
@@ -501,7 +501,8 @@ static void AttemptToFoldSymbolOffsetDif
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.
Modified: llvm/trunk/lib/MC/MCObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectWriter.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectWriter.cpp Mon May 25 19:36:57 2015
@@ -43,7 +43,7 @@ bool MCObjectWriter::IsSymbolRefDifferen
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;
}
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon May 25 19:36:57 2015
@@ -67,8 +67,8 @@ bool MachObjectWriter::isFixupKindPCRel(
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,
@@ -101,7 +101,8 @@ uint64_t MachObjectWriter::getSymbolAddr
return Address;
}
- return getSectionAddress(S.getData().getFragment()->getParent()) +
+ return getSectionAddress(
+ &S.getData().getFragment()->getParent()->getSectionData()) +
Layout.getSymbolOffset(S);
}
@@ -679,7 +680,7 @@ bool MachObjectWriter::IsSymbolRefDiffer
// 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
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Mon May 25 19:36:57 2015
@@ -420,8 +420,7 @@ void WinCOFFObjectWriter::DefineSymbol(c
} 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");
@@ -689,15 +688,15 @@ void WinCOFFObjectWriter::RecordRelocati
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;
Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp Mon May 25 19:36:57 2015
@@ -229,7 +229,8 @@ void AArch64MachObjectWriter::RecordRelo
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)
@@ -278,14 +279,15 @@ void AArch64MachObjectWriter::RecordRelo
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);
@@ -385,7 +387,8 @@ void AArch64MachObjectWriter::RecordRelo
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;
@@ -406,7 +409,8 @@ void AArch64MachObjectWriter::RecordRelo
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,
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp Mon May 25 19:36:57 2015
@@ -161,8 +161,8 @@ RecordARMScatteredHalfRelocation(MachObj
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()) {
@@ -176,7 +176,8 @@ RecordARMScatteredHalfRelocation(MachObj
// 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.
@@ -227,7 +228,8 @@ RecordARMScatteredHalfRelocation(MachObj
(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;
@@ -238,7 +240,7 @@ RecordARMScatteredHalfRelocation(MachObj
(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,
@@ -263,7 +265,8 @@ void ARMMachObjectWriter::RecordARMScatt
"' 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;
@@ -279,7 +282,8 @@ void ARMMachObjectWriter::RecordARMScatt
// 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.
@@ -292,7 +296,8 @@ void ARMMachObjectWriter::RecordARMScatt
(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;
@@ -302,7 +307,7 @@ void ARMMachObjectWriter::RecordARMScatt
(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,
@@ -336,7 +341,7 @@ bool ARMMachObjectWriter::requiresExtern
// 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))
@@ -430,7 +435,8 @@ void ARMMachObjectWriter::RecordRelocati
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;
@@ -465,10 +471,12 @@ void ARMMachObjectWriter::RecordRelocati
(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,
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp Mon May 25 19:36:57 2015
@@ -213,8 +213,8 @@ bool PPCMachObjectWriter::RecordScattere
"' 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;
@@ -227,7 +227,8 @@ bool PPCMachObjectWriter::RecordScattere
// 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??
@@ -282,7 +283,8 @@ bool PPCMachObjectWriter::RecordScattere
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
@@ -296,7 +298,7 @@ bool PPCMachObjectWriter::RecordScattere
}
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;
}
@@ -369,13 +371,15 @@ void PPCMachObjectWriter::RecordPPCReloc
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,
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp?rev=238162&r1=238161&r2=238162&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp Mon May 25 19:36:57 2015
@@ -190,19 +190,20 @@ void X86MachObjectWriter::RecordX86_64Re
(!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();
@@ -219,8 +220,8 @@ void X86MachObjectWriter::RecordX86_64Re
// 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;
}
@@ -235,7 +236,7 @@ void X86MachObjectWriter::RecordX86_64Re
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)
@@ -336,7 +337,8 @@ void X86MachObjectWriter::RecordX86_64Re
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,
@@ -362,7 +364,8 @@ bool X86MachObjectWriter::RecordScattere
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;
@@ -382,7 +385,8 @@ bool X86MachObjectWriter::RecordScattere
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.
@@ -408,7 +412,8 @@ bool X86MachObjectWriter::RecordScattere
(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
@@ -430,7 +435,7 @@ bool X86MachObjectWriter::RecordScattere
(IsPCRel << 30) |
MachO::R_SCATTERED);
MRE.r_word1 = Value;
- Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
+ Writer->addRelocation(nullptr, &Fragment->getParent()->getSectionData(), MRE);
return true;
}
@@ -472,8 +477,8 @@ void X86MachObjectWriter::RecordTLVPRelo
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,
@@ -560,7 +565,8 @@ void X86MachObjectWriter::RecordX86Reloc
FixedValue += Writer->getSectionAddress(&SymSD);
}
if (IsPCRel)
- FixedValue -= Writer->getSectionAddress(Fragment->getParent());
+ FixedValue -=
+ Writer->getSectionAddress(&Fragment->getParent()->getSectionData());
Type = MachO::GENERIC_RELOC_VANILLA;
}
@@ -570,7 +576,8 @@ void X86MachObjectWriter::RecordX86Reloc
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,
More information about the llvm-commits
mailing list