LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
LinkerOptHint.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 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_MACHO_LINKER_OPT_HINT_COMMAND_H
17#define LIEF_MACHO_LINKER_OPT_HINT_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21#include "LIEF/span.hpp"
22
24
25namespace LIEF {
26namespace MachO {
27
28class BinaryParser;
29class Builder;
30class LinkEdit;
31
32namespace details {
33struct linkedit_data_command;
34}
35
38 friend class BinaryParser;
39 friend class Builder;
40 friend class LinkEdit;
41
42 public:
43 LinkerOptHint() = default;
44 LinkerOptHint(const details::linkedit_data_command& cmd);
45
46 LinkerOptHint& operator=(const LinkerOptHint& copy) = default;
47 LinkerOptHint(const LinkerOptHint& copy) = default;
48
49 std::unique_ptr<LoadCommand> clone() const override {
50 return std::unique_ptr<LinkerOptHint>(new LinkerOptHint(*this));
51 }
52
54 uint32_t data_offset() const {
55 return data_offset_;
56 }
57
59 uint32_t data_size() const {
60 return data_size_;
61 }
62
63 void data_offset(uint32_t offset) {
64 data_offset_ = offset;
65 }
66
67 void data_size(uint32_t size) {
68 data_size_ = size;
69 }
70
72 return content_;
73 }
74
76 return content_;
77 }
78
79 ~LinkerOptHint() override = default;
80
81 void accept(Visitor& visitor) const override;
82
83 std::ostream& print(std::ostream& os) const override;
84
85 static bool classof(const LoadCommand* cmd) {
86 return cmd->command() == LoadCommand::TYPE::LINKER_OPTIMIZATION_HINT;
87 }
88
89 private:
90 uint32_t data_offset_ = 0;
91 uint32_t data_size_ = 0;
92 span<uint8_t> content_;
93
94};
95
96}
97}
98#endif
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:74
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:55
Definition LinkEdit.hpp:42
Class which represents the LC_LINKER_OPTIMIZATION_HINT command.
Definition LinkerOptHint.hpp:37
uint32_t data_size() const
Size of the payload.
Definition LinkerOptHint.hpp:59
static bool classof(const LoadCommand *cmd)
Definition LinkerOptHint.hpp:85
~LinkerOptHint() override=default
LinkerOptHint & operator=(const LinkerOptHint &copy)=default
span< const uint8_t > content() const
Definition LinkerOptHint.hpp:71
std::ostream & print(std::ostream &os) const override
std::unique_ptr< LoadCommand > clone() const override
Definition LinkerOptHint.hpp:49
void accept(Visitor &visitor) const override
span< uint8_t > content()
Definition LinkerOptHint.hpp:75
LinkerOptHint(const LinkerOptHint &copy)=default
void data_size(uint32_t size)
Definition LinkerOptHint.hpp:67
uint32_t data_offset() const
Offset in the binary where the hint starts.
Definition LinkerOptHint.hpp:54
LinkerOptHint(const details::linkedit_data_command &cmd)
void data_offset(uint32_t offset)
Definition LinkerOptHint.hpp:63
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:122
Definition Visitor.hpp:224
LIEF namespace.
Definition Abstract/Binary.hpp:32
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:41