LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
Pogo.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_POGO_H
16#define LIEF_PE_POGO_H
17
20#include "LIEF/iterators.hpp"
21#include "LIEF/visibility.h"
22
23
24namespace LIEF::PE {
25
26class Builder;
27class Parser;
28
31class LIEF_API Pogo : public Debug {
32
33 friend class Builder;
34 friend class Parser;
35
36 public:
37 using entries_t = std::vector<PogoEntry>;
40
41 enum class SIGNATURES {
42 UNKNOWN = 0x0fffffff,
43 ZERO = 0x00000000,
44 LCTG = 0x4C544347, // LCTG
45 PGI = 0x50474900, // PGI\0
46 PGO = 0x50474F00, // PGI\0
47 PGU = 0x50475500, // PGU\0
48 SPGO = 0x5350474f, // SPGO
49 };
50
51 Pogo() {
52 type_ = Debug::TYPES::POGO;
53 }
54
56 Debug{Debug::TYPES::POGO},
57 sig_{sig} {}
58
59 Pogo(const details::pe_debug& debug, SIGNATURES sig, Section* sec) :
60 Debug(debug, sec),
61 sig_(sig) {}
62
63 Pogo(const Pogo&) = default;
64 Pogo& operator=(const Pogo&) = default;
65
66 Pogo(Pogo&&) = default;
67 Pogo& operator=(Pogo&&) = default;
68
69 std::unique_ptr<Debug> clone() const override {
70 return std::unique_ptr<Debug>(new Pogo(*this));
71 }
72
74 return sig_;
75 }
76
79 return entries_;
80 }
81
83 return entries_;
84 }
85
86 void add(PogoEntry entry) {
87 entries_.push_back(std::move(entry));
88 }
89
90 static bool classof(const Debug* debug) {
91 return debug->type() == Debug::TYPES::POGO;
92 }
93
94 void accept(Visitor& visitor) const override;
95
96 std::string to_string() const override;
97
98 ~Pogo() override = default;
99
100 protected:
102 entries_t entries_;
103};
104
106
107} // Namespace PE
108// Namespace LIEF
109
110#endif
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:43
Debug()=default
TYPES
The entry types.
Definition debug/Debug.hpp:45
@ POGO
Profile Guided Optimization metadata.
Definition debug/Debug.hpp:85
Main interface to parse PE binaries. In particular, the static Parser::parse functions should be used...
Definition PE/Parser.hpp:53
Definition PogoEntry.hpp:30
Pogo(SIGNATURES sig)
Definition Pogo.hpp:55
std::unique_ptr< Debug > clone() const override
Definition Pogo.hpp:69
std::vector< PogoEntry > entries_t
Definition Pogo.hpp:37
ref_iterator< entries_t & > it_entries
Definition Pogo.hpp:38
~Pogo() override=default
static bool classof(const Debug *debug)
Definition Pogo.hpp:90
SIGNATURES
Definition Pogo.hpp:41
@ UNKNOWN
Definition Pogo.hpp:42
Pogo(const Pogo &)=default
void accept(Visitor &visitor) const override
Pogo & operator=(const Pogo &)=default
it_entries entries()
An iterator over the different POGO elements.
Definition Pogo.hpp:78
it_const_entries entries() const
Definition Pogo.hpp:82
friend class Builder
Definition Pogo.hpp:33
Pogo()
Definition Pogo.hpp:51
void add(PogoEntry entry)
Definition Pogo.hpp:86
friend class Parser
Definition Pogo.hpp:34
Pogo & operator=(Pogo &&)=default
SIGNATURES signature() const
Definition Pogo.hpp:73
Pogo(const details::pe_debug &debug, SIGNATURES sig, Section *sec)
Definition Pogo.hpp:59
Pogo(Pogo &&)=default
const_ref_iterator< const entries_t & > it_const_entries
Definition Pogo.hpp:39
std::string to_string() const override
Class which represents a PE section.
Definition PE/Section.hpp:46
Definition Visitor.hpp:211
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)
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
#define LIEF_API
Definition visibility.h:44