1 //===- MipsWinCOFFObjectWriter.cpp------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===---------------------------------------------------------------------===//
9 #include "MCTargetDesc/MipsFixupKinds.h"
10 #include "MCTargetDesc/MipsMCTargetDesc.h"
11 #include "llvm/BinaryFormat/COFF.h"
12 #include "llvm/MC/MCContext.h"
13 #include "llvm/MC/MCWinCOFFObjectWriter.h"
19 class MipsWinCOFFObjectWriter
: public MCWinCOFFObjectTargetWriter
{
21 MipsWinCOFFObjectWriter();
23 unsigned getRelocType(MCContext
&Ctx
, const MCValue
&Target
,
24 const MCFixup
&Fixup
, bool IsCrossSection
,
25 const MCAsmBackend
&MAB
) const override
;
28 } // end anonymous namespace
30 MipsWinCOFFObjectWriter::MipsWinCOFFObjectWriter()
31 : MCWinCOFFObjectTargetWriter(COFF::IMAGE_FILE_MACHINE_R4000
) {}
33 unsigned MipsWinCOFFObjectWriter::getRelocType(MCContext
&Ctx
,
34 const MCValue
&Target
,
37 const MCAsmBackend
&MAB
) const {
38 unsigned FixupKind
= Fixup
.getKind();
42 return COFF::IMAGE_REL_MIPS_REFWORD
;
43 case Mips::fixup_Mips_26
:
44 return COFF::IMAGE_REL_MIPS_JMPADDR
;
45 case Mips::fixup_Mips_HI16
:
46 return COFF::IMAGE_REL_MIPS_REFHI
;
47 case Mips::fixup_Mips_LO16
:
48 return COFF::IMAGE_REL_MIPS_REFLO
;
50 Ctx
.reportError(Fixup
.getLoc(), "unsupported relocation type");
51 return COFF::IMAGE_REL_MIPS_REFWORD
;
55 std::unique_ptr
<MCObjectTargetWriter
> llvm::createMipsWinCOFFObjectWriter() {
56 return std::make_unique
<MipsWinCOFFObjectWriter
>();