From 159ccc8f51f7cb090058cfd0dcb64453f5681606 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 21 May 2014 23:17:50 +0000 Subject: [PATCH] MC: introduce ability to restrict recorded relocations 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 | 1 + lib/MC/WinCOFFObjectWriter.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/llvm/MC/MCWinCOFFObjectWriter.h b/include/llvm/MC/MCWinCOFFObjectWriter.h index 213481c9090..dad7bb59703 100644 --- a/include/llvm/MC/MCWinCOFFObjectWriter.h +++ b/include/llvm/MC/MCWinCOFFObjectWriter.h @@ -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. diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index 2cc027bfa13..961cbc6a8f7 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -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, -- 2.34.1