LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
FPO.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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_FPO_H
17#define LIEF_PE_FPO_H
18
19#include <vector>
20#include "LIEF/iterators.hpp"
21#include "LIEF/visibility.h"
23
24namespace LIEF {
25namespace PE {
26
28class LIEF_API FPO : public Debug {
29 public:
30 enum class FRAME_TYPE {
31 FPO = 0,
32 TRAP = 1,
33 TSS = 2,
34 NON_FPO = 3,
35 };
36
41 uint32_t rva = 0;
42
44 uint32_t proc_size = 0;
45
47 uint32_t nb_locals = 0;
48
50 uint32_t parameters_size = 0;
51
53 uint16_t prolog_size = 0;
54
56 uint16_t nb_saved_regs = 0;
57
59 bool use_seh = false;
60
62 bool use_bp = false;
63
65 uint16_t reserved = 0;
66
69
70 std::string to_string() const;
71
72 friend LIEF_API std::ostream& operator<<(std::ostream& os,
73 const entry_t& entry) {
74 os << entry.to_string();
75 return os;
76 }
77 };
78
79 using entries_t = std::vector<entry_t>;
82
83 static std::unique_ptr<FPO> parse(const details::pe_debug& hdr, Section* section,
85
86 FPO(const details::pe_debug& hdr, Section* section) :
87 Debug(hdr, section) {}
88
89 FPO(const FPO& other) = default;
90 FPO& operator=(const FPO& other) = default;
91
92 FPO(FPO&&) = default;
93 FPO& operator=(FPO&& other) = default;
94
95 std::unique_ptr<Debug> clone() const override {
96 return std::unique_ptr<Debug>(new FPO(*this));
97 }
98
101 return entries_;
102 }
103
105 return entries_;
106 }
107
108 static bool classof(const Debug* debug) {
109 return debug->type() == Debug::TYPES::FPO;
110 }
111
112 ~FPO() override = default;
113
114 std::string to_string() const override;
115
116 private:
117 entries_t entries_;
118};
119
121
122}
123}
124
125#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:170
@ FPO
Frame pointer omission information.
Definition debug/Debug.hpp:56
FPO(const FPO &other)=default
it_entries entries()
Definition FPO.hpp:104
FPO & operator=(FPO &&other)=default
it_const_entries entries() const
Iterator over the FPO entries.
Definition FPO.hpp:100
static bool classof(const Debug *debug)
Definition FPO.hpp:108
FPO(const details::pe_debug &hdr, Section *section)
Definition FPO.hpp:86
~FPO() override=default
std::string to_string() const override
const_ref_iterator< const entries_t & > it_const_entries
Definition FPO.hpp:81
FPO(FPO &&)=default
std::vector< entry_t > entries_t
Definition FPO.hpp:79
static std::unique_ptr< FPO > parse(const details::pe_debug &hdr, Section *section, span< uint8_t > payload)
FRAME_TYPE
Definition FPO.hpp:30
@ FPO
Definition FPO.hpp:31
ref_iterator< entries_t & > it_entries
Definition FPO.hpp:80
std::unique_ptr< Debug > clone() const override
Definition FPO.hpp:95
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:45
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
const char * to_string(CODE_PAGES e)
LIEF namespace.
Definition Abstract/Binary.hpp:40
tcb::span< ElementType, Extent > span
Definition span.hpp:22
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:286
Represents the stack frame layout for a x86 function when frame pointer omission (FPO) optimization i...
Definition FPO.hpp:39
uint32_t proc_size
The number of bytes in the function.
Definition FPO.hpp:44
uint16_t nb_saved_regs
Number of registers saved.
Definition FPO.hpp:56
std::string to_string() const
uint16_t prolog_size
The number of bytes in the function prolog code.
Definition FPO.hpp:53
uint16_t reserved
Reserved for future use.
Definition FPO.hpp:65
friend std::ostream & operator<<(std::ostream &os, const entry_t &entry)
Definition FPO.hpp:72
uint32_t nb_locals
The number of local variables.
Definition FPO.hpp:47
uint32_t parameters_size
The size of the parameters.
Definition FPO.hpp:50
FRAME_TYPE type
Variable that indicates the frame type.
Definition FPO.hpp:68
bool use_seh
Whether the function uses structured exception handling.
Definition FPO.hpp:59
uint32_t rva
The function RVA.
Definition FPO.hpp:41
bool use_bp
Whether the EBP register has been allocated.
Definition FPO.hpp:62
#define LIEF_API
Definition visibility.h:43