[llvm] r237502 - MC: Use MCSymbol in RelAndSymbol, NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri May 15 18:14:19 PDT 2015
Author: dexonsmith
Date: Fri May 15 20:14:19 2015
New Revision: 237502
URL: http://llvm.org/viewvc/llvm-project?rev=237502&view=rev
Log:
MC: Use MCSymbol in RelAndSymbol, NFC
Switch from `MCSymbolData` to `MCSymbol`.
Modified:
llvm/trunk/include/llvm/MC/MCMachObjectWriter.h
llvm/trunk/lib/MC/MachObjectWriter.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/MCMachObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCMachObjectWriter.h?rev=237502&r1=237501&r2=237502&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCMachObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MCMachObjectWriter.h Fri May 15 20:14:19 2015
@@ -96,9 +96,9 @@ class MachObjectWriter : public MCObject
/// @{
struct RelAndSymbol {
- const MCSymbolData *Sym;
+ const MCSymbol *Sym;
MachO::any_relocation_info MRE;
- RelAndSymbol(const MCSymbolData *Sym, const MachO::any_relocation_info &MRE)
+ RelAndSymbol(const MCSymbol *Sym, const MachO::any_relocation_info &MRE)
: Sym(Sym), MRE(MRE) {}
};
@@ -223,7 +223,7 @@ public:
// to a symbol it should be passed as \p RelSymbol so that it can be updated
// afterwards. If the relocation doesn't refer to a symbol, nullptr should be
// used.
- void addRelocation(const MCSymbolData *RelSymbol, const MCSectionData *SD,
+ void addRelocation(const MCSymbol *RelSymbol, const MCSectionData *SD,
MachO::any_relocation_info &MRE) {
RelAndSymbol P(RelSymbol, MRE);
Relocations[SD].push_back(P);
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=237502&r1=237501&r2=237502&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Fri May 15 20:14:19 2015
@@ -633,7 +633,7 @@ void MachObjectWriter::ComputeSymbolTabl
continue;
// Set the Index and the IsExtern bit.
- unsigned Index = Rel.Sym->getIndex();
+ unsigned Index = Rel.Sym->getData().getIndex();
assert(isInt<24>(Index));
if (IsLittleEndian)
Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (~0U << 24)) | Index | (1 << 27);
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=237502&r1=237501&r2=237502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp Fri May 15 20:14:19 2015
@@ -230,8 +230,7 @@ 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 ? &A_Base->getData() : nullptr,
- Fragment->getParent(), MRE);
+ Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
return;
} else if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
Target.getSymB()->getKind() != MCSymbolRefExpr::VK_None)
@@ -282,8 +281,7 @@ 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 ? &A_Base->getData() : nullptr,
- Fragment->getParent(), MRE);
+ Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
RelSymbol = B_Base;
Type = MachO::ARM64_RELOC_SUBTRACTOR;
@@ -392,8 +390,7 @@ void AArch64MachObjectWriter::RecordRelo
MRE.r_word0 = FixupOffset;
MRE.r_word1 =
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(RelSymbol ? &RelSymbol->getData() : nullptr,
- Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
// Now set up the Addend relocation.
Type = MachO::ARM64_RELOC_ADDEND;
@@ -414,8 +411,7 @@ void AArch64MachObjectWriter::RecordRelo
MRE.r_word0 = FixupOffset;
MRE.r_word1 =
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(RelSymbol ? &RelSymbol->getData() : nullptr,
- Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, Fragment->getParent(), 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=237502&r1=237501&r2=237502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp Fri May 15 20:14:19 2015
@@ -396,7 +396,7 @@ void ARMMachObjectWriter::RecordRelocati
uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
unsigned Index = 0;
unsigned Type = 0;
- const MCSymbolData *RelSymbol = nullptr;
+ const MCSymbol *RelSymbol = nullptr;
if (Target.isAbsolute()) { // constant
// FIXME!
@@ -416,7 +416,7 @@ void ARMMachObjectWriter::RecordRelocati
// Check whether we need an external or internal relocation.
if (requiresExternRelocation(Writer, Asm, *Fragment, RelocType, SD,
FixedValue)) {
- RelSymbol = SD;
+ RelSymbol = &SD->getSymbol();
// For external relocations, make sure to offset the fixup value to
// compensate for the addend of the symbol address, if it was
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=237502&r1=237501&r2=237502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp Fri May 15 20:14:19 2015
@@ -333,7 +333,7 @@ void PPCMachObjectWriter::RecordPPCReloc
unsigned Index = 0;
unsigned Type = RelocType;
- const MCSymbolData *RelSymbol = nullptr;
+ const MCSymbol *RelSymbol = nullptr;
if (Target.isAbsolute()) { // constant
// SymbolNum of 0 indicates the absolute section.
//
@@ -355,7 +355,7 @@ void PPCMachObjectWriter::RecordPPCReloc
// Check whether we need an external or internal relocation.
if (Writer->doesSymbolRequireExternRelocation(SD)) {
- RelSymbol = SD;
+ RelSymbol = &SD->getSymbol();
// 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.
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=237502&r1=237501&r2=237502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp Fri May 15 20:14:19 2015
@@ -199,8 +199,7 @@ void X86MachObjectWriter::RecordX86_64Re
MRE.r_word0 = FixupOffset;
MRE.r_word1 =
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(A_Base ? &A_Base->getData() : nullptr,
- Fragment->getParent(), MRE);
+ Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
if (B_Base)
RelSymbol = B_Base;
@@ -339,8 +338,7 @@ void X86MachObjectWriter::RecordX86_64Re
MRE.r_word0 = FixupOffset;
MRE.r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
(IsExtern << 27) | (Type << 28);
- Writer->addRelocation(RelSymbol ? &RelSymbol->getData() : nullptr,
- Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
}
bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
@@ -453,9 +451,6 @@ void X86MachObjectWriter::RecordTLVPRelo
uint32_t Value = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
unsigned IsPCRel = 0;
- // Get the symbol data.
- const MCSymbolData *SD_A = &Asm.getSymbolData(Target.getSymA()->getSymbol());
-
// We're only going to have a second symbol in pic mode and it'll be a
// subtraction from the picbase. For 32-bit pic the addend is the difference
// between the picbase and the next address. For 32-bit static the addend is
@@ -479,7 +474,8 @@ void X86MachObjectWriter::RecordTLVPRelo
MRE.r_word0 = Value;
MRE.r_word1 =
(IsPCRel << 24) | (Log2Size << 25) | (MachO::GENERIC_RELOC_TLV << 28);
- Writer->addRelocation(SD_A, Fragment->getParent(), MRE);
+ Writer->addRelocation(&Target.getSymA()->getSymbol(), Fragment->getParent(),
+ MRE);
}
void X86MachObjectWriter::RecordX86Relocation(MachObjectWriter *Writer,
@@ -531,7 +527,7 @@ void X86MachObjectWriter::RecordX86Reloc
uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
unsigned Index = 0;
unsigned Type = 0;
- const MCSymbolData *RelSymbol = nullptr;
+ const MCSymbol *RelSymbol = nullptr;
if (Target.isAbsolute()) { // constant
// SymbolNum of 0 indicates the absolute section.
@@ -552,7 +548,7 @@ void X86MachObjectWriter::RecordX86Reloc
// Check whether we need an external or internal relocation.
if (Writer->doesSymbolRequireExternRelocation(SD)) {
- RelSymbol = SD;
+ RelSymbol = &SD->getSymbol();
// 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.
More information about the llvm-commits
mailing list