16#ifndef LIEF_ELF_PARSER_H
17#define LIEF_ELF_PARSER_H
18#include <unordered_map>
70 static std::unique_ptr<Binary>
parse(
const std::string& file,
81 static std::unique_ptr<Binary>
parse(
const std::vector<uint8_t>& data,
92 static std::unique_ptr<Binary>
parse(std::unique_ptr<BinaryStream> stream,
116 template<
typename ELF_T>
119 template<
typename ELF_T>
122 template<
typename ELF_T>
125 template<
typename ELF_T>
132 LIEF_LOCAL uint64_t get_dynamic_string_table_from_sections()
const;
135 template<
typename ELF_T>
140 template<
typename ELF_T>
144 template<
typename ELF_T>
148 template<
typename ELF_T>
152 template<
typename ELF_T>
156 template<
typename ELF_T>
159 template<
typename ELF_T>
162 template<
typename ELF_T>
173 template<
typename ELF_T>
175 parse_symtab_symbols(uint64_t offset, uint32_t nb_symbols,
176 const Section& string_section);
181 template<
typename ELF_T,
typename REL_T>
183 parse_dynamic_relocations(uint64_t relocations_offset, uint64_t size);
190 template<
typename ELF_T,
typename REL_T>
195 template<
typename ELF_T>
199 template<
typename ELF_T>
202 template<
typename ELF_T>
207 template<
typename ELF_T,
typename REL_T>
209 parse_section_relocations(
const Section& section);
216 template<
typename ELF_T>
218 parse_symbol_version_requirement(uint64_t offset, uint32_t nb_entries);
226 template<
typename ELF_T>
228 parse_symbol_version_definition(uint64_t offset, uint32_t nb_entries);
242 template<
typename ELF_T>
249 get_note(uint32_t type, std::string name, std::vector<uint8_t> desc_bytes);
256 template<
typename ELF_T,
typename REL_T>
257 LIEF_LOCAL uint32_t max_relocation_index(uint64_t relocations_offset, uint64_t size)
const;
265 template<
class ELF_T>
268 std::unique_ptr<BinaryStream> stream_;
269 std::unique_ptr<Binary> binary_;
278 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
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:59
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:57
@ ELF64
Definition ELF/Parser.hpp:59
@ ELF_UNKNOWN
Definition ELF/Parser.hpp:58
@ ELF32
Definition ELF/Parser.hpp:59
static constexpr uint32_t MAX_SEGMENT_SIZE
Definition ELF/Parser.hpp:55
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
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:112
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
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
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