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