16#ifndef LIEF_ELF_PARSER_H
17#define LIEF_ELF_PARSER_H
18#include <unordered_map>
71 static std::unique_ptr<Binary>
parse(
const std::string& file,
82 static std::unique_ptr<Binary>
parse(
const std::vector<uint8_t>& data,
93 static std::unique_ptr<Binary>
parse(std::unique_ptr<BinaryStream> stream,
117 template<
typename ELF_T>
120 template<
typename ELF_T>
123 template<
typename ELF_T>
126 template<
typename ELF_T>
133 LIEF_LOCAL uint64_t get_dynamic_string_table_from_sections()
const;
136 template<
typename ELF_T>
141 template<
typename ELF_T>
145 template<
typename ELF_T>
149 template<
typename ELF_T>
153 template<
typename ELF_T>
157 template<
typename ELF_T>
160 template<
typename ELF_T>
163 template<
typename ELF_T>
174 template<
typename ELF_T>
176 parse_symtab_symbols(uint64_t offset, uint32_t nb_symbols,
177 const Section& string_section);
182 template<
typename ELF_T,
typename REL_T>
184 parse_dynamic_relocations(uint64_t relocations_offset, uint64_t size);
191 template<
typename ELF_T,
typename REL_T>
196 template<
typename ELF_T>
200 template<
typename ELF_T>
203 template<
typename ELF_T>
208 template<
typename ELF_T,
typename REL_T>
210 parse_section_relocations(
const Section& section);
217 template<
typename ELF_T>
219 parse_symbol_version_requirement(uint64_t offset, uint32_t nb_entries);
227 template<
typename ELF_T>
229 parse_symbol_version_definition(uint64_t offset, uint32_t nb_entries);
243 template<
typename ELF_T>
250 get_note(uint32_t type, std::string name, std::vector<uint8_t> desc_bytes);
257 template<
typename ELF_T,
typename REL_T>
258 LIEF_LOCAL uint32_t max_relocation_index(uint64_t relocations_offset, uint64_t size)
const;
266 template<
class ELF_T>
269 std::unique_ptr<BinaryStream> stream_;
270 std::unique_ptr<Binary> binary_;
279 std::unordered_map<size_t, Section*> sections_idx_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
Abstract binary that exposes an uniform API for the different executable file formats.
Definition Abstract/Binary.hpp:53
static constexpr uint32_t NB_MAX_MASKWORD
Definition ELF/Parser.hpp:55
static constexpr uint32_t NB_MAX_BUCKETS
Definition ELF/Parser.hpp:50
friend class OAT::Parser
Definition ELF/Parser.hpp:46
static constexpr uint32_t NB_MAX_SYMBOLS
Definition ELF/Parser.hpp:48
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 constexpr uint32_t DELTA_NB_SYMBOLS
Definition ELF/Parser.hpp:49
static constexpr uint32_t NB_MAX_RELOCATIONS
Definition ELF/Parser.hpp:53
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(const std::string &file, const ParserConfig &conf=ParserConfig::all())
Parse an ELF file and return a LIEF::ELF::Binary object.
static constexpr uint32_t NB_MAX_CHAINS
Definition ELF/Parser.hpp:51
ELF_TYPE
Definition ELF/Parser.hpp:58
@ ELF64
Definition ELF/Parser.hpp:60
@ ELF_UNKNOWN
Definition ELF/Parser.hpp:59
@ ELF32
Definition ELF/Parser.hpp:60
static constexpr uint32_t MAX_SEGMENT_SIZE
Definition ELF/Parser.hpp:56
Parser(const Parser &)=delete
Parser & operator=(const Parser &)=delete
static constexpr uint32_t NB_MAX_SEGMENTS
Definition ELF/Parser.hpp:52
static constexpr uint32_t NB_MAX_DYNAMIC_ENTRIES
Definition ELF/Parser.hpp:54
Class that represents an ELF relocation.
Definition ELF/Relocation.hpp:40
Class which represents an ELF Section.
Definition ELF/Section.hpp:48
Class which represents the ELF segments.
Definition Segment.hpp:48
Class which represents an ELF symbol.
Definition ELF/Symbol.hpp:35
Class to parse an OAT file to produce an OAT::Binary.
Definition OAT/Parser.hpp:38
Main interface to parse an executable regardless of its format.
Definition Abstract/Parser.hpp:30
Class which represents an abstracted Relocation.
Definition Abstract/Relocation.hpp:27
Class which represents an abstracted section.
Definition Abstract/Section.hpp:29
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
Definition ELF/Parser.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:40
result< ok_t > ok_error_t
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:109
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
This structure is used to tweak the ELF Parser (ELF::Parser).
Definition ELF/ParserConfig.hpp:25
DYNSYM_COUNT
Definition ELF/ParserConfig.hpp:28
static ParserConfig all()
This returns a ParserConfig object configured to process all the ELF elements.
Definition ELF/ParserConfig.hpp:37
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42