LIEF: Library to Instrument Executable Formats Version 1.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 <ostream>
19
21#include "LIEF/visibility.h"
22#include "LIEF/span.hpp"
23
25
26namespace LIEF {
27namespace 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::unique_ptr<LinkerOptHint>(new 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: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: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: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:60
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:41
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:45