46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
|
//===-- CSKYELFObjectWriter.cpp - CSKY ELF Writer -------------------------===//
|
||
|
//
|
||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
|
||
|
#include "CSKYMCTargetDesc.h"
|
||
|
#include "llvm/MC/MCContext.h"
|
||
|
#include "llvm/MC/MCELFObjectWriter.h"
|
||
|
#include "llvm/MC/MCObjectWriter.h"
|
||
|
|
||
|
#define DEBUG_TYPE "csky-elf-object-writer"
|
||
|
|
||
|
using namespace llvm;
|
||
|
|
||
|
namespace {
|
||
|
|
||
|
class CSKYELFObjectWriter : public MCELFObjectTargetWriter {
|
||
|
public:
|
||
|
CSKYELFObjectWriter(uint8_t OSABI = 0)
|
||
|
: MCELFObjectTargetWriter(false, OSABI, ELF::EM_CSKY, true){};
|
||
|
~CSKYELFObjectWriter() {}
|
||
|
|
||
|
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
|
||
|
const MCFixup &Fixup, bool IsPCRel) const override;
|
||
|
};
|
||
|
|
||
|
} // namespace
|
||
|
|
||
|
unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
|
||
|
const MCValue &Target,
|
||
|
const MCFixup &Fixup,
|
||
|
bool IsPCRel) const {
|
||
|
// Determine the type of the relocation.
|
||
|
switch ((unsigned)Fixup.getKind()) {
|
||
|
default:
|
||
|
llvm_unreachable("invalid fixup kind!");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
std::unique_ptr<MCObjectTargetWriter> llvm::createCSKYELFObjectWriter() {
|
||
|
return std::make_unique<CSKYELFObjectWriter>();
|
||
|
}
|