LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
internal_arm64.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2025 R. Thomas
2 * Copyright 2017 - 2025 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_PE_UNWIND_CODE_ARM64_INTERNAL_H
17#define LIEF_PE_UNWIND_CODE_ARM64_INTERNAL_H
18#include <cstdint>
19#include <array>
20
21namespace LIEF::PE::details {
22inline uint32_t xdata_unpacked_rva(uint32_t value) {
23 return value & ~0x3;
24}
25
27 uint32_t raw;
28
29 uint8_t flags() const {
30 return raw & 0x03;
31 }
32
33 uint32_t function_length() const {
34 return ((raw & 0x00001ffc) >> 2) << 2;
35 }
36
37 uint8_t RF() const {
38 return ((raw & 0x0000e000) >> 13);
39 }
40
41 uint8_t RI() const {
42 return ((raw & 0x000f0000) >> 16);
43 }
44
45 bool H() const {
46 return ((raw & 0x00100000) >> 20);
47 }
48
49 uint8_t CR() const {
50 return ((raw & 0x600000) >> 21);
51 }
52
53 uint8_t frame_size() const {
54 return ((raw & 0xff800000) >> 23);
55 }
56};
57
58static_assert(sizeof(arm64_packed_t) == sizeof(uint32_t));
59
61 static constexpr auto MAX_WORDS = 2;
62 std::array<uint32_t, MAX_WORDS> data = {0};
63
64 uint32_t function_length() const {
65 return (data[0] & 0x0003ffff) << 2;
66 }
67
68 uint8_t version() const {
69 return (data[0] & 0x000C0000) >> 18;
70 }
71
72 bool X() const {
73 return (data[0] & 0x00100000) >> 20;
74 }
75
76 uint8_t E() const {
77 return (data[0] & 0x00200000) >> 21;
78 }
79
80 uint16_t epilog_count() const {
81 return is_extended() ? (data[1] & 0x0000ffff) :
82 (data[0] & 0x07C00000) >> 22;
83 }
84
85 uint8_t code_words() const {
86 return is_extended() ? (data[1] & 0x00ff0000) >> 16 :
87 (data[0] & 0xf8000000) >> 27;
88 }
89
90 bool is_extended() const {
91 return (data[0] & 0xffc00000) == 0;
92 }
93};
94
96 uint32_t raw;
97
98 uint32_t start_offset() const {
99 return raw & 0x0003ffff;
100 }
101
102 uint8_t reserved() const {
103 return (raw & 0x000f0000) >> 18;
104 }
105
106 uint8_t start_index() const {
107 return (raw & 0xffc00000) >> 22;
108 }
109};
110
111}
112#endif
Definition DataDirectory.hpp:37
uint32_t xdata_unpacked_rva(uint32_t value)
Definition internal_arm64.hpp:22
Definition internal_arm64.hpp:95
uint32_t raw
Definition internal_arm64.hpp:96
uint8_t reserved() const
Definition internal_arm64.hpp:102
uint32_t start_offset() const
Definition internal_arm64.hpp:98
uint8_t start_index() const
Definition internal_arm64.hpp:106
Definition internal_arm64.hpp:26
bool H() const
Definition internal_arm64.hpp:45
uint8_t RF() const
Definition internal_arm64.hpp:37
uint8_t RI() const
Definition internal_arm64.hpp:41
uint8_t flags() const
Definition internal_arm64.hpp:29
uint32_t raw
Definition internal_arm64.hpp:27
uint32_t function_length() const
Definition internal_arm64.hpp:33
uint8_t frame_size() const
Definition internal_arm64.hpp:53
uint8_t CR() const
Definition internal_arm64.hpp:49
Definition internal_arm64.hpp:60
uint8_t version() const
Definition internal_arm64.hpp:68
uint8_t E() const
Definition internal_arm64.hpp:76
uint8_t code_words() const
Definition internal_arm64.hpp:85
static constexpr auto MAX_WORDS
Definition internal_arm64.hpp:61
uint16_t epilog_count() const
Definition internal_arm64.hpp:80
uint32_t function_length() const
Definition internal_arm64.hpp:64
bool is_extended() const
Definition internal_arm64.hpp:90
std::array< uint32_t, MAX_WORDS > data
Definition internal_arm64.hpp:62
bool X() const
Definition internal_arm64.hpp:72