LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
SegmentSplitInfo.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_SEGMENT_SPLIT_INFO_H
17#define LIEF_MACHO_SEGMENT_SPLIT_INFO_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 {
27class BinaryParser;
28class LinkEdit;
29
30namespace details {
31struct linkedit_data_command;
32}
33
35class LIEF_API SegmentSplitInfo : public LoadCommand {
36 friend class BinaryParser;
37 friend class LinkEdit;
38 public:
39 SegmentSplitInfo() = default;
40 SegmentSplitInfo(const details::linkedit_data_command& cmd);
41
42 SegmentSplitInfo& operator=(const SegmentSplitInfo& copy) = default;
43 SegmentSplitInfo(const SegmentSplitInfo& copy) = default;
44
45 std::unique_ptr<LoadCommand> clone() const override {
46 return std::unique_ptr<SegmentSplitInfo>(new SegmentSplitInfo(*this));
47 }
48
49 uint32_t data_offset() const {
50 return data_offset_;
51 }
52 uint32_t data_size() const {
53 return data_size_;
54 }
55
56 void data_offset(uint32_t offset) {
57 data_offset_ = offset;
58 }
59 void data_size(uint32_t size) {
60 data_size_ = size;
61 }
62
63 span<uint8_t> content() {
64 return content_;
65 }
66
67 span<const uint8_t> content() const {
68 return content_;
69 }
70
71 ~SegmentSplitInfo() override = default;
72
73 void accept(Visitor& visitor) const override;
74
75 std::ostream& print(std::ostream& os) const override;
76
77 static bool classof(const LoadCommand* cmd) {
78 return cmd->command() == LoadCommand::TYPE::SEGMENT_SPLIT_INFO;
79 }
80
81 private:
82 uint32_t data_offset_ = 0;
83 uint32_t data_size_ = 0;
84 span<uint8_t> content_;
85
86};
87
88}
89}
90#endif
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:73
Definition LinkEdit.hpp:42
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:120
Class that represents the LoadCommand::TYPE::SEGMENT_SPLIT_INFO command.
Definition SegmentSplitInfo.hpp:35
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32