[llvm] r306053 - Simplify WinCOFFObjectWriter::recordRelocation.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 22 13:27:33 PDT 2017
Author: rafael
Date: Thu Jun 22 15:27:33 2017
New Revision: 306053
URL: http://llvm.org/viewvc/llvm-project?rev=306053&view=rev
Log:
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.
Modified:
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=306053&r1=306052&r2=306053&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Thu Jun 22 15:27:33 2017
@@ -735,7 +735,6 @@ void WinCOFFObjectWriter::recordRelocati
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::recordRelocati
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::recordRelocati
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::recordRelocati
++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?
More information about the llvm-commits
mailing list