LLVM
20.0.0git
lib
Target
MSP430
MCTargetDesc
MSP430ELFObjectWriter.cpp
Go to the documentation of this file.
1
//===-- MSP430ELFObjectWriter.cpp - MSP430 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 "
MCTargetDesc/MSP430FixupKinds.h
"
10
#include "
MCTargetDesc/MSP430MCTargetDesc.h
"
11
12
#include "
llvm/MC/MCELFObjectWriter.h
"
13
#include "
llvm/MC/MCFixup.h
"
14
#include "
llvm/MC/MCObjectWriter.h
"
15
#include "
llvm/MC/MCValue.h
"
16
#include "
llvm/Support/ErrorHandling.h
"
17
18
using namespace
llvm
;
19
20
namespace
{
21
class
MSP430ELFObjectWriter :
public
MCELFObjectTargetWriter
{
22
public
:
23
MSP430ELFObjectWriter(uint8_t OSABI)
24
:
MCELFObjectTargetWriter
(
false
, OSABI,
ELF
::
EM_MSP430
,
25
/*HasRelocationAddend*/
true
) {}
26
27
~MSP430ELFObjectWriter()
override
=
default
;
28
29
protected
:
30
unsigned
getRelocType
(
MCContext
&Ctx,
const
MCValue
&
Target
,
31
const
MCFixup
&
Fixup
,
bool
IsPCRel)
const override
{
32
// Translate fixup kind to ELF relocation type.
33
switch
(
Fixup
.getTargetKind()) {
34
case
FK_Data_1
:
return
ELF::R_MSP430_8;
35
case
FK_Data_2
:
return
ELF::R_MSP430_16_BYTE;
36
case
FK_Data_4
:
return
ELF::R_MSP430_32;
37
case
MSP430::fixup_32
:
return
ELF::R_MSP430_32;
38
case
MSP430::fixup_10_pcrel
:
return
ELF::R_MSP430_10_PCREL;
39
case
MSP430::fixup_16
:
return
ELF::R_MSP430_16;
40
case
MSP430::fixup_16_pcrel
:
return
ELF::R_MSP430_16_PCREL;
41
case
MSP430::fixup_16_byte
:
return
ELF::R_MSP430_16_BYTE;
42
case
MSP430::fixup_16_pcrel_byte
:
return
ELF::R_MSP430_16_PCREL_BYTE;
43
case
MSP430::fixup_2x_pcrel
:
return
ELF::R_MSP430_2X_PCREL;
44
case
MSP430::fixup_rl_pcrel
:
return
ELF::R_MSP430_RL_PCREL;
45
case
MSP430::fixup_8
:
return
ELF::R_MSP430_8;
46
case
MSP430::fixup_sym_diff
:
return
ELF::R_MSP430_SYM_DIFF;
47
default
:
48
llvm_unreachable
(
"Invalid fixup kind"
);
49
}
50
}
51
};
52
}
// end of anonymous namespace
53
54
std::unique_ptr<MCObjectTargetWriter>
55
llvm::createMSP430ELFObjectWriter
(uint8_t OSABI) {
56
return
std::make_unique<MSP430ELFObjectWriter>(OSABI);
57
}
true
basic Basic Alias true
Definition:
BasicAliasAnalysis.cpp:1994
MCELFObjectWriter.h
MCFixup.h
MCObjectWriter.h
MCValue.h
MSP430FixupKinds.h
MSP430MCTargetDesc.h
Fixup
PowerPC TLS Dynamic Call Fixup
Definition:
PPCTLSDynamicCall.cpp:340
llvm::MCContext
Context object for machine code objects.
Definition:
MCContext.h:83
llvm::MCELFObjectTargetWriter
Definition:
MCELFObjectWriter.h:55
llvm::MCELFObjectTargetWriter::getRelocType
virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target, const MCFixup &Fixup, bool IsPCRel) const =0
llvm::MCFixup
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition:
MCFixup.h:71
llvm::MCValue
This represents an "assembler immediate".
Definition:
MCValue.h:36
llvm::Target
Target - Wrapper for Target specific information.
Definition:
TargetRegistry.h:144
ErrorHandling.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:
ErrorHandling.h:143
false
Definition:
StackSlotColoring.cpp:194
llvm::ELF::EM_MSP430
@ EM_MSP430
Definition:
ELF.h:223
llvm::MSP430::fixup_32
@ fixup_32
Definition:
MSP430FixupKinds.h:25
llvm::MSP430::fixup_16_byte
@ fixup_16_byte
Definition:
MSP430FixupKinds.h:33
llvm::MSP430::fixup_10_pcrel
@ fixup_10_pcrel
Definition:
MSP430FixupKinds.h:27
llvm::MSP430::fixup_16_pcrel_byte
@ fixup_16_pcrel_byte
Definition:
MSP430FixupKinds.h:35
llvm::MSP430::fixup_8
@ fixup_8
Definition:
MSP430FixupKinds.h:41
llvm::MSP430::fixup_rl_pcrel
@ fixup_rl_pcrel
Definition:
MSP430FixupKinds.h:39
llvm::MSP430::fixup_16
@ fixup_16
Definition:
MSP430FixupKinds.h:29
llvm::MSP430::fixup_2x_pcrel
@ fixup_2x_pcrel
Definition:
MSP430FixupKinds.h:37
llvm::MSP430::fixup_16_pcrel
@ fixup_16_pcrel
Definition:
MSP430FixupKinds.h:31
llvm::MSP430::fixup_sym_diff
@ fixup_sym_diff
Definition:
MSP430FixupKinds.h:43
llvm::logicalview::LVBinaryType::ELF
@ ELF
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
llvm::FK_Data_1
@ FK_Data_1
A one-byte fixup.
Definition:
MCFixup.h:23
llvm::FK_Data_4
@ FK_Data_4
A four-byte fixup.
Definition:
MCFixup.h:25
llvm::FK_Data_2
@ FK_Data_2
A two-byte fixup.
Definition:
MCFixup.h:24
llvm::createMSP430ELFObjectWriter
std::unique_ptr< MCObjectTargetWriter > createMSP430ELFObjectWriter(uint8_t OSABI)
Definition:
MSP430ELFObjectWriter.cpp:55
Generated on Tue Nov 12 2024 16:38:57 for LLVM by
1.9.6