16#ifndef LIEF_ELF_PARSER_H
17#define LIEF_ELF_PARSER_H
19#include <unordered_map>
20#include <unordered_set>
76 static std::unique_ptr<Binary>
81 template<
class PathT, enable_if_path_t<PathT> = 0>
82 static std::unique_ptr<Binary>
84 return parse(file.string(), conf);
97 static std::unique_ptr<Binary>
98 parse(
const std::vector<uint8_t>& data,
111 static std::unique_ptr<Binary>
112 parse(std::unique_ptr<BinaryStream> stream,
121 static std::unique_ptr<Binary>
132 static std::unique_ptr<Binary>
145 static std::unique_ptr<Binary>
151 template<
class PathT, enable_if_path_t<PathT> = 0>
152 static std::unique_ptr<Binary>
160 static std::unique_ptr<Binary>
166 static std::unique_ptr<Binary>
191 template<
typename ELF_T>
194 template<
typename ELF_T>
197 template<
typename ELF_T>
200 template<
typename ELF_T>
204 get_dynamic_string_table(
BinaryStream* stream =
nullptr)
const;
207 get_dynamic_string_table_from_segments(
BinaryStream* stream =
nullptr)
const;
209 LIEF_LOCAL uint64_t get_dynamic_string_table_from_sections()
const;
212 template<
typename ELF_T>
217 template<
typename ELF_T>
221 template<
typename ELF_T>
225 template<
typename ELF_T>
229 template<
typename ELF_T>
233 template<
typename ELF_T>
236 template<
typename ELF_T>
239 template<
typename ELF_T>
251 template<
typename ELF_T>
253 const Section& string_section);
258 template<
typename ELF_T,
typename REL_T>
267 template<
typename ELF_T,
typename REL_T>
272 template<
typename ELF_T>
276 template<
typename ELF_T>
279 template<
typename ELF_T>
284 template<
typename ELF_T,
typename REL_T>
292 template<
typename ELF_T>
294 uint32_t nb_entries);
302 template<
typename ELF_T>
304 uint32_t nb_entries);
318 template<
typename ELF_T>
324 LIEF_LOCAL std::unique_ptr<Note> get_note(uint32_t type, std::string name,
325 std::vector<uint8_t> desc_bytes);
332 template<
typename ELF_T,
typename REL_T>
333 LIEF_LOCAL uint32_t max_relocation_index(uint64_t relocations_offset,
334 uint64_t size)
const;
343 template<
class ELF_T>
346 std::unique_ptr<BinaryStream> stream_;
347 std::unique_ptr<Binary> binary_;
356 std::unordered_map<size_t, Section*> sections_idx_;
357 uint64_t memory_address_ = 0;
358 std::unordered_set<uint64_t> notes_offset_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:35
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:61
static std::unique_ptr< Binary > parse_from_dump(std::string_view filepath, uint64_t addr, const ParserConfig &conf=ParserConfig::all())
Parse an ELF binary from a memory dump located on disk.
static std::unique_ptr< Binary > parse(std::string_view file, const ParserConfig &conf=ParserConfig::all())
Parse an ELF file and return a LIEF::ELF::Binary object.
static std::unique_ptr< Binary > parse(const PathT &file, const ParserConfig &conf=ParserConfig::all())
Same as parse(std::string_view, const ParserConfig&) but the file is given as a std::filesystem::path...
Definition ELF/Parser.hpp:83
static std::unique_ptr< Binary > parse_from_dump(BinaryStream &stream, uint64_t addr, const ParserConfig &conf=ParserConfig::all())
Same as parse_from_dump(std::string_view, uint64_t, const ParserConfig&) but the dump is wrapped in t...
static constexpr uint32_t NB_MAX_BUCKETS
Definition ELF/Parser.hpp:53
static constexpr uint32_t NB_MAX_SECTION_SEGMENT_LINKS
Definition ELF/Parser.hpp:56
friend class OAT::Parser
Definition ELF/Parser.hpp:48
static constexpr uint32_t NB_MAX_SYMBOLS
Definition ELF/Parser.hpp:51
static std::unique_ptr< Binary > parse_from_dump(const PathT &filepath, uint64_t addr, const ParserConfig &conf=ParserConfig::all())
Same as parse_from_dump(std::string_view, uint64_t, const ParserConfig&) but the dump file is given a...
Definition ELF/Parser.hpp:153
static std::unique_ptr< Binary > parse(std::unique_ptr< BinaryStream > stream, const ParserConfig &conf=ParserConfig::all())
Parse the ELF binary from the given stream and return a LIEF::ELF::Binary object.
static std::unique_ptr< Binary > parse_from_dump(std::unique_ptr< BinaryStream > stream, uint64_t addr, const ParserConfig &conf=ParserConfig::all())
Same as parse_from_dump(std::string_view, uint64_t, const ParserConfig&) but the dump is wrapped in t...
static constexpr uint32_t DELTA_NB_SYMBOLS
Definition ELF/Parser.hpp:52
static constexpr uint32_t NB_MAX_RELOCATIONS
Definition ELF/Parser.hpp:57
static std::unique_ptr< Binary > parse(const std::vector< uint8_t > &data, const ParserConfig &conf=ParserConfig::all())
Parse the given raw data as an ELF binary and return a LIEF::ELF::Binary object.
static std::unique_ptr< Binary > parse_from_memory(uintptr_t address, const ParserConfig &conf=ParserConfig::all())
Parse the ELF binary from the given memory address.
static std::unique_ptr< Binary > parse_from_memory(uintptr_t address, size_t size, const ParserConfig &conf=ParserConfig::all())
Parse the ELF binary from the given memory address with the given size.
static constexpr uint32_t NB_MAX_CHAINS
Definition ELF/Parser.hpp:54
ELF_TYPE
Definition ELF/Parser.hpp:61
@ ELF64
Definition ELF/Parser.hpp:64
@ ELF_UNKNOWN
Definition ELF/Parser.hpp:62
@ ELF32
Definition ELF/Parser.hpp:63
static constexpr uint32_t MAX_SEGMENT_SIZE
Definition ELF/Parser.hpp:59
Parser(const Parser &)=delete
Parser & operator=(const Parser &)=delete
static constexpr uint32_t NB_MAX_SEGMENTS
Definition ELF/Parser.hpp:55
static constexpr uint32_t NB_MAX_DYNAMIC_ENTRIES
Definition ELF/Parser.hpp:58
Class that represents an ELF relocation.
Definition ELF/Relocation.hpp:43
Class which represents an ELF Section.
Definition ELF/Section.hpp:50
Class which represents the ELF segments.
Definition Segment.hpp:49
Class which represents an ELF symbol.
Definition ELF/Symbol.hpp:34
Class to parse an OAT file to produce an OAT::Binary.
Definition OAT/Parser.hpp:42
Main interface to parse an executable regardless of its format.
Definition Abstract/Parser.hpp:32
Class which represents an abstracted Relocation.
Definition Abstract/Relocation.hpp:27
Class which represents an abstracted section.
Definition Abstract/Section.hpp:31
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:30
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:119
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:79
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
Definition ELF/Parser.hpp:34
LIEF namespace.
Definition Abstract/Binary.hpp:42
This structure is used to tweak the ELF Parser (ELF::Parser).
Definition ELF/ParserConfig.hpp:26
DYNSYM_COUNT
Methods that can be used by the LIEF::ELF::Parser to count the number of dynamic symbols.
Definition ELF/ParserConfig.hpp:29
static ParserConfig all()
This returns a ParserConfig object configured to process all the ELF elements.
Definition ELF/ParserConfig.hpp:45
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46