LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
LinkEdit.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_LINK_EDIT_H
17#define LIEF_MACHO_LINK_EDIT_H
18#include <memory>
19
20#include "LIEF/visibility.h"
21
22#include "LIEF/MachO/SegmentCommand.hpp"
23
24namespace LIEF {
25namespace MachO {
26
27class Binary;
28class BinaryParser;
29class Builder;
30class CodeSignatureDir;
31class DataInCode;
32class DyldChainedFixups;
33class DyldExportsTrie;
34class DyldInfo;
35class FunctionStarts;
36class LinkerOptHint;
37class SymbolCommand;
38class TwoLevelHints;
39class SegmentSplitInfo;
40class CodeSignature;
41
42class LIEF_API LinkEdit : public SegmentCommand {
43
44 friend class BinaryParser;
45 friend class Binary;
46 friend class Builder;
47
48 public:
49 using SegmentCommand::SegmentCommand;
50
51 LinkEdit& operator=(LinkEdit other);
52 LinkEdit(const LinkEdit& copy) = default;
53
54 void swap(LinkEdit& other) noexcept;
55
56 std::unique_ptr<LoadCommand> clone() const override {
57 return std::unique_ptr<LinkEdit>(new LinkEdit(*this));
58 }
59
60 ~LinkEdit() override = default;
61
62 static bool classof(const LoadCommand* cmd) {
63 return SegmentCommand::classof(cmd);
64 }
65
66 static bool segmentof(const SegmentCommand& segment) {
67 return segment.name() == "__LINKEDIT";
68 }
69
70 private:
71 LIEF_LOCAL void update_data(const update_fnc_t& f) override;
72 LIEF_LOCAL void update_data(const update_fnc_ws_t& f,
73 size_t where, size_t size) override;
74
75 //x-ref to keep the spans in a consistent state
76 DyldInfo* dyld_ = nullptr;
77 DyldChainedFixups* chained_fixups_ = nullptr;
78 DyldExportsTrie* exports_trie_ = nullptr;
79 SegmentSplitInfo* seg_split_ = nullptr;
80 FunctionStarts* fstarts_ = nullptr;
81 DataInCode* data_code_ = nullptr;
82 CodeSignatureDir* code_sig_dir_ = nullptr;
83 LinkerOptHint* linker_opt_ = nullptr;
84 SymbolCommand* symtab_ = nullptr;
85 TwoLevelHints* two_lvl_hint_ = nullptr;
86 CodeSignature* code_sig_ = nullptr;
87};
88
89}
90}
91#endif
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:73
Class which represents a MachO binary.
Definition MachO/Binary.hpp:73
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:54
Definition CodeSignatureDir.hpp:36
Definition CodeSignature.hpp:37
Interface of the LC_DATA_IN_CODE command This command is used to list slices of code sections that co...
Definition DataInCode.hpp:42
Class that represents the LC_DYLD_CHAINED_FIXUPS command.
Definition DyldChainedFixups.hpp:46
Class that represents the LC_DYLD_EXPORTS_TRIE command.
Definition DyldExportsTrie.hpp:40
Class that represents the LC_DYLD_INFO and LC_DYLD_INFO_ONLY commands.
Definition DyldInfo.hpp:49
Class which represents the LC_FUNCTION_STARTS command.
Definition FunctionStarts.hpp:39
Definition LinkEdit.hpp:42
Class which represents the LC_LINKER_OPTIMIZATION_HINT command.
Definition LinkerOptHint.hpp:37
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:48
const std::string & name() const
Name of the segment (e.g. __TEXT)
Definition SegmentCommand.hpp:113
Class that represents the LoadCommand::TYPE::SEGMENT_SPLIT_INFO command.
Definition SegmentSplitInfo.hpp:35
Class that represents the LC_SYMTAB command.
Definition SymbolCommand.hpp:35
Class which represents the LC_TWOLEVEL_HINTS command.
Definition TwoLevelHints.hpp:39
LIEF namespace.
Definition Abstract/Binary.hpp:32