LIEF: Library to Instrument Executable Formats Version 0.16.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_MACHO_SYMBOL_H
17#define LIEF_MACHO_SYMBOL_H
49 friend class BinaryParser;
53 static constexpr int SELF_LIBRARY_ORD = 0x0;
54 static constexpr int MAIN_EXECUTABLE_ORD = 0xff;
55 static constexpr int DYNAMIC_LOOKUP_ORD = 0xfe;
56 enum class CATEGORY : uint32_t {
70 enum class ORIGIN : uint32_t {
77 enum class TYPE : uint32_t{
85 static constexpr uint32_t TYPE_MASK = 0x0e;
91 Symbol(
const details::nlist_32& cmd);
92 Symbol(
const details::nlist_64& cmd);
93 Symbol(uint8_t n_type, uint8_t n_sect, uint8_t n_desc, uint64_t value) :
95 numberof_sections_{n_sect},
97 origin_{ORIGIN::LC_SYMTAB}
104 void swap(Symbol& other)
noexcept;
110 return idx != SELF_LIBRARY_ORD && idx != MAIN_EXECUTABLE_ORD &&
111 idx != DYNAMIC_LOOKUP_ORD;
115 return (description() >> 8) & 0xff;
125 return TYPE(type_ & TYPE_MASK);
131 return numberof_sections_;
142 return export_info() !=
nullptr;
157 return binding_info() !=
nullptr;
163 return binding_info_;
167 return binding_info_;
175 return type() == TYPE::UNDEFINED;
177 const DylibCommand*
library()
const {
202 numberof_sections_ = nbsections;
208 void accept(Visitor& visitor)
const override;
217 Symbol(CATEGORY cat) :
220 void library(DylibCommand& library) {
221 this->library_ = &library;
225 uint8_t numberof_sections_ = 0;
226 uint16_t description_ = 0;
228 BindingInfo* binding_info_ =
nullptr;
229 ExportInfo* export_info_ =
nullptr;
231 DylibCommand* library_ =
nullptr;
233 ORIGIN origin_ = ORIGIN::UNKNOWN;
234 CATEGORY category_ = CATEGORY::NONE;
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:74
Class which represents a MachO binary.
Definition MachO/Binary.hpp:85
Class that provides an interface over a binding operation.
Definition BindingInfo.hpp:39
Class which represents a library dependency.
Definition DylibCommand.hpp:34
Class that provides an interface over the Dyld export info.
Definition ExportInfo.hpp:38
Class that represents a Symbol in a Mach-O file.
Definition MachO/Symbol.hpp:47
ORIGIN
Definition MachO/Symbol.hpp:70
void description(uint16_t desc)
Definition MachO/Symbol.hpp:204
uint8_t numberof_sections() const
It returns the number of sections in which this symbol can be found. If the symbol can't be found in ...
Definition MachO/Symbol.hpp:130
bool is_external() const
True if the symbol is defined as an external symbol.
Definition MachO/Symbol.hpp:174
const DylibCommand * library() const
Return the library in which the symbol is defined. It returns a null pointer if the library can't be ...
Definition MachO/Symbol.hpp:180
static const Symbol & indirect_local()
std::string demangled_name() const
Try to demangle the symbol or return an empty string if it is not possible.
void raw_type(uint8_t type)
Definition MachO/Symbol.hpp:198
static bool is_valid_index_ordinal(int idx)
Definition MachO/Symbol.hpp:109
void swap(Symbol &other) noexcept
Symbol(const details::nlist_32 &cmd)
~Symbol() override=default
void accept(Visitor &visitor) const override
CATEGORY
Category of the symbol when the symbol comes from the LC_SYMTAB command. The category is defined acco...
Definition MachO/Symbol.hpp:59
uint16_t description() const
Return information about the symbol (SYMBOL_DESCRIPTIONS)
Definition MachO/Symbol.hpp:135
TYPE
Definition MachO/Symbol.hpp:77
Symbol(const details::nlist_64 &cmd)
void numberof_sections(uint8_t nbsections)
Definition MachO/Symbol.hpp:201
bool has_export_info() const
True if the symbol is associated with an ExportInfo This value is set when the symbol comes from the ...
Definition MachO/Symbol.hpp:141
BindingInfo * binding_info()
Definition MachO/Symbol.hpp:166
friend std::ostream & operator<<(std::ostream &os, const Symbol &symbol)
ORIGIN origin() const
Return the origin of the symbol: from LC_SYMTAB command or from the Dyld information.
Definition MachO/Symbol.hpp:189
uint8_t raw_type() const
Raw value of nlist_xx.n_type
Definition MachO/Symbol.hpp:119
int library_ordinal() const
Definition MachO/Symbol.hpp:114
static const Symbol & indirect_abs()
ExportInfo * export_info()
Definition MachO/Symbol.hpp:150
Symbol & operator=(Symbol other)
static const Symbol & indirect_abs_local()
CATEGORY category() const
Category of the symbol according to the LC_DYSYMTAB command.
Definition MachO/Symbol.hpp:194
Symbol(const Symbol &other)
const ExportInfo * export_info() const
Return the ExportInfo associated with this symbol (or nullptr if not present)
Definition MachO/Symbol.hpp:147
const BindingInfo * binding_info() const
Return the BindingInfo associated with this symbol (or nullptr if not present)
Definition MachO/Symbol.hpp:162
bool has_binding_info() const
True if the symbol is associated with a BindingInfo This value is set when the symbol comes from the ...
Definition MachO/Symbol.hpp:156
DylibCommand * library()
Definition MachO/Symbol.hpp:184
Symbol(uint8_t n_type, uint8_t n_sect, uint8_t n_desc, uint64_t value)
Definition MachO/Symbol.hpp:93
TYPE type() const
Type as defined by nlist_xx.n_type & N_TYPE
Definition MachO/Symbol.hpp:124
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
@ UNKNOWN
Definition MachO/enums.hpp:25
const char * to_string(BuildToolVersion::TOOLS tool)
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41