LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
DynamicSymbolCommand.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_DYNAMIC_SYMBOL_COMMAND_H
17#define LIEF_MACHO_DYNAMIC_SYMBOL_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21#include "LIEF/iterators.hpp"
22
24
25namespace LIEF {
26namespace MachO {
27class Symbol;
28class BinaryParser;
29class Builder;
30class Binary;
31
32namespace details {
33struct dysymtab_command;
34}
41 friend class BinaryParser;
42 friend class Builder;
43 friend class Binary;
44
45 public: using indirect_symbols_t = std::vector<Symbol*>;
48 using it_indirect_symbols = ref_iterator<indirect_symbols_t&>;
51 using it_const_indirect_symbols = const_ref_iterator<const indirect_symbols_t&>;
52
54
55 DynamicSymbolCommand(const details::dysymtab_command& cmd);
56
57 DynamicSymbolCommand& operator=(const DynamicSymbolCommand& copy) = default;
58 DynamicSymbolCommand(const DynamicSymbolCommand& copy) = default;
59
60 std::unique_ptr<LoadCommand> clone() const override {
61 return std::unique_ptr<DynamicSymbolCommand>(new DynamicSymbolCommand(*this));
62 }
63
64 ~DynamicSymbolCommand() override = default;
65
66 void accept(Visitor& visitor) const override;
67
68 std::ostream& print(std::ostream& os) const override;
69 uint32_t idx_local_symbol() const {
72 return idx_local_symbol_;
73 }
74 uint32_t nb_local_symbols() const {
77 return nb_local_symbols_;
78 }
79 uint32_t idx_external_define_symbol() const {
82 return idx_external_define_symbol_;
83 }
84 uint32_t nb_external_define_symbols() const {
87 return nb_external_define_symbols_;
88 }
89 uint32_t idx_undefined_symbol() const {
92 return idx_undefined_symbol_;
93 }
94 uint32_t nb_undefined_symbols() const {
97 return nb_undefined_symbols_;
98 }
99 uint32_t toc_offset() const {
105 return toc_offset_;
106 }
107 uint32_t nb_toc() const {
112 return nb_toc_;
113 }
114 uint32_t module_table_offset() const {
119 return module_table_offset_;
120 }
121 uint32_t nb_module_table() const {
126 return nb_module_table_;
127 }
128 uint32_t external_reference_symbol_offset() const {
133 return external_reference_symbol_offset_;
134 }
135 uint32_t nb_external_reference_symbols() const {
140 return nb_external_reference_symbols_;
141 }
142 uint32_t indirect_symbol_offset() const {
152 return indirect_sym_offset_;
153 }
154 uint32_t nb_indirect_symbols() const {
159 return nb_indirect_symbols_;
160 }
161
162 uint32_t external_relocation_offset() const {
167 return external_relocation_offset_;
168 }
169 uint32_t nb_external_relocations() const {
174 return nb_external_relocations_;
175 }
176 uint32_t local_relocation_offset() const {
181 return local_relocation_offset_;
182 }
183 uint32_t nb_local_relocations() const {
188 return nb_local_relocations_;
189 }
190
191 void idx_local_symbol(uint32_t value) {
192 idx_local_symbol_ = value;
193 }
194 void nb_local_symbols(uint32_t value) {
195 nb_local_symbols_ = value;
196 }
197
198 void idx_external_define_symbol(uint32_t value) {
199 idx_external_define_symbol_ = value;
200 }
201 void nb_external_define_symbols(uint32_t value) {
202 nb_external_define_symbols_ = value;
203 }
204
205 void idx_undefined_symbol(uint32_t value) {
206 idx_undefined_symbol_ = value;
207 }
208 void nb_undefined_symbols(uint32_t value) {
209 nb_undefined_symbols_ = value;
210 }
211
212 void toc_offset(uint32_t value) {
213 toc_offset_ = value;
214 }
215 void nb_toc(uint32_t value) {
216 nb_toc_ = value;
217 }
218
219 void module_table_offset(uint32_t value) {
220 module_table_offset_ = value;
221 }
222 void nb_module_table(uint32_t value) {
223 nb_module_table_ = value;
224 }
225
226 void external_reference_symbol_offset(uint32_t value) {
227 external_reference_symbol_offset_ = value;
228 }
229 void nb_external_reference_symbols(uint32_t value) {
230 nb_external_reference_symbols_ = value;
231 }
232
233 void indirect_symbol_offset(uint32_t value) {
234 indirect_sym_offset_ = value;
235 }
236 void nb_indirect_symbols(uint32_t value) {
237 nb_indirect_symbols_ = value;
238 }
239
240 void external_relocation_offset(uint32_t value) {
241 external_relocation_offset_ = value;
242 }
243 void nb_external_relocations(uint32_t value) {
244 nb_external_relocations_ = value;
245 }
246
247 void local_relocation_offset(uint32_t value) {
248 local_relocation_offset_ = value;
249 }
250 void nb_local_relocations(uint32_t value) {
251 nb_local_relocations_ = value;
252 }
253 it_indirect_symbols indirect_symbols() {
256 return indirect_symbols_;
257 }
258
259 it_const_indirect_symbols indirect_symbols() const {
260 return indirect_symbols_;
261 }
262
263 static bool classof(const LoadCommand* cmd) {
264 return cmd->command() == LoadCommand::TYPE::DYSYMTAB;
265 }
266
267 private:
268 uint32_t idx_local_symbol_ = 0;
269 uint32_t nb_local_symbols_ = 0;
270
271 uint32_t idx_external_define_symbol_ = 0;
272 uint32_t nb_external_define_symbols_ = 0;
273
274 uint32_t idx_undefined_symbol_ = 0;
275 uint32_t nb_undefined_symbols_ = 0;
276
277 uint32_t toc_offset_ = 0;
278 uint32_t nb_toc_ = 0;
279
280 uint32_t module_table_offset_ = 0;
281 uint32_t nb_module_table_ = 0;
282
283 uint32_t external_reference_symbol_offset_ = 0;
284 uint32_t nb_external_reference_symbols_ = 0;
285
286 uint32_t indirect_sym_offset_ = 0;
287 uint32_t nb_indirect_symbols_ = 0;
288
289 uint32_t external_relocation_offset_ = 0;
290 uint32_t nb_external_relocations_ = 0;
291
292 uint32_t local_relocation_offset_ = 0;
293 uint32_t nb_local_relocations_ = 0;
294
295 indirect_symbols_t indirect_symbols_;
296};
297
298}
299}
300#endif
LoadCommand.hpp
LIEF::MachO::BinaryParser
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:74
LIEF::MachO::Binary
Class which represents a MachO binary.
Definition MachO/Binary.hpp:85
LIEF::MachO::Builder
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:57
LIEF::MachO::DynamicSymbolCommand
Class that represents the LC_DYSYMTAB command.
Definition DynamicSymbolCommand.hpp:40
LIEF::MachO::DynamicSymbolCommand::nb_module_table
uint32_t nb_module_table() const
Number of entries in the module table.
Definition DynamicSymbolCommand.hpp:125
LIEF::MachO::DynamicSymbolCommand::nb_local_symbols
void nb_local_symbols(uint32_t value)
Definition DynamicSymbolCommand.hpp:194
LIEF::MachO::DynamicSymbolCommand::local_relocation_offset
void local_relocation_offset(uint32_t value)
Definition DynamicSymbolCommand.hpp:247
LIEF::MachO::DynamicSymbolCommand::idx_undefined_symbol
void idx_undefined_symbol(uint32_t value)
Definition DynamicSymbolCommand.hpp:205
LIEF::MachO::DynamicSymbolCommand::accept
void accept(Visitor &visitor) const override
LIEF::MachO::DynamicSymbolCommand::nb_undefined_symbols
uint32_t nb_undefined_symbols() const
Number of symbols in the group of undefined external symbols.
Definition DynamicSymbolCommand.hpp:96
LIEF::MachO::DynamicSymbolCommand::indirect_symbol_offset
void indirect_symbol_offset(uint32_t value)
Definition DynamicSymbolCommand.hpp:233
LIEF::MachO::DynamicSymbolCommand::external_reference_symbol_offset
void external_reference_symbol_offset(uint32_t value)
Definition DynamicSymbolCommand.hpp:226
LIEF::MachO::DynamicSymbolCommand::idx_external_define_symbol
void idx_external_define_symbol(uint32_t value)
Definition DynamicSymbolCommand.hpp:198
LIEF::MachO::DynamicSymbolCommand::nb_indirect_symbols
uint32_t nb_indirect_symbols() const
Number of entries in the indirect symbol table.
Definition DynamicSymbolCommand.hpp:158
LIEF::MachO::DynamicSymbolCommand::nb_external_relocations
uint32_t nb_external_relocations() const
Number of entries in the external relocation table.
Definition DynamicSymbolCommand.hpp:173
LIEF::MachO::DynamicSymbolCommand::nb_module_table
void nb_module_table(uint32_t value)
Definition DynamicSymbolCommand.hpp:222
LIEF::MachO::DynamicSymbolCommand::external_relocation_offset
void external_relocation_offset(uint32_t value)
Definition DynamicSymbolCommand.hpp:240
LIEF::MachO::DynamicSymbolCommand::indirect_symbols
it_indirect_symbols indirect_symbols()
Iterator over the indirect symbols indexed by this command.
Definition DynamicSymbolCommand.hpp:255
LIEF::MachO::DynamicSymbolCommand::nb_external_define_symbols
uint32_t nb_external_define_symbols() const
Number of symbols in the group of defined external symbols.
Definition DynamicSymbolCommand.hpp:86
LIEF::MachO::DynamicSymbolCommand::print
std::ostream & print(std::ostream &os) const override
LIEF::MachO::DynamicSymbolCommand::nb_undefined_symbols
void nb_undefined_symbols(uint32_t value)
Definition DynamicSymbolCommand.hpp:208
LIEF::MachO::DynamicSymbolCommand::nb_external_reference_symbols
uint32_t nb_external_reference_symbols() const
Number of entries in the external reference table.
Definition DynamicSymbolCommand.hpp:139
LIEF::MachO::DynamicSymbolCommand::clone
std::unique_ptr< LoadCommand > clone() const override
Definition DynamicSymbolCommand.hpp:60
LIEF::MachO::DynamicSymbolCommand::nb_indirect_symbols
void nb_indirect_symbols(uint32_t value)
Definition DynamicSymbolCommand.hpp:236
LIEF::MachO::DynamicSymbolCommand::DynamicSymbolCommand
DynamicSymbolCommand(const details::dysymtab_command &cmd)
LIEF::MachO::DynamicSymbolCommand::nb_local_relocations
void nb_local_relocations(uint32_t value)
Definition DynamicSymbolCommand.hpp:250
LIEF::MachO::DynamicSymbolCommand::external_relocation_offset
uint32_t external_relocation_offset() const
Byte offset from the start of the file to the external relocation table data.
Definition DynamicSymbolCommand.hpp:166
LIEF::MachO::DynamicSymbolCommand::classof
static bool classof(const LoadCommand *cmd)
Definition DynamicSymbolCommand.hpp:263
LIEF::MachO::DynamicSymbolCommand::toc_offset
void toc_offset(uint32_t value)
Definition DynamicSymbolCommand.hpp:212
LIEF::MachO::DynamicSymbolCommand::DynamicSymbolCommand
DynamicSymbolCommand(const DynamicSymbolCommand &copy)=default
LIEF::MachO::DynamicSymbolCommand::nb_local_symbols
uint32_t nb_local_symbols() const
Number of symbols in the group of local symbols.
Definition DynamicSymbolCommand.hpp:76
LIEF::MachO::DynamicSymbolCommand::operator=
DynamicSymbolCommand & operator=(const DynamicSymbolCommand &copy)=default
LIEF::MachO::DynamicSymbolCommand::module_table_offset
uint32_t module_table_offset() const
Byte offset from the start of the file to the module table data.
Definition DynamicSymbolCommand.hpp:118
LIEF::MachO::DynamicSymbolCommand::local_relocation_offset
uint32_t local_relocation_offset() const
Byte offset from the start of the file to the local relocation table data.
Definition DynamicSymbolCommand.hpp:180
LIEF::MachO::DynamicSymbolCommand::indirect_symbol_offset
uint32_t indirect_symbol_offset() const
Byte offset from the start of the file to the indirect symbol table data.
Definition DynamicSymbolCommand.hpp:151
LIEF::MachO::DynamicSymbolCommand::nb_external_define_symbols
void nb_external_define_symbols(uint32_t value)
Definition DynamicSymbolCommand.hpp:201
LIEF::MachO::DynamicSymbolCommand::external_reference_symbol_offset
uint32_t external_reference_symbol_offset() const
Byte offset from the start of the file to the external reference table data.
Definition DynamicSymbolCommand.hpp:132
LIEF::MachO::DynamicSymbolCommand::indirect_symbols
it_const_indirect_symbols indirect_symbols() const
Definition DynamicSymbolCommand.hpp:259
LIEF::MachO::DynamicSymbolCommand::nb_external_reference_symbols
void nb_external_reference_symbols(uint32_t value)
Definition DynamicSymbolCommand.hpp:229
LIEF::MachO::DynamicSymbolCommand::toc_offset
uint32_t toc_offset() const
Byte offset from the start of the file to the table of contents data.
Definition DynamicSymbolCommand.hpp:104
LIEF::MachO::DynamicSymbolCommand::nb_toc
void nb_toc(uint32_t value)
Definition DynamicSymbolCommand.hpp:215
LIEF::MachO::DynamicSymbolCommand::nb_local_relocations
uint32_t nb_local_relocations() const
Number of entries in the local relocation table.
Definition DynamicSymbolCommand.hpp:187
LIEF::MachO::DynamicSymbolCommand::idx_external_define_symbol
uint32_t idx_external_define_symbol() const
Index of the first symbol in the group of defined external symbols.
Definition DynamicSymbolCommand.hpp:81
LIEF::MachO::DynamicSymbolCommand::nb_toc
uint32_t nb_toc() const
Number of entries in the table of contents.
Definition DynamicSymbolCommand.hpp:111
LIEF::MachO::DynamicSymbolCommand::idx_local_symbol
uint32_t idx_local_symbol() const
Index of the first symbol in the group of local symbols.
Definition DynamicSymbolCommand.hpp:71
LIEF::MachO::DynamicSymbolCommand::nb_external_relocations
void nb_external_relocations(uint32_t value)
Definition DynamicSymbolCommand.hpp:243
LIEF::MachO::DynamicSymbolCommand::module_table_offset
void module_table_offset(uint32_t value)
Definition DynamicSymbolCommand.hpp:219
LIEF::MachO::DynamicSymbolCommand::idx_local_symbol
void idx_local_symbol(uint32_t value)
Definition DynamicSymbolCommand.hpp:191
LIEF::MachO::DynamicSymbolCommand::DynamicSymbolCommand
DynamicSymbolCommand()
LIEF::MachO::DynamicSymbolCommand::~DynamicSymbolCommand
~DynamicSymbolCommand() override=default
LIEF::MachO::DynamicSymbolCommand::idx_undefined_symbol
uint32_t idx_undefined_symbol() const
Index of the first symbol in the group of undefined external symbols.
Definition DynamicSymbolCommand.hpp:91
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::Symbol
Class that represents a Symbol in a Mach-O file.
Definition MachO/Symbol.hpp:47
iterators.hpp
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
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41