LLVM
8.0.1
lib
DebugInfo
DWARF
DWARFDataExtractor.cpp
Go to the documentation of this file.
1
//===- DWARFDataExtractor.cpp ---------------------------------------------===//
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 "
llvm/DebugInfo/DWARF/DWARFDataExtractor.h
"
11
#include "
llvm/BinaryFormat/Dwarf.h
"
12
#include "
llvm/DebugInfo/DWARF/DWARFContext.h
"
13
14
using namespace
llvm
;
15
16
uint64_t
DWARFDataExtractor::getRelocatedValue
(
uint32_t
Size
,
uint32_t
*Off,
17
uint64_t *SecNdx)
const
{
18
if
(SecNdx)
19
*SecNdx = -1ULL;
20
if
(!Section)
21
return
getUnsigned
(Off, Size);
22
Optional<RelocAddrEntry>
Rel = Obj->
find
(*Section, *Off);
23
if
(!Rel)
24
return
getUnsigned
(Off, Size);
25
if
(SecNdx)
26
*SecNdx = Rel->
SectionIndex
;
27
return
getUnsigned
(Off, Size) + Rel->
Value
;
28
}
29
30
Optional<uint64_t>
31
DWARFDataExtractor::getEncodedPointer
(
uint32_t
*
Offset
, uint8_t Encoding,
32
uint64_t PCRelOffset)
const
{
33
if
(Encoding ==
dwarf::DW_EH_PE_omit
)
34
return
None
;
35
36
uint64_t Result = 0;
37
uint32_t
OldOffset = *
Offset
;
38
// First get value
39
switch
(Encoding & 0x0F) {
40
case
dwarf::DW_EH_PE_absptr
:
41
switch
(
getAddressSize
()) {
42
case
2:
43
case
4:
44
case
8:
45
Result =
getUnsigned
(Offset,
getAddressSize
());
46
break
;
47
default
:
48
return
None
;
49
}
50
break
;
51
case
dwarf::DW_EH_PE_uleb128
:
52
Result =
getULEB128
(Offset);
53
break
;
54
case
dwarf::DW_EH_PE_sleb128
:
55
Result =
getSLEB128
(Offset);
56
break
;
57
case
dwarf::DW_EH_PE_udata2
:
58
Result =
getUnsigned
(Offset, 2);
59
break
;
60
case
dwarf::DW_EH_PE_udata4
:
61
Result =
getUnsigned
(Offset, 4);
62
break
;
63
case
dwarf::DW_EH_PE_udata8
:
64
Result =
getUnsigned
(Offset, 8);
65
break
;
66
case
dwarf::DW_EH_PE_sdata2
:
67
Result =
getSigned
(Offset, 2);
68
break
;
69
case
dwarf::DW_EH_PE_sdata4
:
70
Result =
getSigned
(Offset, 4);
71
break
;
72
case
dwarf::DW_EH_PE_sdata8
:
73
Result =
getSigned
(Offset, 8);
74
break
;
75
default
:
76
return
None
;
77
}
78
// Then add relative offset, if required
79
switch
(Encoding & 0x70) {
80
case
dwarf::DW_EH_PE_absptr
:
81
// do nothing
82
break
;
83
case
dwarf::DW_EH_PE_pcrel
:
84
Result += PCRelOffset;
85
break
;
86
case
dwarf::DW_EH_PE_datarel
:
87
case
dwarf::DW_EH_PE_textrel
:
88
case
dwarf::DW_EH_PE_funcrel
:
89
case
dwarf::DW_EH_PE_aligned
:
90
default
:
91
*Offset = OldOffset;
92
return
None
;
93
}
94
95
return
Result;
96
}
llvm::DataExtractor::getULEB128
uint64_t getULEB128(uint32_t *offset_ptr) const
Extract a unsigned LEB128 value from *offset_ptr.
Definition:
DataExtractor.cpp:148
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:24
llvm::DWARFObject::find
virtual Optional< RelocAddrEntry > find(const DWARFSection &Sec, uint64_t Pos) const =0
llvm::dwarf::DW_EH_PE_sleb128
Definition:
Dwarf.h:296
llvm::dwarf::DW_EH_PE_uleb128
Definition:
Dwarf.h:292
llvm::dwarf::DW_EH_PE_udata4
Definition:
Dwarf.h:294
llvm::dwarf::DW_EH_PE_omit
Definition:
Dwarf.h:291
llvm::dwarf::DW_EH_PE_textrel
Definition:
Dwarf.h:302
llvm::Optional
Definition:
APInt.h:34
llvm::dwarf::DW_EH_PE_funcrel
Definition:
Dwarf.h:304
llvm::DataExtractor::getSLEB128
int64_t getSLEB128(uint32_t *offset_ptr) const
Extract a signed LEB128 value from *offset_ptr.
Definition:
DataExtractor.cpp:169
llvm::dwarf::DW_EH_PE_datarel
Definition:
Dwarf.h:303
llvm::NoneType::None
llvm::DataExtractor::getAddressSize
uint8_t getAddressSize() const
Get the address size for this extractor.
Definition:
DataExtractor.h:59
llvm::DataExtractor::getSigned
int64_t getSigned(uint32_t *offset_ptr, uint32_t size) const
Extract an signed integer of size byte_size from *offset_ptr.
Definition:
DataExtractor.cpp:114
llvm::dwarf::DW_EH_PE_sdata2
Definition:
Dwarf.h:297
llvm::DWARFDataExtractor::getEncodedPointer
Optional< uint64_t > getEncodedPointer(uint32_t *Offset, uint8_t Encoding, uint64_t AbsPosOffset=0) const
Extracts a DWARF-encoded pointer in Offset using Encoding.
Definition:
DWARFDataExtractor.cpp:31
llvm::DWARFDataExtractor::getRelocatedValue
uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off, uint64_t *SectionIndex=nullptr) const
Extracts a value and applies a relocation to the result if one exists for the given offset...
Definition:
DWARFDataExtractor.cpp:16
llvm::AMDGPU::Hwreg::Offset
Offset
Definition:
SIDefines.h:296
uint32_t
llvm::RelocAddrEntry::SectionIndex
uint64_t SectionIndex
Definition:
DWARFRelocMap.h:21
llvm::dwarf::DW_EH_PE_absptr
Definition:
Dwarf.h:290
DWARFDataExtractor.h
Dwarf.h
This file contains constants used for implementing Dwarf debug support.
llvm::DataExtractor::getUnsigned
uint64_t getUnsigned(uint32_t *offset_ptr, uint32_t byte_size) const
Extract an unsigned integer of size byte_size from *offset_ptr.
Definition:
DataExtractor.cpp:99
Size
uint32_t Size
Definition:
Profile.cpp:47
llvm::dwarf::DW_EH_PE_pcrel
Definition:
Dwarf.h:301
llvm::dwarf::DW_EH_PE_sdata4
Definition:
Dwarf.h:298
llvm::dwarf::DW_EH_PE_udata2
Definition:
Dwarf.h:293
llvm::dwarf::DW_EH_PE_udata8
Definition:
Dwarf.h:295
llvm::RelocAddrEntry::Value
uint64_t Value
Definition:
DWARFRelocMap.h:22
llvm::dwarf::DW_EH_PE_aligned
Definition:
Dwarf.h:305
llvm::dwarf::DW_EH_PE_sdata8
Definition:
Dwarf.h:299
DWARFContext.h
Generated on Sun Dec 20 2020 13:55:10 for LLVM by
1.8.13