LLVM  8.0.1
MSP430ELFObjectWriter.cpp
Go to the documentation of this file.
1 //===-- MSP430ELFObjectWriter.cpp - MSP430 ELF Writer ---------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
12 
15 #include "llvm/MC/MCFixup.h"
16 #include "llvm/MC/MCObjectWriter.h"
17 #include "llvm/MC/MCValue.h"
19 
20 using namespace llvm;
21 
22 namespace {
23 class MSP430ELFObjectWriter : public MCELFObjectTargetWriter {
24 public:
25  MSP430ELFObjectWriter(uint8_t OSABI)
27  /*HasRelocationAddend*/ true) {}
28 
29  ~MSP430ELFObjectWriter() override {}
30 
31 protected:
32  unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
33  const MCFixup &Fixup, bool IsPCRel) const override {
34  // Translate fixup kind to ELF relocation type.
35  switch ((unsigned)Fixup.getKind()) {
36  case FK_Data_1: return ELF::R_MSP430_8;
37  case FK_Data_2: return ELF::R_MSP430_16_BYTE;
38  case FK_Data_4: return ELF::R_MSP430_32;
39  case MSP430::fixup_32: return ELF::R_MSP430_32;
40  case MSP430::fixup_10_pcrel: return ELF::R_MSP430_10_PCREL;
41  case MSP430::fixup_16: return ELF::R_MSP430_16;
42  case MSP430::fixup_16_pcrel: return ELF::R_MSP430_16_PCREL;
43  case MSP430::fixup_16_byte: return ELF::R_MSP430_16_BYTE;
44  case MSP430::fixup_16_pcrel_byte: return ELF::R_MSP430_16_PCREL_BYTE;
45  case MSP430::fixup_2x_pcrel: return ELF::R_MSP430_2X_PCREL;
46  case MSP430::fixup_rl_pcrel: return ELF::R_MSP430_RL_PCREL;
47  case MSP430::fixup_8: return ELF::R_MSP430_8;
48  case MSP430::fixup_sym_diff: return ELF::R_MSP430_SYM_DIFF;
49  default:
50  llvm_unreachable("Invalid fixup kind");
51  }
52  }
53 };
54 } // end of anonymous namespace
55 
56 std::unique_ptr<MCObjectTargetWriter>
58  return llvm::make_unique<MSP430ELFObjectWriter>(OSABI);
59 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
block Block Frequency true
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:74
static unsigned getRelocType(const MCValue &Target, const MCFixupKind FixupKind, const bool IsPCRel)
Translates generic PPC fixup kind to Mach-O/PPC relocation type enum.
A four-byte fixup.
Definition: MCFixup.h:26
Context object for machine code objects.
Definition: MCContext.h:63
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
A one-byte fixup.
Definition: MCFixup.h:24
std::unique_ptr< MCObjectTargetWriter > createMSP430ELFObjectWriter(uint8_t OSABI)
Target - Wrapper for Target specific information.
A two-byte fixup.
Definition: MCFixup.h:25
MCFixupKind getKind() const
Definition: MCFixup.h:123