LLVM
20.0.0git
lib
Target
Lanai
MCTargetDesc
LanaiELFObjectWriter.cpp
Go to the documentation of this file.
1
//===-- LanaiELFObjectWriter.cpp - Lanai 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/LanaiBaseInfo.h
"
10
#include "
MCTargetDesc/LanaiFixupKinds.h
"
11
#include "
llvm/BinaryFormat/ELF.h
"
12
#include "
llvm/MC/MCELFObjectWriter.h
"
13
#include "
llvm/MC/MCObjectWriter.h
"
14
#include "
llvm/Support/ErrorHandling.h
"
15
16
using namespace
llvm
;
17
18
namespace
{
19
20
class
LanaiELFObjectWriter :
public
MCELFObjectTargetWriter
{
21
public
:
22
explicit
LanaiELFObjectWriter(
uint8_t
OSABI);
23
24
~LanaiELFObjectWriter()
override
=
default
;
25
26
protected
:
27
unsigned
getRelocType
(
MCContext
&Ctx,
const
MCValue
&
Target
,
28
const
MCFixup
&
Fixup
,
bool
IsPCRel)
const override
;
29
bool
needsRelocateWithSymbol
(
const
MCValue
&Val,
const
MCSymbol
&
Sym
,
30
unsigned
Type
)
const override
;
31
};
32
33
}
// end anonymous namespace
34
35
LanaiELFObjectWriter::LanaiELFObjectWriter(
uint8_t
OSABI)
36
:
MCELFObjectTargetWriter
(
/*Is64Bit_=*/
false
, OSABI,
ELF
::
EM_LANAI
,
37
/*HasRelocationAddend_=*/
true
) {}
38
39
unsigned
LanaiELFObjectWriter::getRelocType(
MCContext
&
/*Ctx*/
,
40
const
MCValue
&
/*Target*/
,
41
const
MCFixup
&
Fixup
,
42
bool
/*IsPCRel*/
)
const
{
43
unsigned
Type
;
44
unsigned
Kind
=
static_cast<
unsigned
>
(
Fixup
.getKind());
45
switch
(Kind) {
46
case
Lanai::FIXUP_LANAI_21
:
47
Type
= ELF::R_LANAI_21;
48
break
;
49
case
Lanai::FIXUP_LANAI_21_F
:
50
Type
= ELF::R_LANAI_21_F;
51
break
;
52
case
Lanai::FIXUP_LANAI_25
:
53
Type
= ELF::R_LANAI_25;
54
break
;
55
case
Lanai::FIXUP_LANAI_32
:
56
case
FK_Data_4
:
57
Type
= ELF::R_LANAI_32;
58
break
;
59
case
Lanai::FIXUP_LANAI_HI16
:
60
Type
= ELF::R_LANAI_HI16;
61
break
;
62
case
Lanai::FIXUP_LANAI_LO16
:
63
Type
= ELF::R_LANAI_LO16;
64
break
;
65
case
Lanai::FIXUP_LANAI_NONE
:
66
Type
= ELF::R_LANAI_NONE;
67
break
;
68
69
default
:
70
llvm_unreachable
(
"Invalid fixup kind!"
);
71
}
72
return
Type
;
73
}
74
75
bool
LanaiELFObjectWriter::needsRelocateWithSymbol(
const
MCValue
&,
76
const
MCSymbol
&,
77
unsigned
Type
)
const
{
78
switch
(
Type
) {
79
case
ELF::R_LANAI_21:
80
case
ELF::R_LANAI_21_F:
81
case
ELF::R_LANAI_25:
82
case
ELF::R_LANAI_32:
83
case
ELF::R_LANAI_HI16:
84
return
true
;
85
default
:
86
return
false
;
87
}
88
}
89
90
std::unique_ptr<MCObjectTargetWriter>
91
llvm::createLanaiELFObjectWriter
(
uint8_t
OSABI) {
92
return
std::make_unique<LanaiELFObjectWriter>(OSABI);
93
}
true
basic Basic Alias true
Definition:
BasicAliasAnalysis.cpp:1981
ELF.h
Sym
Symbol * Sym
Definition:
ELF_riscv.cpp:479
LanaiBaseInfo.h
LanaiFixupKinds.h
MCELFObjectWriter.h
MCObjectWriter.h
Fixup
PowerPC TLS Dynamic Call Fixup
Definition:
PPCTLSDynamicCall.cpp:339
llvm::MCContext
Context object for machine code objects.
Definition:
MCContext.h:83
llvm::MCELFObjectTargetWriter
Definition:
MCELFObjectWriter.h:53
llvm::MCELFObjectTargetWriter::needsRelocateWithSymbol
virtual bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym, unsigned Type) const
Definition:
MCELFObjectTargetWriter.cpp:20
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::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition:
MCSymbol.h:41
llvm::MCValue
This represents an "assembler immediate".
Definition:
MCValue.h:36
llvm::Target
Target - Wrapper for Target specific information.
Definition:
TargetRegistry.h:144
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:
Type.h:45
uint8_t
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:193
llvm::ELF::EM_LANAI
@ EM_LANAI
Definition:
ELF.h:319
llvm::Lanai::FIXUP_LANAI_25
@ FIXUP_LANAI_25
Definition:
LanaiFixupKinds.h:30
llvm::Lanai::FIXUP_LANAI_21
@ FIXUP_LANAI_21
Definition:
LanaiFixupKinds.h:28
llvm::Lanai::FIXUP_LANAI_32
@ FIXUP_LANAI_32
Definition:
LanaiFixupKinds.h:31
llvm::Lanai::FIXUP_LANAI_NONE
@ FIXUP_LANAI_NONE
Definition:
LanaiFixupKinds.h:26
llvm::Lanai::FIXUP_LANAI_21_F
@ FIXUP_LANAI_21_F
Definition:
LanaiFixupKinds.h:29
llvm::Lanai::FIXUP_LANAI_LO16
@ FIXUP_LANAI_LO16
Definition:
LanaiFixupKinds.h:33
llvm::Lanai::FIXUP_LANAI_HI16
@ FIXUP_LANAI_HI16
Definition:
LanaiFixupKinds.h:32
llvm::lltok::Kind
Kind
Definition:
LLToken.h:18
llvm::logicalview::LVBinaryType::ELF
@ ELF
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
llvm::FK_Data_4
@ FK_Data_4
A four-byte fixup.
Definition:
MCFixup.h:25
llvm::createLanaiELFObjectWriter
std::unique_ptr< MCObjectTargetWriter > createLanaiELFObjectWriter(uint8_t OSABI)
Definition:
LanaiELFObjectWriter.cpp:91
Generated on Sun Dec 22 2024 01:30:35 for LLVM by
1.9.6