aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-12-24 21:22:02 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-12-24 21:22:02 +0000
commitfea753b397823c340608925eb7f3256a64a30017 (patch)
tree91016581c74485267516a02e4066ef865445cc0d /lib/MC/ELFObjectWriter.cpp
parenta112087e4298ca8ec1bc8aef8a2b272e49faa7ac (diff)
downloadexternal_llvm-fea753b397823c340608925eb7f3256a64a30017.zip
external_llvm-fea753b397823c340608925eb7f3256a64a30017.tar.gz
external_llvm-fea753b397823c340608925eb7f3256a64a30017.tar.bz2
Merge IsFixupFullyResolved and IsSymbolRefDifferenceFullyResolved. We now
have a single point where targets test if a relocation is needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122549 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/ELFObjectWriter.cpp')
-rw-r--r--lib/MC/ELFObjectWriter.cpp58
1 files changed, 16 insertions, 42 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index b6e1223..ef6e0f1 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -344,10 +344,12 @@ namespace {
MCDataFragment *F,
const MCSectionData *SD);
- virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
- const MCValue Target,
- bool IsPCRel,
- const MCFragment *DF) const;
+ virtual bool
+ IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
+ const MCSymbolData &DataA,
+ const MCFragment &FB,
+ bool InSet,
+ bool IsPCRel) const;
virtual void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout);
virtual void WriteSection(MCAssembler &Asm,
@@ -1154,50 +1156,22 @@ void ELFObjectWriter::CreateMetadataSections(MCAssembler &Asm,
}
}
-bool ELFObjectWriter::IsFixupFullyResolved(const MCAssembler &Asm,
- const MCValue Target,
- bool IsPCRel,
- const MCFragment *DF) const {
- // If this is a PCrel relocation, find the section this fixup value is
- // relative to.
- const MCSection *BaseSection = 0;
- if (IsPCRel) {
- BaseSection = &DF->getParent()->getSection();
- assert(BaseSection);
- }
-
- const MCSection *SectionA = 0;
- const MCSymbol *SymbolA = 0;
- if (const MCSymbolRefExpr *A = Target.getSymA()) {
- SymbolA = &A->getSymbol();
- SectionA = &SymbolA->AliasedSymbol().getSection();
- }
-
- const MCSection *SectionB = 0;
- const MCSymbol *SymbolB = 0;
- if (const MCSymbolRefExpr *B = Target.getSymB()) {
- SymbolB = &B->getSymbol();
- SectionB = &SymbolB->AliasedSymbol().getSection();
- }
-
- if (!BaseSection)
- return SectionA == SectionB;
-
- if (SymbolB)
- return false;
-
- // Absolute address but PCrel instruction, so we need a relocation.
- if (!SymbolA)
- return false;
-
+bool
+ELFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
+ const MCSymbolData &DataA,
+ const MCFragment &FB,
+ bool InSet,
+ bool IsPCRel) const {
// FIXME: This is in here just to match gnu as output. If the two ends
// are in the same section, there is nothing that the linker can do to
// break it.
- const MCSymbolData &DataA = Asm.getSymbolData(*SymbolA);
if (DataA.isExternal())
return false;
- return BaseSection == SectionA;
+ const MCSection &SecA = DataA.getSymbol().AliasedSymbol().getSection();
+ const MCSection &SecB = FB.getParent()->getSection();
+ // On ELF A - B is absolute if A and B are in the same section.
+ return &SecA == &SecB;
}
void ELFObjectWriter::CreateGroupSections(MCAssembler &Asm,