Remove getData.

This completes the mechanical part of merging MCSymbol and MCSymbolData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238617 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-05-29 21:45:01 +00:00
parent 38a2e49d1c
commit cfac75ad0e
18 changed files with 99 additions and 164 deletions

View File

@@ -165,10 +165,9 @@ private:
Name + "." + Twine(MappingSymbolCounter++));
getAssembler().registerSymbol(*Symbol);
MCSymbol &SD = Symbol->getData();
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
Symbol->setExternal(false);
auto Sec = getCurrentSection().first;
assert(Sec && "need a section");
Symbol->setSection(*Sec);

View File

@@ -209,11 +209,9 @@ void AArch64MachObjectWriter::RecordRelocation(
}
} else if (Target.getSymB()) { // A - B + constant
const MCSymbol *A = &Target.getSymA()->getSymbol();
const MCSymbol &A_SD = A->getData();
const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
const MCSymbol &B_SD = B->getData();
const MCSymbol *B_Base = Asm.getAtom(*B);
// Check for "_foo@got - .", which comes through here as:
@@ -264,14 +262,12 @@ void AArch64MachObjectWriter::RecordRelocation(
Asm.getContext().reportFatalError(Fixup.getLoc(),
"unsupported relocation with identical base");
Value += (!A_SD.getFragment() ? 0 : Writer->getSymbolAddress(*A, Layout)) -
(!A_Base || !A_Base->getData().getFragment()
? 0
: Writer->getSymbolAddress(*A_Base, Layout));
Value -= (!B_SD.getFragment() ? 0 : Writer->getSymbolAddress(*B, Layout)) -
(!B_Base || !B_Base->getData().getFragment()
? 0
: Writer->getSymbolAddress(*B_Base, Layout));
Value += (!A->getFragment() ? 0 : Writer->getSymbolAddress(*A, Layout)) -
(!A_Base || !A_Base->getFragment() ? 0 : Writer->getSymbolAddress(
*A_Base, Layout));
Value -= (!B->getFragment() ? 0 : Writer->getSymbolAddress(*B, Layout)) -
(!B_Base || !B_Base->getFragment() ? 0 : Writer->getSymbolAddress(
*B_Base, Layout));
Type = MachO::ARM64_RELOC_UNSIGNED;

View File

@@ -601,8 +601,7 @@ void ARMAsmBackend::processFixupValue(const MCAssembler &Asm,
// the offset when the destination has the same MCFragment.
if (A && (unsigned)Fixup.getKind() == ARM::fixup_arm_thumb_bl) {
const MCSymbol &Sym = A->getSymbol();
const MCSymbol &SymData = Sym.getData();
IsResolved = (SymData.getFragment() == DF);
IsResolved = (Sym.getFragment() == DF);
}
// We must always generate a relocation for BL/BLX instructions if we have
// a symbol to reference, as the linker relies on knowing the destination

View File

@@ -567,10 +567,9 @@ private:
Twine(MappingSymbolCounter++));
getAssembler().registerSymbol(*Symbol);
MCSymbol &SD = Symbol->getData();
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
Symbol->setExternal(false);
AssignSection(Symbol, getCurrentSection().first);
const MCExpr *Value = MCSymbolRefExpr::Create(Start, getContext());

View File

@@ -152,23 +152,21 @@ RecordARMScatteredHalfRelocation(MachObjectWriter *Writer,
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
const MCSymbol *A_SD = &A->getData();
if (!A_SD->getFragment())
if (!A->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
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->getFragment()->getParent());
FixedValue += SecAddr;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
const MCSymbol *B_SD = &B->getSymbol().getData();
const MCSymbol *SB = &B->getSymbol();
if (!B_SD->getFragment())
if (!SB->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
@@ -176,7 +174,7 @@ RecordARMScatteredHalfRelocation(MachObjectWriter *Writer,
// 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(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
@@ -255,24 +253,22 @@ void ARMMachObjectWriter::RecordARMScatteredRelocation(MachObjectWriter *Writer,
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
const MCSymbol *A_SD = &A->getData();
if (!A_SD->getFragment())
if (!A->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + A->getName() +
"' 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->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
assert(Type == MachO::ARM_RELOC_VANILLA && "invalid reloc for 2 symbols");
const MCSymbol *B_SD = &B->getSymbol().getData();
const MCSymbol *SB = &B->getSymbol();
if (!B_SD->getFragment())
if (!SB->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
@@ -280,7 +276,7 @@ void ARMMachObjectWriter::RecordARMScatteredRelocation(MachObjectWriter *Writer,
// 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(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.

View File

@@ -206,28 +206,26 @@ bool PPCMachObjectWriter::RecordScatteredRelocation(
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
const MCSymbol *A_SD = &A->getData();
if (!A_SD->getFragment())
if (!A->getFragment())
report_fatal_error("symbol '" + A->getName() +
"' 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->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
const MCSymbol *B_SD = &B->getSymbol().getData();
const MCSymbol *SB = &B->getSymbol();
if (!B_SD->getFragment())
if (!SB->getFragment())
report_fatal_error("symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
// 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(SB->getFragment()->getParent());
}
// FIXME: does FixedValue get used??

View File

@@ -142,13 +142,11 @@ void X86MachObjectWriter::RecordX86_64Relocation(
const MCSymbol *A = &Target.getSymA()->getSymbol();
if (A->isTemporary())
A = &Writer->findAliasedSymbol(*A);
const MCSymbol &A_SD = A->getData();
const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
if (B->isTemporary())
B = &Writer->findAliasedSymbol(*B);
const MCSymbol &B_SD = B->getData();
const MCSymbol *B_Base = Asm.getAtom(*B);
// Neither symbol can be modified.
@@ -190,7 +188,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
(!B_Base ? 0 : Writer->getSymbolAddress(*B_Base, Layout));
if (!A_Base)
Index = A_SD.getFragment()->getParent()->getOrdinal() + 1;
Index = A->getFragment()->getParent()->getOrdinal() + 1;
Type = MachO::X86_64_RELOC_UNSIGNED;
MachO::any_relocation_info MRE;
@@ -202,7 +200,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
if (B_Base)
RelSymbol = B_Base;
else
Index = B_SD.getFragment()->getParent()->getOrdinal() + 1;
Index = B->getFragment()->getParent()->getOrdinal() + 1;
Type = MachO::X86_64_RELOC_SUBTRACTOR;
} else {
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
@@ -211,7 +209,6 @@ void X86MachObjectWriter::RecordX86_64Relocation(
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
Asm.addLocalUsedInReloc(*Symbol);
}
const MCSymbol &SD = Symbol->getData();
RelSymbol = Asm.getAtom(*Symbol);
// Relocations inside debug sections always use local relocations when
@@ -235,7 +232,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
Layout.getSymbolOffset(*RelSymbol);
} else if (Symbol->isInSection() && !Symbol->isVariable()) {
// The index is the section ordinal (1-based).
Index = SD.getFragment()->getParent()->getOrdinal() + 1;
Index = Symbol->getFragment()->getParent()->getOrdinal() + 1;
Value += Writer->getSymbolAddress(*Symbol, Layout);
if (IsPCRel)
@@ -354,23 +351,21 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
const MCSymbol *A_SD = &A->getData();
if (!A_SD->getFragment())
if (!A->getFragment())
report_fatal_error("symbol '" + A->getName() +
"' can not be undefined in a subtraction expression",
false);
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
uint64_t SecAddr =
Writer->getSectionAddress(A_SD->getFragment()->getParent());
uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
const MCSymbol *B_SD = &B->getSymbol().getData();
const MCSymbol *SB = &B->getSymbol();
if (!B_SD->getFragment())
if (!SB->getFragment())
report_fatal_error("symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression",
false);
@@ -380,10 +375,10 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
// Note that there is no longer any semantic difference between these two
// relocation types from the linkers point of view, this is done solely for
// pedantic compatibility with 'as'.
Type = A_SD->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF :
(unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
Type = A->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(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.