1 //===-- CSKYELFObjectWriter.cpp - CSKY ELF Writer -------------------------===//
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 //===----------------------------------------------------------------------===//
8
9 #include "CSKYMCTargetDesc.h"
10 #include "llvm/MC/MCContext.h"
11 #include "llvm/MC/MCELFObjectWriter.h"
12 #include "llvm/MC/MCObjectWriter.h"
13
14 #define DEBUG_TYPE "csky-elf-object-writer"
15
16 using namespace llvm;
17
18 namespace {
19
20 class CSKYELFObjectWriter : public MCELFObjectTargetWriter {
21 public:
CSKYELFObjectWriter(uint8_t OSABI=0)22 CSKYELFObjectWriter(uint8_t OSABI = 0)
23 : MCELFObjectTargetWriter(false, OSABI, ELF::EM_CSKY, true){};
~CSKYELFObjectWriter()24 ~CSKYELFObjectWriter() {}
25
26 unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
27 const MCFixup &Fixup, bool IsPCRel) const override;
28 };
29
30 } // namespace
31
getRelocType(MCContext & Ctx,const MCValue & Target,const MCFixup & Fixup,bool IsPCRel) const32 unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
33 const MCValue &Target,
34 const MCFixup &Fixup,
35 bool IsPCRel) const {
36 // Determine the type of the relocation.
37 switch ((unsigned)Fixup.getKind()) {
38 default:
39 llvm_unreachable("invalid fixup kind!");
40 }
41 }
42
createCSKYELFObjectWriter()43 std::unique_ptr<MCObjectTargetWriter> llvm::createCSKYELFObjectWriter() {
44 return std::make_unique<CSKYELFObjectWriter>();
45 }
46