diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-06-22 20:27:33 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-06-22 20:27:33 +0000 |
| commit | 656669bae471c1a5157e01527fe3c50fa745f20d (patch) | |
| tree | 45e314d8fb3e8277d74611a1b1e70c9305c9fb5b /llvm | |
| parent | 72c90c87f81b40b2ec6c25a817577add1d816546 (diff) | |
| download | bcm5719-llvm-656669bae471c1a5157e01527fe3c50fa745f20d.tar.gz bcm5719-llvm-656669bae471c1a5157e01527fe3c50fa745f20d.zip | |
Simplify WinCOFFObjectWriter::recordRelocation.
It looks like that when this code was written recordRelocation could
be called with A-B where A and B are in the same section. The
expression evaluation logic these days makes sure those are folded, so
some of this code was dead.
llvm-svn: 306053
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/MC/WinCOFFObjectWriter.cpp | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp index 53dee3e8b9f..ec1fa0801a0 100644 --- a/llvm/lib/MC/WinCOFFObjectWriter.cpp +++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp @@ -735,7 +735,6 @@ void WinCOFFObjectWriter::recordRelocation( COFFSection *Sec = SectionMap[MCSec]; const MCSymbolRefExpr *SymB = Target.getSymB(); - bool CrossSection = false; if (SymB) { const MCSymbol *B = &SymB->getSymbol(); @@ -755,20 +754,12 @@ void WinCOFFObjectWriter::recordRelocation( return; } - CrossSection = &A.getSection() != &B->getSection(); + assert(&A.getSection() != &B->getSection() && + "This doesn't need a relocation"); // Offset of the symbol in the section int64_t OffsetOfB = Layout.getSymbolOffset(*B); - // In the case where we have SymbA and SymB, we just need to store the delta - // between the two symbols. Update FixedValue to account for the delta, and - // skip recording the relocation. - if (!CrossSection) { - int64_t OffsetOfA = Layout.getSymbolOffset(A); - FixedValue = (OffsetOfA - OffsetOfB) + Target.getConstant(); - return; - } - // Offset of the relocation in the section int64_t OffsetOfRelocation = Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); @@ -784,7 +775,7 @@ void WinCOFFObjectWriter::recordRelocation( Reloc.Data.VirtualAddress = Layout.getFragmentOffset(Fragment); // Turn relocations for temporary symbols into section relocations. - if (A.isTemporary() || CrossSection) { + if (A.isTemporary() || SymB) { MCSection *TargetSection = &A.getSection(); assert( SectionMap.find(TargetSection) != SectionMap.end() && @@ -801,8 +792,8 @@ void WinCOFFObjectWriter::recordRelocation( ++Reloc.Symb->Relocations; Reloc.Data.VirtualAddress += Fixup.getOffset(); - Reloc.Data.Type = TargetObjectWriter->getRelocType( - Target, Fixup, CrossSection, Asm.getBackend()); + Reloc.Data.Type = + TargetObjectWriter->getRelocType(Target, Fixup, SymB, Asm.getBackend()); // FIXME: Can anyone explain what this does other than adjust for the size // of the offset? |

