LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
LinkerOptHint.hpp
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
23#include "LIEF/MachO/LoadCommand.hpp"
24
25namespace LIEF {
26namespace MachO {
27
28class BinaryParser;
29class Builder;
30class LinkEdit;
31
32namespace details {
33struct linkedit_data_command;
34}
35
37class LIEF_API LinkerOptHint : public LoadCommand {
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
71 span<const uint8_t> content() const {
72 return content_;
73 }
74
75 span<uint8_t> content() {
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:73
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:54
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 raw signature.
Definition LinkerOptHint.hpp:59
uint32_t data_offset() const
Offset in the binary where the signature starts.
Definition LinkerOptHint.hpp:54
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:32