LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
LinkerOptHint.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_MACHO_LINKER_OPT_HINT_COMMAND_H
17#define LIEF_MACHO_LINKER_OPT_HINT_COMMAND_H
18#include <memory>
19#include <ostream>
20
22#include "LIEF/span.hpp"
23#include "LIEF/visibility.h"
24
26
27
28namespace LIEF::MachO {
29
30class BinaryParser;
31class Builder;
32class LinkEdit;
33
34namespace details {
35struct linkedit_data_command;
36}
37
40 friend class BinaryParser;
41 friend class Builder;
42 friend class LinkEdit;
43
44 public:
45 LinkerOptHint() = default;
46 LinkerOptHint(const details::linkedit_data_command& cmd);
47
48 LinkerOptHint& operator=(const LinkerOptHint& copy) = default;
49 LinkerOptHint(const LinkerOptHint& copy) = default;
50
51 std::unique_ptr<LoadCommand> clone() const override {
52 return std::make_unique<LinkerOptHint>(*this);
53 }
54
56 uint32_t data_offset() const {
57 return data_offset_;
58 }
59
61 uint32_t data_size() const {
62 return data_size_;
63 }
64
65 void data_offset(uint32_t offset) {
66 data_offset_ = offset;
67 }
68
69 void data_size(uint32_t size) {
70 data_size_ = size;
71 }
72
74 return content_;
75 }
76
78 return content_;
79 }
80
81 ~LinkerOptHint() override = default;
82
83 void accept(Visitor& visitor) const override;
84
85 std::ostream& print(std::ostream& os) const override;
86
87 static bool classof(const LoadCommand* cmd) {
89 }
90
91 private:
92 uint32_t data_offset_ = 0;
93 uint32_t data_size_ = 0;
94 span<uint8_t> content_;
95};
96
97}
98
99#endif
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:79
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:64
Definition LinkEdit.hpp:47
uint32_t data_size() const
Size of the payload.
Definition LinkerOptHint.hpp:61
static bool classof(const LoadCommand *cmd)
Definition LinkerOptHint.hpp:87
friend class BinaryParser
Definition LinkerOptHint.hpp:40
~LinkerOptHint() override=default
LinkerOptHint & operator=(const LinkerOptHint &copy)=default
span< const uint8_t > content() const
Definition LinkerOptHint.hpp:73
std::ostream & print(std::ostream &os) const override
friend class Builder
Definition LinkerOptHint.hpp:41
std::unique_ptr< LoadCommand > clone() const override
Definition LinkerOptHint.hpp:51
void accept(Visitor &visitor) const override
span< uint8_t > content()
Definition LinkerOptHint.hpp:77
friend class LinkEdit
Definition LinkerOptHint.hpp:42
LinkerOptHint(const LinkerOptHint &copy)=default
void data_size(uint32_t size)
Definition LinkerOptHint.hpp:69
uint32_t data_offset() const
Offset in the binary where the hint starts.
Definition LinkerOptHint.hpp:56
LinkerOptHint(const details::linkedit_data_command &cmd)
void data_offset(uint32_t offset)
Definition LinkerOptHint.hpp:65
uint32_t size() const
Size of the command (should be greater than sizeof(load_command)).
Definition LoadCommand.hpp:137
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:132
@ LINKER_OPTIMIZATION_HINT
Definition LoadCommand.hpp:95
Definition Visitor.hpp:212
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:45