[Darwin][Driver][clang] apple-none-macho orders the resource directory after internal...
[llvm-project.git] / llvm / lib / Target / Mips / MCTargetDesc / MipsWinCOFFObjectWriter.cpp
blob94187c71ba70d6e030a279a4908a810d9b4e9453
1 //===- MipsWinCOFFObjectWriter.cpp------------------------------*- C++ -*-===//
2 //
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
6 //
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"
15 using namespace llvm;
17 namespace {
19 class MipsWinCOFFObjectWriter : public MCWinCOFFObjectTargetWriter {
20 public:
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,
35 const MCFixup &Fixup,
36 bool IsCrossSection,
37 const MCAsmBackend &MAB) const {
38 unsigned FixupKind = Fixup.getKind();
40 switch (FixupKind) {
41 case FK_Data_4:
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;
49 default:
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>();