1 //===-- HexagonELFObjectWriter.cpp - Hexagon Target Descriptions ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "llvm/MC/MCAssembler.h"
12 #include "llvm/MC/MCELFObjectWriter.h"
13 #include "llvm/Support/Debug.h"
14 #include "llvm/Support/raw_ostream.h"
16 #define DEBUG_TYPE "hexagon-elf-writer"
19 using namespace Hexagon;
23 class HexagonELFObjectWriter : public MCELFObjectTargetWriter {
28 HexagonELFObjectWriter(uint8_t OSABI, StringRef C);
30 virtual unsigned GetRelocType(MCValue const &Target, MCFixup const &Fixup,
31 bool IsPCRel) const override;
35 HexagonELFObjectWriter::HexagonELFObjectWriter(uint8_t OSABI, StringRef C)
36 : MCELFObjectTargetWriter(/*Is64bit*/ false, OSABI, ELF::EM_HEXAGON,
37 /*HasRelocationAddend*/ true),
40 unsigned HexagonELFObjectWriter::GetRelocType(MCValue const &/*Target*/,
43 unsigned Type = (unsigned)ELF::R_HEX_NONE;
44 llvm::MCFixupKind Kind = Fixup.getKind();
48 DEBUG(dbgs() << "unrecognized relocation " << Fixup.getKind() << "\n");
49 llvm_unreachable("Unimplemented Fixup kind!");
52 Type = (IsPCRel) ? ELF::R_HEX_32_PCREL : ELF::R_HEX_32;
58 MCObjectWriter *llvm::createHexagonELFObjectWriter(raw_ostream &OS,
61 MCELFObjectTargetWriter *MOTW = new HexagonELFObjectWriter(OSABI, CPU);
62 return createELFObjectWriter(MOTW, OS, /*IsLittleEndian*/ true);