LLVM
7.0.0
lib
Target
BPF
MCTargetDesc
BPFELFObjectWriter.cpp
Go to the documentation of this file.
1
//===-- BPFELFObjectWriter.cpp - BPF 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/BPFMCTargetDesc.h
"
11
#include "
llvm/BinaryFormat/ELF.h
"
12
#include "
llvm/MC/MCELFObjectWriter.h
"
13
#include "
llvm/MC/MCFixup.h
"
14
#include "
llvm/MC/MCObjectWriter.h
"
15
#include "
llvm/Support/ErrorHandling.h
"
16
#include <cstdint>
17
18
using namespace
llvm
;
19
20
namespace
{
21
22
class
BPFELFObjectWriter :
public
MCELFObjectTargetWriter
{
23
public
:
24
BPFELFObjectWriter(uint8_t OSABI);
25
~BPFELFObjectWriter()
override
=
default
;
26
27
protected
:
28
unsigned
getRelocType
(
MCContext
&Ctx,
const
MCValue
&
Target
,
29
const
MCFixup
&Fixup,
bool
IsPCRel)
const override
;
30
};
31
32
}
// end anonymous namespace
33
34
BPFELFObjectWriter::BPFELFObjectWriter(uint8_t OSABI)
35
:
MCELFObjectTargetWriter
(
/*Is64Bit*/
true
, OSABI, ELF::
EM_BPF
,
36
/*HasRelocationAddend*/
false
) {}
37
38
unsigned
BPFELFObjectWriter::getRelocType
(
MCContext
&Ctx,
const
MCValue
&
Target
,
39
const
MCFixup
&Fixup,
40
bool
IsPCRel)
const
{
41
// determine the type of the relocation
42
switch
((
unsigned
)Fixup.
getKind
()) {
43
default
:
44
llvm_unreachable
(
"invalid fixup kind!"
);
45
case
FK_SecRel_8
:
46
return
ELF::R_BPF_64_64;
47
case
FK_PCRel_4
:
48
case
FK_SecRel_4
:
49
return
ELF::R_BPF_64_32;
50
case
FK_Data_8
:
51
return
ELF::R_BPF_64_64;
52
case
FK_Data_4
:
53
return
ELF::R_BPF_64_32;
54
}
55
}
56
57
std::unique_ptr<MCObjectTargetWriter>
58
llvm::createBPFELFObjectWriter
(uint8_t OSABI) {
59
return
llvm::make_unique<BPFELFObjectWriter>(OSABI);
60
}
llvm
Compute iterated dominance frontiers using a linear time algorithm.
Definition:
AllocatorList.h:24
llvm::createBPFELFObjectWriter
std::unique_ptr< MCObjectTargetWriter > createBPFELFObjectWriter(uint8_t OSABI)
Definition:
BPFELFObjectWriter.cpp:58
llvm::MCValue
This represents an "assembler immediate".
Definition:
MCValue.h:40
BPFMCTargetDesc.h
ELF.h
true
block Block Frequency true
Definition:
BlockFrequencyInfo.cpp:293
llvm::ELF::EM_BPF
Definition:
ELF.h:314
llvm::MCFixup
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition:
MCFixup.h:74
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_SecRel_4
A four-byte section relative fixup.
Definition:
MCFixup.h:42
llvm::FK_Data_4
A four-byte fixup.
Definition:
MCFixup.h:26
llvm::MCContext
Context object for machine code objects.
Definition:
MCContext.h:63
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_PCRel_4
A four-byte pc relative fixup.
Definition:
MCFixup.h:30
ErrorHandling.h
llvm::Target
Target - Wrapper for Target specific information.
Definition:
TargetRegistry.h:120
MCObjectWriter.h
llvm::FK_SecRel_8
A eight-byte section relative fixup.
Definition:
MCFixup.h:43
llvm::FK_Data_8
A eight-byte fixup.
Definition:
MCFixup.h:27
llvm::MCELFObjectTargetWriter
Definition:
MCELFObjectWriter.h:54
llvm::MCFixup::getKind
MCFixupKind getKind() const
Definition:
MCFixup.h:123
MCFixup.h
Generated on Thu Aug 23 2018 18:55:13 for LLVM by
1.8.13