LIEF: Library to Instrument Executable Formats Version 0.16.0
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}
35class 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 uint32_t data_offset() const {
55 return data_offset_;
56 }
57 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
LoadCommand.hpp
LIEF::MachO::BinaryParser
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:74
LIEF::MachO::Builder
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:57
LIEF::MachO::LinkEdit
Definition LinkEdit.hpp:42
LIEF::MachO::LinkerOptHint
Class which represents the LC_LINKER_OPTIMIZATION_HINT command.
Definition LinkerOptHint.hpp:37
LIEF::MachO::LinkerOptHint::data_size
uint32_t data_size() const
Size of the payload.
Definition LinkerOptHint.hpp:59
LIEF::MachO::LinkerOptHint::classof
static bool classof(const LoadCommand *cmd)
Definition LinkerOptHint.hpp:85
LIEF::MachO::LinkerOptHint::~LinkerOptHint
~LinkerOptHint() override=default
LIEF::MachO::LinkerOptHint::operator=
LinkerOptHint & operator=(const LinkerOptHint &copy)=default
LIEF::MachO::LinkerOptHint::content
span< const uint8_t > content() const
Definition LinkerOptHint.hpp:71
LIEF::MachO::LinkerOptHint::print
std::ostream & print(std::ostream &os) const override
LIEF::MachO::LinkerOptHint::clone
std::unique_ptr< LoadCommand > clone() const override
Definition LinkerOptHint.hpp:49
LIEF::MachO::LinkerOptHint::accept
void accept(Visitor &visitor) const override
LIEF::MachO::LinkerOptHint::content
span< uint8_t > content()
Definition LinkerOptHint.hpp:75
LIEF::MachO::LinkerOptHint::LinkerOptHint
LinkerOptHint(const LinkerOptHint &copy)=default
LIEF::MachO::LinkerOptHint::data_size
void data_size(uint32_t size)
Definition LinkerOptHint.hpp:67
LIEF::MachO::LinkerOptHint::data_offset
uint32_t data_offset() const
Offset in the binary where the hint starts.
Definition LinkerOptHint.hpp:54
LIEF::MachO::LinkerOptHint::LinkerOptHint
LinkerOptHint()=default
LIEF::MachO::LinkerOptHint::LinkerOptHint
LinkerOptHint(const details::linkedit_data_command &cmd)
LIEF::MachO::LinkerOptHint::data_offset
void data_offset(uint32_t offset)
Definition LinkerOptHint.hpp:63
LIEF::MachO::LoadCommand
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
LIEF::MachO::LoadCommand::command
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:124
LIEF::MachO::details
Definition endianness_support.hpp:59
LIEF::MachO
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
span.hpp
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41