LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
FPO.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_PE_FPO_H
16#define LIEF_PE_FPO_H
17
19#include "LIEF/iterators.hpp"
20#include "LIEF/visibility.h"
21#include <vector>
22
23
24namespace LIEF::PE {
25
27class LIEF_API FPO : public Debug {
28 public:
29 enum class FRAME_TYPE {
30 FPO = 0,
31 TRAP = 1,
32 TSS = 2,
33 NON_FPO = 3,
34 };
35
40 uint32_t rva = 0;
41
43 uint32_t proc_size = 0;
44
46 uint32_t nb_locals = 0;
47
49 uint32_t parameters_size = 0;
50
52 uint16_t prolog_size = 0;
53
55 uint16_t nb_saved_regs = 0;
56
58 bool use_seh = false;
59
61 bool use_bp = false;
62
64 uint16_t reserved = 0;
65
68
69 std::string to_string() const;
70
71 friend LIEF_API std::ostream& operator<<(std::ostream& os,
72 const entry_t& entry) {
73 os << entry.to_string();
74 return os;
75 }
76 };
77
78 using entries_t = std::vector<entry_t>;
81
82 static std::unique_ptr<FPO> parse(const details::pe_debug& hdr, Section* section,
84
85 FPO(const details::pe_debug& hdr, Section* section) :
86 Debug(hdr, section) {}
87
88 FPO(const FPO& other) = default;
89 FPO& operator=(const FPO& other) = default;
90
91 FPO(FPO&&) = default;
92 FPO& operator=(FPO&& other) = default;
93
94 std::unique_ptr<Debug> clone() const override {
95 return std::unique_ptr<Debug>(new FPO(*this));
96 }
97
100 return entries_;
101 }
102
104 return entries_;
105 }
106
107 static bool classof(const Debug* debug) {
108 return debug->type() == Debug::TYPES::FPO;
109 }
110
111 ~FPO() override = default;
112
113 std::string to_string() const override;
114
115 private:
116 entries_t entries_;
117};
118
120
121}
122
123
124#endif
span< uint8_t > payload()
Debug data associated with this entry.
Debug()=default
const Section * section() const
The section where debug data is located.
Definition debug/Debug.hpp:168
@ FPO
Frame pointer omission information.
Definition debug/Debug.hpp:55
FPO(const FPO &other)=default
it_entries entries()
Definition FPO.hpp:103
FPO & operator=(FPO &&other)=default
it_const_entries entries() const
Iterator over the FPO entries.
Definition FPO.hpp:99
static bool classof(const Debug *debug)
Definition FPO.hpp:107
FPO(const details::pe_debug &hdr, Section *section)
Definition FPO.hpp:85
~FPO() override=default
std::string to_string() const override
const_ref_iterator< const entries_t & > it_const_entries
Definition FPO.hpp:80
FPO(FPO &&)=default
std::vector< entry_t > entries_t
Definition FPO.hpp:78
static std::unique_ptr< FPO > parse(const details::pe_debug &hdr, Section *section, span< uint8_t > payload)
FRAME_TYPE
Definition FPO.hpp:29
@ FPO
Definition FPO.hpp:30
ref_iterator< entries_t & > it_entries
Definition FPO.hpp:79
std::unique_ptr< Debug > clone() const override
Definition FPO.hpp:94
FPO & operator=(const FPO &other)=default
Class which represents a PE section.
Definition PE/Section.hpp:46
Iterator which returns reference on container's values.
Definition iterators.hpp:120
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:31
const char * to_string(CODE_PAGES e)
tcb::span< ElementType, Extent > span
Definition span.hpp:22
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which returns a const ref on container's values.
Definition iterators.hpp:385
Represents the stack frame layout for a x86 function when frame pointer omission (FPO) optimization i...
Definition FPO.hpp:38
uint32_t proc_size
The number of bytes in the function.
Definition FPO.hpp:43
uint16_t nb_saved_regs
Number of registers saved.
Definition FPO.hpp:55
std::string to_string() const
uint16_t prolog_size
The number of bytes in the function prologue code.
Definition FPO.hpp:52
uint16_t reserved
Reserved for future use.
Definition FPO.hpp:64
friend std::ostream & operator<<(std::ostream &os, const entry_t &entry)
Definition FPO.hpp:71
uint32_t nb_locals
The number of local variables.
Definition FPO.hpp:46
uint32_t parameters_size
The size of the parameters.
Definition FPO.hpp:49
FRAME_TYPE type
Variable that indicates the frame type.
Definition FPO.hpp:67
bool use_seh
Whether the function uses structured exception handling.
Definition FPO.hpp:58
uint32_t rva
The function RVA.
Definition FPO.hpp:40
bool use_bp
Whether the EBP register has been allocated.
Definition FPO.hpp:61
#define LIEF_API
Definition visibility.h:44