diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-05-20 15:16:14 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-05-20 15:16:14 +0000 |
commit | 08b8726de3a8a8014ed2f422e0952d5389fad26f (patch) | |
tree | 9f96f0d74e3fc75f0891ded17c415129f063090d /llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp | |
parent | 5266ad9bec7ce11498edef67a4d2942366332f37 (diff) | |
download | bcm5719-llvm-08b8726de3a8a8014ed2f422e0952d5389fad26f.tar.gz bcm5719-llvm-08b8726de3a8a8014ed2f422e0952d5389fad26f.zip |
MC: Use MCSymbol in MachObjectWriter, NFC
Replace uses of `MCSymbolData` with `MCSymbol` where both are needed, so
we can remove the backpointer.
llvm-svn: 237799
Diffstat (limited to 'llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp index 2b38da1d988..d5f5f9a005f 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp @@ -44,9 +44,8 @@ class ARMMachObjectWriter : public MCMachObjectTargetWriter { bool requiresExternRelocation(MachObjectWriter *Writer, const MCAssembler &Asm, - const MCFragment &Fragment, - unsigned RelocType, const MCSymbolData *SD, - uint64_t FixedValue); + const MCFragment &Fragment, unsigned RelocType, + const MCSymbol &S, uint64_t FixedValue); public: ARMMachObjectWriter(bool Is64Bit, uint32_t CPUType, @@ -309,10 +308,10 @@ bool ARMMachObjectWriter::requiresExternRelocation(MachObjectWriter *Writer, const MCAssembler &Asm, const MCFragment &Fragment, unsigned RelocType, - const MCSymbolData *SD, + const MCSymbol &S, uint64_t FixedValue) { // Most cases can be identified purely from the symbol. - if (Writer->doesSymbolRequireExternRelocation(SD)) + if (Writer->doesSymbolRequireExternRelocation(S)) return true; int64_t Value = (int64_t)FixedValue; // The displacement is signed. int64_t Range; @@ -334,8 +333,7 @@ bool ARMMachObjectWriter::requiresExternRelocation(MachObjectWriter *Writer, // 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( - SD->getSymbol().getSection()); + const MCSectionData &SymSD = Asm.getSectionData(S.getSection()); Value += Writer->getSectionAddress(&SymSD); Value -= Writer->getSectionAddress(Fragment.getParent()); // If the resultant value would be out of range for an internal relocation, @@ -375,9 +373,9 @@ void ARMMachObjectWriter::RecordRelocation(MachObjectWriter *Writer, } // Get the symbol data, if any. - const MCSymbolData *SD = nullptr; + const MCSymbol *A = nullptr; if (Target.getSymA()) - SD = &Asm.getSymbolData(Target.getSymA()->getSymbol()); + A = &Target.getSymA()->getSymbol(); // FIXME: For other platforms, we need to use scattered relocations for // internal relocations with offsets. If this is an internal relocation with @@ -387,7 +385,7 @@ void ARMMachObjectWriter::RecordRelocation(MachObjectWriter *Writer, uint32_t Offset = Target.getConstant(); if (IsPCRel && RelocType == MachO::ARM_RELOC_VANILLA) Offset += 1 << Log2Size; - if (Offset && SD && !Writer->doesSymbolRequireExternRelocation(SD)) + if (Offset && A && !Writer->doesSymbolRequireExternRelocation(*A)) return RecordARMScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup, Target, RelocType, Log2Size, FixedValue); @@ -404,29 +402,28 @@ void ARMMachObjectWriter::RecordRelocation(MachObjectWriter *Writer, "not yet implemented"); } else { // Resolve constant variables. - if (SD->getSymbol().isVariable()) { + if (A->isVariable()) { int64_t Res; - if (SD->getSymbol().getVariableValue()->EvaluateAsAbsolute( - Res, Layout, Writer->getSectionAddressMap())) { + if (A->getVariableValue()->EvaluateAsAbsolute( + Res, Layout, Writer->getSectionAddressMap())) { FixedValue = Res; return; } } // Check whether we need an external or internal relocation. - if (requiresExternRelocation(Writer, Asm, *Fragment, RelocType, SD, + if (requiresExternRelocation(Writer, Asm, *Fragment, RelocType, *A, FixedValue)) { - RelSymbol = &SD->getSymbol(); + RelSymbol = A; // For external relocations, make sure to offset the fixup value to // compensate for the addend of the symbol address, if it was // undefined. This occurs with weak definitions, for example. - if (!SD->getSymbol().isUndefined()) - FixedValue -= Layout.getSymbolOffset(SD->getSymbol()); + if (!A->isUndefined()) + FixedValue -= Layout.getSymbolOffset(*A); } else { // The index is the section ordinal (1-based). - const MCSectionData &SymSD = Asm.getSectionData( - SD->getSymbol().getSection()); + const MCSectionData &SymSD = Asm.getSectionData(A->getSection()); Index = SymSD.getOrdinal() + 1; FixedValue += Writer->getSectionAddress(&SymSD); } |