Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MCTargetDesc/MipsWinCOFFObjectWriter.cpp
213845 views
//===- MipsWinCOFFObjectWriter.cpp------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===---------------------------------------------------------------------===//78#include "MCTargetDesc/MipsFixupKinds.h"9#include "MCTargetDesc/MipsMCTargetDesc.h"10#include "llvm/BinaryFormat/COFF.h"11#include "llvm/MC/MCContext.h"12#include "llvm/MC/MCWinCOFFObjectWriter.h"1314using namespace llvm;1516namespace {1718class MipsWinCOFFObjectWriter : public MCWinCOFFObjectTargetWriter {19public:20MipsWinCOFFObjectWriter();2122unsigned getRelocType(MCContext &Ctx, const MCValue &Target,23const MCFixup &Fixup, bool IsCrossSection,24const MCAsmBackend &MAB) const override;25};2627} // end anonymous namespace2829MipsWinCOFFObjectWriter::MipsWinCOFFObjectWriter()30: MCWinCOFFObjectTargetWriter(COFF::IMAGE_FILE_MACHINE_R4000) {}3132unsigned MipsWinCOFFObjectWriter::getRelocType(MCContext &Ctx,33const MCValue &Target,34const MCFixup &Fixup,35bool IsCrossSection,36const MCAsmBackend &MAB) const {37unsigned FixupKind = Fixup.getKind();3839switch (FixupKind) {40case FK_Data_4:41return COFF::IMAGE_REL_MIPS_REFWORD;42case FK_SecRel_2:43return COFF::IMAGE_REL_MIPS_SECTION;44case FK_SecRel_4:45return COFF::IMAGE_REL_MIPS_SECREL;46case Mips::fixup_Mips_26:47return COFF::IMAGE_REL_MIPS_JMPADDR;48case Mips::fixup_Mips_HI16:49return COFF::IMAGE_REL_MIPS_REFHI;50case Mips::fixup_Mips_LO16:51return COFF::IMAGE_REL_MIPS_REFLO;52default:53Ctx.reportError(Fixup.getLoc(), "unsupported relocation type");54return COFF::IMAGE_REL_MIPS_REFWORD;55}56}5758std::unique_ptr<MCObjectTargetWriter> llvm::createMipsWinCOFFObjectWriter() {59return std::make_unique<MipsWinCOFFObjectWriter>();60}616263