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