LLVM
8.0.1
lib
Target
MSP430
MCTargetDesc
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
10
#include "
MCTargetDesc/MSP430FixupKinds.h
"
11
#include "
MCTargetDesc/MSP430MCTargetDesc.h
"
12
13
#include "
MCTargetDesc/MSP430MCTargetDesc.h
"
14
#include "
llvm/MC/MCELFObjectWriter.h
"
15
#include "
llvm/MC/MCFixup.h
"
16
#include "
llvm/MC/MCObjectWriter.h
"
17
#include "
llvm/MC/MCValue.h
"
18
#include "
llvm/Support/ErrorHandling.h
"
19
20
using namespace
llvm
;
21
22
namespace
{
23
class
MSP430ELFObjectWriter :
public
MCELFObjectTargetWriter
{
24
public
:
25
MSP430ELFObjectWriter(uint8_t OSABI)
26
:
MCELFObjectTargetWriter
(
false
, OSABI, ELF::
EM_MSP430
,
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>
57
llvm::createMSP430ELFObjectWriter
(uint8_t OSABI) {
58
return
llvm::make_unique<MSP430ELFObjectWriter>(OSABI);
59
}
llvm::MSP430::fixup_16
Definition:
MSP430FixupKinds.h:30
llvm::MSP430::fixup_16_byte
Definition:
MSP430FixupKinds.h:34
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:24
llvm::MSP430::fixup_10_pcrel
Definition:
MSP430FixupKinds.h:28
llvm::MCValue
This represents an "assembler immediate".
Definition:
MCValue.h:40
true
block Block Frequency true
Definition:
BlockFrequencyInfo.cpp:293
llvm::MCFixup
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition:
MCFixup.h:74
llvm::MSP430::fixup_8
Definition:
MSP430FixupKinds.h:42
llvm::ELF::EM_MSP430
Definition:
ELF.h:218
getRelocType
static unsigned getRelocType(const MCValue &Target, const MCFixupKind FixupKind, const bool IsPCRel)
Translates generic PPC fixup kind to Mach-O/PPC relocation type enum.
Definition:
PPCMachObjectWriter.cpp:83
false
Definition:
StackSlotColoring.cpp:142
llvm::FK_Data_4
A four-byte fixup.
Definition:
MCFixup.h:26
llvm::MCContext
Context object for machine code objects.
Definition:
MCContext.h:63
llvm::MSP430::fixup_2x_pcrel
Definition:
MSP430FixupKinds.h:38
llvm::MSP430::fixup_16_pcrel
Definition:
MSP430FixupKinds.h:32
MSP430FixupKinds.h
MCELFObjectWriter.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:
ErrorHandling.h:136
llvm::FK_Data_1
A one-byte fixup.
Definition:
MCFixup.h:24
llvm::MSP430::fixup_rl_pcrel
Definition:
MSP430FixupKinds.h:40
ErrorHandling.h
llvm::createMSP430ELFObjectWriter
std::unique_ptr< MCObjectTargetWriter > createMSP430ELFObjectWriter(uint8_t OSABI)
Definition:
MSP430ELFObjectWriter.cpp:57
llvm::MSP430::fixup_16_pcrel_byte
Definition:
MSP430FixupKinds.h:36
MCValue.h
llvm::Target
Target - Wrapper for Target specific information.
Definition:
TargetRegistry.h:120
MSP430MCTargetDesc.h
llvm::MSP430::fixup_sym_diff
Definition:
MSP430FixupKinds.h:44
MCObjectWriter.h
llvm::MCELFObjectTargetWriter
Definition:
MCELFObjectWriter.h:55
llvm::MSP430::fixup_32
Definition:
MSP430FixupKinds.h:26
llvm::FK_Data_2
A two-byte fixup.
Definition:
MCFixup.h:25
llvm::MCFixup::getKind
MCFixupKind getKind() const
Definition:
MCFixup.h:123
MCFixup.h
Generated on Sun Dec 20 2020 13:57:23 for LLVM by
1.8.13