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