LIEF: Library to Instrument Executable Formats Version
Loading...
Searching...
No Matches
LinkEdit.hpp
1/* Copyright 2017 - 2023 R. Thomas
2 * Copyright 2017 - 2023 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
19#include <string>
20#include <vector>
21#include <ostream>
22#include <memory>
23
24#include "LIEF/types.hpp"
25#include "LIEF/visibility.h"
26
27#include "LIEF/MachO/SegmentCommand.hpp"
28
29
30namespace LIEF {
31namespace MachO {
32
33class Binary;
34class BinaryParser;
35class Builder;
36class CodeSignatureDir;
37class DataInCode;
38class DyldChainedFixups;
39class DyldExportsTrie;
40class DyldInfo;
41class FunctionStarts;
42class LinkerOptHint;
43class SymbolCommand;
44class TwoLevelHints;
45class SegmentSplitInfo;
46class CodeSignature;
47
48class LIEF_API LinkEdit : public SegmentCommand {
49
50 friend class BinaryParser;
51 friend class Binary;
52 friend class Builder;
53
54 public:
55 using SegmentCommand::SegmentCommand;
56
57 LinkEdit& operator=(LinkEdit other);
58 LinkEdit(const LinkEdit& copy);
59
60 void swap(LinkEdit& other);
61
62 SegmentCommand* clone() const override;
63
64 ~LinkEdit() override;
65
66
67 static bool classof(const LoadCommand* cmd);
68 static bool segmentof(const SegmentCommand& segment);
69
70 private:
71
72 LIEF_LOCAL void update_data(update_fnc_t f) override;
73 LIEF_LOCAL void update_data(update_fnc_ws_t f, 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:74
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:58
Definition CodeSignatureDir.hpp:38
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:44
Class that represents the LC_DYLD_CHAINED_FIXUPS command.
Definition DyldChainedFixups.hpp:45
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:50
Class which represents the LC_FUNCTION_STARTS command.
Definition FunctionStarts.hpp:42
Definition LinkEdit.hpp:48
Class which represents the LC_LINKER_OPTIMIZATION_HINT command.
Definition LinkerOptHint.hpp:39
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:39
Class which represents a LOAD_COMMAND_TYPES::LC_SEGMENT / LOAD_COMMAND_TYPES::LC_SEGMENT_64 command.
Definition SegmentCommand.hpp:48
Class that represents the LOAD_COMMAND_TYPES::LC_SEGMENT_SPLIT_INFO command.
Definition SegmentSplitInfo.hpp:37
Class that represents the LC_SYMTAB command.
Definition SymbolCommand.hpp:36
Class which represents the LC_TWOLEVEL_HINTS command.
Definition TwoLevelHints.hpp:40
LIEF namespace.
Definition Abstract/Binary.hpp:32