1 //===-- CSKYELFObjectWriter.cpp - CSKY ELF Writer -------------------------===//
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 "CSKYMCTargetDesc.h"
10 #include "llvm/MC/MCContext.h"
11 #include "llvm/MC/MCELFObjectWriter.h"
12 #include "llvm/MC/MCObjectWriter.h"
14 #define DEBUG_TYPE "csky-elf-object-writer"
20 class CSKYELFObjectWriter
: public MCELFObjectTargetWriter
{
22 CSKYELFObjectWriter(uint8_t OSABI
= 0)
23 : MCELFObjectTargetWriter(false, OSABI
, ELF::EM_CSKY
, true){};
24 ~CSKYELFObjectWriter() {}
26 unsigned getRelocType(MCContext
&Ctx
, const MCValue
&Target
,
27 const MCFixup
&Fixup
, bool IsPCRel
) const override
;
32 unsigned CSKYELFObjectWriter::getRelocType(MCContext
&Ctx
,
33 const MCValue
&Target
,
36 // Determine the type of the relocation.
37 switch ((unsigned)Fixup
.getKind()) {
39 llvm_unreachable("invalid fixup kind!");
43 std::unique_ptr
<MCObjectTargetWriter
> llvm::createCSKYELFObjectWriter() {
44 return std::make_unique
<CSKYELFObjectWriter
>();