MC: introduce ability to restrict recorded relocations
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 21 May 2014 23:17:50 +0000 (23:17 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 21 May 2014 23:17:50 +0000 (23:17 +0000)
Add support to allow a target specific COFF object writer to restrict the
recorded resolutions in the emitted object files.  This is motivated by the need
in Windows on ARM, where an intermediate relocation needs to be prevented from
being emitted in the object file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209336 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCWinCOFFObjectWriter.h
lib/MC/WinCOFFObjectWriter.cpp

index 213481c9090cfed2d8e4aefd95ec33e2c4cfa31d..dad7bb597039ba31039eeea1d84ab57518b9b9ea 100644 (file)
@@ -30,6 +30,7 @@ namespace llvm {
     virtual unsigned getRelocType(const MCValue &Target,
                                   const MCFixup &Fixup,
                                   bool IsCrossSection) const = 0;
+    virtual bool recordRelocation(const MCFixup &) const { return true; }
   };
 
   /// \brief Construct a new Win COFF writer instance.
index 2cc027bfa136c34b5c09c07176001fc7578f1da5..961cbc6a8f7d67966dcec72febb00c389553555c 100644 (file)
@@ -808,7 +808,8 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
     }
   }
 
-  coff_section->Relocations.push_back(Reloc);
+  if (TargetObjectWriter->recordRelocation(Fixup))
+    coff_section->Relocations.push_back(Reloc);
 }
 
 void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,