LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
ELF/Binary.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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_ELF_BINARY_H
17#define LIEF_ELF_BINARY_H
18
19#include <string_view>
20#include <memory>
21#include <vector>
22
24#include "LIEF/errors.hpp"
25#include "LIEF/iterators.hpp"
26#include "LIEF/visibility.h"
27
29
30#include "LIEF/ELF/Builder.hpp"
32#include "LIEF/ELF/Header.hpp"
33#include "LIEF/ELF/Note.hpp"
34#include "LIEF/ELF/Section.hpp"
35#include "LIEF/ELF/Segment.hpp"
36
37
39namespace LIEF::ELF {
40namespace DataHandler {
41class Handler;
42}
43
44class ExeLayout;
45class GnuHash;
46class Layout;
47class ObjectFileLayout;
48class Parser;
49class Relocation;
50class Section;
51class Segment;
52class Symbol;
53class SymbolVersion;
57class SysvHash;
58struct sizing_info_t;
59
62 friend class Parser;
63 friend class Builder;
64 friend class ExeLayout;
65 friend class Layout;
66 friend class ObjectFileLayout;
67
68 public:
69 using string_list_t = std::vector<std::string>;
70
72 using notes_t = std::vector<std::unique_ptr<Note>>;
73
76
79
82 std::vector<std::unique_ptr<SymbolVersionRequirement>>;
83
87
92
95 std::vector<std::unique_ptr<SymbolVersionDefinition>>;
96
100
105
107 using segments_t = std::vector<std::unique_ptr<Segment>>;
108
111
114
116 using dynamic_entries_t = std::vector<std::unique_ptr<DynamicEntry>>;
117
120
124
126 using symbols_version_t = std::vector<std::unique_ptr<SymbolVersion>>;
127
130
134
136 using relocations_t = std::vector<std::unique_ptr<Relocation>>;
137
140
144
148
153
156
160
163
167
169 using symbols_t = std::vector<std::unique_ptr<Symbol>>;
170
173
177
180
184
187
190
193
196
199
202
204 using sections_t = std::vector<std::unique_ptr<Section>>;
205
208
211
212 public:
245
248 enum class SEC_INSERT_POS {
250 AUTO = 0,
251
257 POST_SEGMENT,
258
262 POST_SECTION,
263 };
264
265 public:
266 Binary& operator=(const Binary&) = delete;
267 Binary(const Binary& copy) = delete;
268
271 return type_;
272 }
273
276 return header_;
277 }
278
280 return header_;
281 }
282
285 uint64_t last_offset_section() const;
286
289 uint64_t last_offset_segment() const;
290
292 uint64_t next_virtual_address() const;
293
296 return sections_;
297 }
298
300 return sections_;
301 }
302
304 uint64_t entrypoint() const override {
305 return header_.entrypoint();
306 }
307
310 return segments_;
311 }
312
314 return segments_;
315 }
316
319 return dynamic_entries_;
320 }
321
323 return dynamic_entries_;
324 }
325
328
331
333 void remove(const DynamicEntry& entry);
334
337
343 void remove(const Section& section, bool clear = false);
344
346 void remove(const Note& note);
347
350
353 void remove(const Segment& seg, bool clear = false);
354
359 void remove(Segment::TYPE type, bool clear = false);
360
364 return dynamic_symbols_;
365 }
366
368 return dynamic_symbols_;
369 }
370
374
378
381 return symtab_symbols_;
382 }
383
385 return symtab_symbols_;
386 }
387
390 return symbol_version_table_;
391 }
393 return symbol_version_table_;
394 }
395
398 return symbol_version_definition_;
399 }
400
401 it_const_symbols_version_definition
403 return symbol_version_definition_;
404 }
405
408 return symbol_version_requirements_;
409 }
410
411 it_const_symbols_version_requirement
413 return symbol_version_requirements_;
414 }
415
419
427
434
443 const Section& section) LIEF_LIFETIMEBOUND;
444
448
452
455 return relocations_;
456 }
457
459 return relocations_;
460 }
461
464 const Relocation* get_relocation(uint64_t address) const LIEF_LIFETIMEBOUND;
466 return const_cast<Relocation*>(
467 static_cast<const Binary*>(this)->get_relocation(address)
468 );
469 }
470
475 return const_cast<Relocation*>(
476 static_cast<const Binary*>(this)->get_relocation(symbol)
477 );
478 }
479
482 const Relocation*
483 get_relocation(const std::string& symbol_name) const LIEF_LIFETIMEBOUND;
484 Relocation* get_relocation(const std::string& symbol_name) LIEF_LIFETIMEBOUND {
485 return const_cast<Relocation*>(
486 static_cast<const Binary*>(this)->get_relocation(symbol_name)
487 );
488 }
489
493 bool use_gnu_hash() const {
494 return gnu_hash_ != nullptr && has(DynamicEntry::TAG::GNU_HASH);
495 }
496
500 return use_gnu_hash() ? gnu_hash_.get() : nullptr;
501 }
502
506 bool use_sysv_hash() const {
507 return sysv_hash_ != nullptr && has(DynamicEntry::TAG::HASH);
508 }
509
513 return use_sysv_hash() ? sysv_hash_.get() : nullptr;
514 }
515
517 bool has_section(const std::string& name) const {
518 return get_section(name) != nullptr;
519 }
520
522 bool has_section_with_offset(uint64_t offset) const;
523
525 bool has_section_with_va(uint64_t va) const;
526
529 Section* get_section(std::string_view name) LIEF_LIFETIMEBOUND {
530 return const_cast<Section*>(
531 static_cast<const Binary*>(this)->get_section(name)
532 );
533 }
534 const Section* get_section(std::string_view name) const LIEF_LIFETIMEBOUND;
535
539 return get_section(".text");
540 }
541
545
549
553
558 uint64_t imagebase() const override;
559
561 uint64_t virtual_size() const override;
562
565 bool has_interpreter() const;
566
571 std::string_view interpreter() const LIEF_LIFETIMEBOUND {
572 return interpreter_;
573 }
574
576 void interpreter(const std::string& interpreter) {
577 interpreter_ = interpreter;
578 }
579
582 return symtab_dyn_symbols();
583 }
584
586 return symtab_dyn_symbols();
587 }
588
591
593 Symbol& export_symbol(const std::string& symbol_name,
594 uint64_t value = 0) LIEF_LIFETIMEBOUND;
595
598 bool has_dynamic_symbol(const std::string& name) const {
599 return get_dynamic_symbol(name) != nullptr;
600 }
601
604 const Symbol*
605 get_dynamic_symbol(const std::string& name) const LIEF_LIFETIMEBOUND;
606
607 Symbol* get_dynamic_symbol(const std::string& name) LIEF_LIFETIMEBOUND {
608 return const_cast<Symbol*>(
609 static_cast<const Binary*>(this)->get_dynamic_symbol(name)
610 );
611 }
612
614 bool has_symtab_symbol(const std::string& name) const {
615 return get_symtab_symbol(name) != nullptr;
616 }
617
620 const Symbol*
621 get_symtab_symbol(const std::string& name) const LIEF_LIFETIMEBOUND;
622
623 Symbol* get_symtab_symbol(const std::string& name) LIEF_LIFETIMEBOUND {
624 return const_cast<Symbol*>(
625 static_cast<const Binary*>(this)->get_symtab_symbol(name)
626 );
627 }
628
632 string_list_t strings(size_t min_size = 5) const;
633
639 void remove_symbol(const std::string& name);
640
642 void remove_symtab_symbol(const std::string& name);
644
646 void remove_dynamic_symbol(const std::string& name);
647
654
657 get_function_address(const std::string& func_name) const override;
658
660 //
663 result<uint64_t> get_function_address(const std::string& func_name,
664 bool demangled) const;
665
677 Section* add(const Section& section, bool loaded = true,
679
680 Section* extend(const Section& section, uint64_t size) LIEF_LIFETIMEBOUND;
681
684
687 nullptr) LIEF_LIFETIMEBOUND;
688
690 Symbol& add_exported_function(uint64_t address,
691 const std::string& name = "") LIEF_LIFETIMEBOUND;
692
695 add_library(const std::string& library_name) LIEF_LIFETIMEBOUND;
696
698 void remove_library(const std::string& library_name);
699
703 get_library(const std::string& library_name) LIEF_LIFETIMEBOUND {
704 return const_cast<DynamicEntryLibrary*>(
705 static_cast<const Binary*>(this)->get_library(library_name)
706 );
707 }
708
712 get_library(const std::string& library_name) const LIEF_LIFETIMEBOUND;
713
715 bool has_library(const std::string& name) const {
716 return get_library(name) != nullptr;
717 }
718
726 Segment* add(const Segment& segment, uint64_t base = 0) LIEF_LIFETIMEBOUND;
727
732 Segment* replace(const Segment& new_segment, const Segment& original_segment,
733 uint64_t base = 0) LIEF_LIFETIMEBOUND;
734
735 Segment* extend(const Segment& segment, uint64_t size) LIEF_LIFETIMEBOUND;
736
737
744 void patch_address(uint64_t address, const std::vector<uint8_t>& patch_value,
745 LIEF::Binary::VA_TYPES addr_type =
746 LIEF::Binary::VA_TYPES::AUTO) override;
747
748
757 uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t),
758 LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO
759 ) override;
760
765 void patch_pltgot(const Symbol& symbol, uint64_t address);
766
767
772 void patch_pltgot(const std::string& symbol_name, uint64_t address);
773
775 void strip();
776
781 void remove_section(const std::string& name, bool clear = false) override;
782
789 void write(const std::string& filename) {
790 return write(filename, Builder::config_t{});
791 }
792
801 void write(const std::string& filename, const Builder::config_t& config);
802
809 void write(std::ostream& os) {
810 return write(os, Builder::config_t{});
811 }
812
818 void write(std::ostream& os, const Builder::config_t& config);
819
821 std::vector<uint8_t> raw();
822
824 result<uint64_t> virtual_address_to_offset(uint64_t virtual_address) const;
825
832 uint64_t slide = 0) const override;
833
838 bool is_pie() const override;
839
841 bool has_nx() const override;
842
845 int64_t dynsym_idx(const std::string& name) const;
846
847 int64_t dynsym_idx(const Symbol& sym) const;
848
850 int64_t symtab_idx(const std::string& name) const;
851
852 int64_t symtab_idx(const Symbol& sym) const;
853
860 const Section*
861 section_from_offset(uint64_t offset,
862 bool skip_nobits = true) const LIEF_LIFETIMEBOUND;
863 Section* section_from_offset(uint64_t offset,
864 bool skip_nobits = true) LIEF_LIFETIMEBOUND {
865 return const_cast<Section*>(
866 static_cast<const Binary*>(this)->section_from_offset(offset, skip_nobits)
867 );
868 }
869
876 uint64_t address, bool skip_nobits = true
877 ) const LIEF_LIFETIMEBOUND;
878
879 Section*
881 bool skip_nobits = true) LIEF_LIFETIMEBOUND {
882 return const_cast<Section*>(
883 static_cast<const Binary*>(this)->section_from_virtual_address(address,
884 skip_nobits)
885 );
886 }
887
890 const Segment*
892
894 return const_cast<Segment*>(
895 static_cast<const Binary*>(this)->segment_from_virtual_address(address)
896 );
897 }
898
899
900 const Segment*
902 uint64_t address) const LIEF_LIFETIMEBOUND;
904 uint64_t address) LIEF_LIFETIMEBOUND {
905 return const_cast<Segment*>(
906 static_cast<const Binary*>(this)->segment_from_virtual_address(type,
907 address)
908 );
909 }
910
913 const Segment* segment_from_offset(uint64_t offset) const LIEF_LIFETIMEBOUND;
915 return const_cast<Segment*>(
916 static_cast<const Binary*>(this)->segment_from_offset(offset)
917 );
918 }
919
924 return const_cast<DynamicEntry*>(static_cast<const Binary*>(this)->get(tag));
925 }
926
931 return const_cast<Segment*>(static_cast<const Binary*>(this)->get(type));
932 }
933
938 return const_cast<Note*>(static_cast<const Binary*>(this)->get(type));
939 }
940
945 return const_cast<Section*>(static_cast<const Binary*>(this)->get(type));
946 }
947
949 bool has(DynamicEntry::TAG tag) const {
950 return get(tag) != nullptr;
951 }
952
954 bool has(Segment::TYPE type) const {
955 return get(type) != nullptr;
956 }
957
959 bool has(Note::TYPE type) const {
960 return get(type) != nullptr;
961 }
962
964 bool has(Section::TYPE type) const {
965 return get(type) != nullptr;
966 }
967
970 uint64_t virtual_address, uint64_t size,
972 ) const LIEF_LIFETIMEBOUND override;
973
975 void accept(LIEF::Visitor& visitor) const override;
976
978 void permute_dynamic_symbols(const std::vector<size_t>& permutation);
979
983
987
990
992 bool has_notes() const;
993
998 return notes_;
999 }
1000
1002 return notes_;
1003 }
1004
1007 uint64_t eof_offset() const;
1008
1010 bool has_overlay() const {
1011 return !overlay_.empty();
1012 }
1013
1016 return overlay_;
1017 }
1018
1020 void overlay(std::vector<uint8_t> overlay) {
1021 overlay_ = std::move(overlay);
1022 }
1023
1033
1036 std::vector<uint64_t> get_relocated_dynamic_array(DynamicEntry::TAG tag) const;
1037
1040
1043 auto it = std::find_if(sections_.begin(), sections_.end(),
1044 [&section](const std::unique_ptr<Section>& S) {
1045 return S.get() == &section;
1046 });
1047 if (it == sections_.end()) {
1049 }
1050 return std::distance(sections_.begin(), it);
1051 }
1052
1054 result<size_t> get_section_idx(const std::string& name) const {
1055 auto it = std::find_if(sections_.begin(), sections_.end(),
1056 [name](const std::unique_ptr<Section>& S) {
1057 return S->name() == name;
1058 });
1059 if (it == sections_.end()) {
1061 }
1062 return std::distance(sections_.begin(), it);
1063 }
1064
1068 const std::string& libname
1069 ) const LIEF_LIFETIMEBOUND;
1070
1073 return const_cast<SymbolVersionRequirement*>(
1074 static_cast<const Binary*>(this)->find_version_requirement(name)
1075 );
1076 }
1077
1084 bool remove_version_requirement(const std::string& libname);
1085
1086 uint8_t ptr_size() const {
1087 switch (type()) {
1088 case Header::CLASS::ELF32: return sizeof(uint32_t);
1089 case Header::CLASS::ELF64: return sizeof(uint64_t);
1090 default: return 0;
1091 }
1092 return 0;
1093 }
1094
1095 uint64_t page_size() const override;
1096
1097 uint64_t layout_pagesize() const;
1098
1099 static bool classof(const LIEF::Binary* bin) {
1100 return bin->format() == Binary::FORMATS::ELF ||
1101 bin->format() == Binary::FORMATS::OAT;
1102 }
1103
1104 size_t hash(const std::string& name);
1105
1106 ~Binary() override;
1107
1108 std::ostream& print(std::ostream& os) const override;
1109
1111 add(entry);
1112 return *this;
1113 }
1115 add(section);
1116 return *this;
1117 }
1118
1120 add(segment);
1121 return *this;
1122 }
1123
1125 add(note);
1126 return *this;
1127 }
1128
1130 remove(entry);
1131 return *this;
1132 }
1133
1135 remove(tag);
1136 return *this;
1137 }
1138
1140 remove(note);
1141 return *this;
1142 }
1143
1145 remove(type);
1146 return *this;
1147 }
1148
1152
1154 return get(type);
1155 }
1156
1160
1162 return get(tag);
1163 }
1164
1168
1170 return get(type);
1171 }
1172
1176
1178 return get(type);
1179 }
1180
1181 bool should_swap() const {
1182 return should_swap_;
1183 }
1184
1185 protected:
1186 struct phdr_relocation_info_t {
1187 uint64_t new_offset = 0;
1188 size_t nb_segments = 0;
1189 void clear() {
1190 new_offset = 0;
1191 nb_segments = 0;
1192 }
1193 };
1194 uint64_t entry_size(DynamicEntry::TAG ent_tag, uint64_t fallback) const {
1195 if (const DynamicEntry* dt_ent = get(ent_tag)) {
1196 return dt_ent->value();
1197 }
1198 return fallback;
1199 }
1200
1201 LIEF_LOCAL Binary();
1202
1204 LIEF_LOCAL LIEF::Binary::sections_t get_abstract_sections() override;
1205
1206 LIEF_LOCAL LIEF::Header get_abstract_header() const override {
1207 return LIEF::Header::from(*this);
1208 }
1209
1211 get_abstract_exported_functions() const override;
1213 get_abstract_imported_functions() const override;
1214 LIEF_LOCAL std::vector<std::string>
1215 get_abstract_imported_libraries() const override;
1216 LIEF_LOCAL LIEF::Binary::symbols_t get_abstract_symbols() override;
1217 LIEF_LOCAL LIEF::Binary::relocations_t get_abstract_relocations() override;
1218
1219 template<ELF::ARCH ARCH>
1220 LIEF_LOCAL void patch_relocations(uint64_t from, uint64_t shift);
1221
1222 template<class T>
1223 LIEF_LOCAL void patch_addend(Relocation& relocatio, uint64_t from,
1224 uint64_t shift);
1225
1226 LIEF_LOCAL void shift_sections(uint64_t from, uint64_t shift);
1227 LIEF_LOCAL void shift_segments(uint64_t from, uint64_t shift);
1228 LIEF_LOCAL void shift_dynamic_entries(uint64_t from, uint64_t shift);
1229 LIEF_LOCAL void shift_symbols(uint64_t from, uint64_t shift);
1230 LIEF_LOCAL void shift_relocations(uint64_t from, uint64_t shift);
1231
1232 template<class ELF_T>
1233 LIEF_LOCAL void fix_got_entries(uint64_t from, uint64_t shift);
1234
1235 LIEF_LOCAL LIEF::Binary::functions_t eh_frame_functions() const;
1236 LIEF_LOCAL LIEF::Binary::functions_t armexid_functions() const;
1237
1238 template<Header::FILE_TYPE OBJECT_TYPE, bool note = false>
1239 LIEF_LOCAL Segment* add_segment(const Segment& segment,
1240 uint64_t base) LIEF_LIFETIMEBOUND;
1241
1242 LIEF_LOCAL uint64_t relocate_phdr_table_auto(size_t required_segments = 1);
1243 LIEF_LOCAL uint64_t reuse_phdr_table();
1244 LIEF_LOCAL uint64_t relocate_phdr_table_pie();
1245 LIEF_LOCAL uint64_t relocate_phdr_table_v1();
1246 LIEF_LOCAL uint64_t relocate_phdr_table_v2();
1247 LIEF_LOCAL uint64_t relocate_phdr_table_v3();
1248
1249 template<Segment::TYPE PT>
1250 LIEF_LOCAL Segment* extend_segment(const Segment& segment,
1251 uint64_t size) LIEF_LIFETIMEBOUND;
1252
1253 template<bool LOADED>
1254 LIEF_LOCAL Section* add_section(const Section& section,
1255 SEC_INSERT_POS pos) LIEF_LIFETIMEBOUND;
1256
1257 std::vector<Symbol*> symtab_dyn_symbols() const LIEF_LIFETIMEBOUND;
1258
1259 LIEF_LOCAL std::string_view shstrtab_name() const;
1260 LIEF_LOCAL Section* add_frame_section(const Section& sec) LIEF_LIFETIMEBOUND;
1261 LIEF_LOCAL Section* add_section(std::unique_ptr<Section> sec) LIEF_LIFETIMEBOUND;
1262
1263 LIEF_LOCAL LIEF::Binary::functions_t tor_functions(DynamicEntry::TAG tag) const;
1264
1265 Header::CLASS type_ = Header::CLASS::NONE;
1266 Header header_;
1267 sections_t sections_;
1268 segments_t segments_;
1269 dynamic_entries_t dynamic_entries_;
1270 symbols_t dynamic_symbols_;
1271 symbols_t symtab_symbols_;
1272 relocations_t relocations_;
1273 symbols_version_t symbol_version_table_;
1274 symbols_version_requirement_t symbol_version_requirements_;
1275 symbols_version_definition_t symbol_version_definition_;
1276 notes_t notes_;
1277 std::unique_ptr<GnuHash> gnu_hash_;
1278 std::unique_ptr<SysvHash> sysv_hash_;
1279 std::unique_ptr<DataHandler::Handler> datahandler_;
1280 phdr_relocation_info_t phdr_reloc_info_;
1281
1282 std::string interpreter_;
1283 std::vector<uint8_t> overlay_;
1284 std::unique_ptr<sizing_info_t> sizing_info_;
1285 uint64_t pagesize_ = 0;
1286 bool should_swap_ = false;
1287};
1288
1289}
1290
1291#endif
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:60
std::vector< Function > functions_t
Definition Abstract/Binary.hpp:83
@ ELF
Definition Abstract/Binary.hpp:77
@ OAT
Definition Abstract/Binary.hpp:80
FORMATS format() const
Executable format (ELF, PE, Mach-O) of the underlying binary.
Definition Abstract/Binary.hpp:125
std::vector< Symbol * > symbols_t
Internal container.
Definition Abstract/Binary.hpp:95
VA_TYPES
Enumeration of virtual address types used for patching and memory access.
Definition Abstract/Binary.hpp:63
@ AUTO
Automatically determine if the address is absolute or relative (default behavior).
Definition Abstract/Binary.hpp:66
std::vector< Section * > sections_t
Internal container.
Definition Abstract/Binary.hpp:86
std::vector< Relocation * > relocations_t
Internal container.
Definition Abstract/Binary.hpp:104
friend class ObjectFileLayout
Definition ELF/Binary.hpp:66
const_ref_iterator< std::vector< Symbol * > > it_const_symbols
Iterator which outputs static and dynamic const Symbol& object.
Definition ELF/Binary.hpp:189
~Binary() override
Segment * add(const Segment &segment, uint64_t base=0)
Add a new segment in the binary.
bool use_gnu_hash() const
true if GNU hash is used
Definition ELF/Binary.hpp:493
std::vector< std::unique_ptr< SymbolVersionRequirement > > symbols_version_requirement_t
Internal container for storing SymbolVersionRequirement.
Definition ELF/Binary.hpp:81
const DynamicEntry * get(DynamicEntry::TAG tag) const
Return the first ELF::DynamicEntry associated with the given tag If the tag can't be found,...
void remove(const Segment &seg, bool clear=false)
Remove the given segment. If clear is set, the original content of the segment will be filled with ze...
void write(std::ostream &os, const Builder::config_t &config)
Reconstruct the binary object with the given config and write it in os stream.
Header::CLASS type() const
Return binary's class (ELF32 or ELF64).
Definition ELF/Binary.hpp:270
std::vector< std::unique_ptr< Symbol > > symbols_t
Internal container for storing ELF's Symbol.
Definition ELF/Binary.hpp:169
const_ref_iterator< const sections_t &, const Section * > it_const_sections
Iterator which outputs const Section& object.
Definition ELF/Binary.hpp:210
bool should_swap() const
Definition ELF/Binary.hpp:1181
uint64_t layout_pagesize() const
result< uint64_t > virtual_address_to_offset(uint64_t virtual_address) const
Convert a virtual address to a file offset.
it_const_symbols symbols() const
Definition ELF/Binary.hpp:585
uint64_t last_offset_section() const
Return the last offset used in binary according to sections table.
SEC_INSERT_POS
This enum defines where the content of a newly added section should be inserted.
Definition ELF/Binary.hpp:248
@ AUTO
Defer the choice to LIEF.
Definition ELF/Binary.hpp:250
span< const uint8_t > get_content_from_virtual_address(uint64_t virtual_address, uint64_t size, Binary::VA_TYPES addr_type=Binary::VA_TYPES::AUTO) const override
Return the content located at virtual address.
PHDR_RELOC
Definition ELF/Binary.hpp:216
@ PIE_SHIFT
Definition ELF/Binary.hpp:227
@ AUTO
Definition ELF/Binary.hpp:220
@ BSS_END
Definition ELF/Binary.hpp:233
@ BINARY_END
Definition ELF/Binary.hpp:237
@ SEGMENT_GAP
Definition ELF/Binary.hpp:243
Header & header()
Return Elf header .
Definition ELF/Binary.hpp:275
friend class ExeLayout
Definition ELF/Binary.hpp:64
const Section * section_from_offset(uint64_t offset, bool skip_nobits=true) const
Return the ELF::Section from the given offset. Return a nullptr if a section can't be found.
it_dynamic_entries dynamic_entries()
Return binary's dynamic entries.
Definition ELF/Binary.hpp:318
Section * get_section(std::string_view name)
Return Section with the given name. If the section can't be found, it returns a nullptr.
Definition ELF/Binary.hpp:529
it_symbols_version_requirement symbols_version_requirement()
Return Symbol version requirement.
Definition ELF/Binary.hpp:407
void remove(Segment::TYPE type, bool clear=false)
Remove all segments associated with the given type.
size_t hash(const std::string &name)
it_pltgot_relocations pltgot_relocations()
Return plt.got relocations.
ref_iterator< notes_t &, Note * > it_notes
Iterator which outputs Note& object.
Definition ELF/Binary.hpp:75
filter_iterator< relocations_t &, Relocation * > it_object_relocations
Iterator which outputs Relocation& object found in object files (.o).
Definition ELF/Binary.hpp:155
void strip()
Strip the binary by removing symtab symbols.
Note & add(const Note &note)
Add the given note and return the created entry.
Symbol & export_symbol(const std::string &symbol_name, uint64_t value=0)
Export the symbol with the given name and create it if it doesn't exist.
void remove_symtab_symbol(Symbol *symbol)
Binary & operator+=(const DynamicEntry &entry)
Definition ELF/Binary.hpp:1110
void remove(const Note &note)
Remove the given note.
const Note * operator[](Note::TYPE type) const
Definition ELF/Binary.hpp:1169
std::vector< std::unique_ptr< Relocation > > relocations_t
Internal container for storing ELF's Relocation.
Definition ELF/Binary.hpp:136
void write(const std::string &filename, const Builder::config_t &config)
Reconstruct the binary object with the given config and write it in filename.
bool has_notes() const
true if the binary embeds notes
int64_t dynsym_idx(const std::string &name) const
Symbol index in the dynamic symbol table or -1 if the symbol does not exist.
Segment * segment_from_virtual_address(uint64_t address)
Definition ELF/Binary.hpp:893
const_ref_iterator< const symbols_t &, const Symbol * > it_const_symtab_symbols
Iterator which outputs the static/debug const Symbol& object.
Definition ELF/Binary.hpp:182
const Relocation * get_relocation(const Symbol &symbol) const
Return relocation associated with the given Symbol It returns a nullptr if it is not found.
void remove_dynamic_symbol(const std::string &name)
Remove dynamic symbols with the given name.
Binary & operator-=(const Note &note)
Definition ELF/Binary.hpp:1139
const Section * section_from_virtual_address(uint64_t address, bool skip_nobits=true) const
Return the ELF::Section from the given address. Return a nullptr if a section can't be found.
const Relocation * get_relocation(const std::string &symbol_name) const
Return relocation associated with the given Symbol name It returns a nullptr if it is not found.
ref_iterator< symbols_version_definition_t &, SymbolVersionDefinition * > it_symbols_version_definition
Iterator which outputs SymbolVersionDefinition& object.
Definition ELF/Binary.hpp:98
it_symtab_symbols symtab_symbols()
Return the debug symbols from the .symtab section.
Definition ELF/Binary.hpp:380
LIEF::Binary::functions_t ctor_functions() const override
List of binary constructors (typically, the functions located in the .init_array).
uint64_t imagebase() const override
Return program image base. For instance 0x40000.
LIEF::Binary::functions_t functions() const
List of the functions found in the binary.
bool has_library(const std::string &name) const
Check if the given library name exists in the current binary.
Definition ELF/Binary.hpp:715
int64_t dynsym_idx(const Symbol &sym) const
LIEF::Binary::functions_t dtor_functions() const
List of the binary destructors (typically, the functions located in the .fini_array).
std::vector< std::unique_ptr< SymbolVersion > > symbols_version_t
Internal container for storing ELF's SymbolVersion.
Definition ELF/Binary.hpp:126
Segment * operator[](Segment::TYPE type)
Definition ELF/Binary.hpp:1149
const Symbol * get_dynamic_symbol(const std::string &name) const
Get the dynamic symbol from the given name. Return a nullptr if it can't be found.
Relocation * get_relocation(uint64_t address)
Definition ELF/Binary.hpp:465
const Segment * segment_from_virtual_address(Segment::TYPE type, uint64_t address) const
DynamicEntryLibrary * get_library(const std::string &library_name)
Get the library object (DynamicEntryLibrary) from the given name If the library can't be found,...
Definition ELF/Binary.hpp:703
bool is_pie() const override
Check if the binary has been compiled with -fpie -pie flags.
Symbol * get_symtab_symbol(const std::string &name)
Definition ELF/Binary.hpp:623
it_symbols_version symbols_version()
Return the symbol versions.
Definition ELF/Binary.hpp:389
DynamicEntryLibrary & add_library(const std::string &library_name)
Add a library as dependency.
Section * text_section()
Return the .text section. If the section can't be found, it returns a nullptr.
Definition ELF/Binary.hpp:538
filter_iterator< std::vector< Symbol * > > it_exported_symbols
Iterator which outputs exported Symbol& object.
Definition ELF/Binary.hpp:192
it_object_relocations object_relocations()
Return relocations used in an object file (*.o).
it_imported_symbols imported_symbols()
Return symbols which are imported by the binary.
std::vector< std::unique_ptr< Segment > > segments_t
Internal container for storing ELF's Segment.
Definition ELF/Binary.hpp:107
it_sections sections()
Return an iterator over the binary's sections.
Definition ELF/Binary.hpp:295
it_const_notes notes() const
Return an iterator over the ELF's LIEF::ELF::Note.
Definition ELF/Binary.hpp:997
it_symbols_version_definition symbols_version_definition()
Return symbols version definition.
Definition ELF/Binary.hpp:397
const Symbol * get_symtab_symbol(const std::string &name) const
Get the symtab symbol from the given name Return a nullptr if it can't be found.
it_dynamic_relocations dynamic_relocations()
Return dynamic relocations.
void overlay(std::vector< uint8_t > overlay)
Function to set the overlay.
Definition ELF/Binary.hpp:1020
Note * get(Note::TYPE type)
Definition ELF/Binary.hpp:937
void remove_dynamic_symbol(Symbol *symbol)
Remove the given symbol from the dynamic symbols table.
const_ref_iterator< const symbols_t &, const Symbol * > it_const_dynamic_symbols
Iterator which outputs the Dynamic const Symbol& object.
Definition ELF/Binary.hpp:175
span< const uint8_t > overlay() const
Overlay data (if any).
Definition ELF/Binary.hpp:1015
const_ref_iterator< const symbols_version_definition_t &, const SymbolVersionDefinition * > it_const_symbols_version_definition
Iterator which outputs const SymbolVersionDefinition& object.
Definition ELF/Binary.hpp:102
bool has_overlay() const
True if data are present at the end of the binary.
Definition ELF/Binary.hpp:1010
const Section * get_section(std::string_view name) const
const_ref_iterator< const dynamic_entries_t &, const DynamicEntry * > it_const_dynamic_entries
Iterator which outputs const DynamicEntry& object.
Definition ELF/Binary.hpp:122
bool has(Section::TYPE type) const
Check if a ELF::Section associated with the given type exists.
Definition ELF/Binary.hpp:964
std::ostream & print(std::ostream &os) const override
Relocation * get_relocation(const std::string &symbol_name)
Definition ELF/Binary.hpp:484
Symbol & add_dynamic_symbol(const Symbol &symbol, const SymbolVersion *version=nullptr)
Add a dynamic symbol with the associated SymbolVersion.
ref_iterator< segments_t &, Segment * > it_segments
Iterator which outputs Segment& object.
Definition ELF/Binary.hpp:110
std::vector< std::unique_ptr< DynamicEntry > > dynamic_entries_t
Internal container for storing ELF's DynamicEntry.
Definition ELF/Binary.hpp:116
Symbol & add_symtab_symbol(const Symbol &symbol)
Add a symtab symbol.
Binary & operator+=(const Section &section)
Definition ELF/Binary.hpp:1114
void interpreter(const std::string &interpreter)
Change the interpreter.
Definition ELF/Binary.hpp:576
const_filter_iterator< std::vector< Symbol * > > it_const_imported_symbols
Iterator which outputs imported const Symbol& object.
Definition ELF/Binary.hpp:201
Binary(const Binary &copy)=delete
const_filter_iterator< const relocations_t &, const Relocation * > it_const_dynamic_relocations
Iterator which outputs dynamic const Relocation& object (not related to the PLT/GOT mechanism).
Definition ELF/Binary.hpp:151
int64_t symtab_idx(const Symbol &sym) const
const Segment * operator[](Segment::TYPE type) const
Definition ELF/Binary.hpp:1153
it_const_sections sections() const
Definition ELF/Binary.hpp:299
result< size_t > get_section_idx(const std::string &name) const
Find the index of the section with the name given in the first parameter.
Definition ELF/Binary.hpp:1054
Relocation * add_object_relocation(const Relocation &relocation, const Section &section)
Add relocation for object file (.o).
it_exported_symbols exported_symbols()
Return symbols which are exported by the binary.
const_ref_iterator< const relocations_t &, const Relocation * > it_const_relocations
Iterator which outputs const Relocation& object.
Definition ELF/Binary.hpp:165
const Header & header() const
Definition ELF/Binary.hpp:279
std::vector< std::string > string_list_t
Definition ELF/Binary.hpp:69
it_const_symtab_symbols symtab_symbols() const
Definition ELF/Binary.hpp:384
std::string_view interpreter() const
Return the ELF interpreter if any. (e.g. /lib64/ld-linux-x86-64.so.2) If the binary does not have an ...
Definition ELF/Binary.hpp:571
result< size_t > get_section_idx(const Section &section) const
Find the index of the section given in the first parameter.
Definition ELF/Binary.hpp:1042
Section * extend(const Section &section, uint64_t size)
std::vector< std::unique_ptr< Note > > notes_t
Internal container for storing notes.
Definition ELF/Binary.hpp:72
const Segment * get(Segment::TYPE type) const
Return the first ELF::Segment associated with the given type. If a segment can't be found,...
uint64_t entrypoint() const override
Return the binary's entrypoint.
Definition ELF/Binary.hpp:304
void write(const std::string &filename)
Reconstruct the binary object and write it in filename.
Definition ELF/Binary.hpp:789
friend class Builder
Definition ELF/Binary.hpp:63
bool has(Note::TYPE type) const
Check if a ELF::Note associated with the given type exists.
Definition ELF/Binary.hpp:959
Segment * segment_from_offset(uint64_t offset)
Definition ELF/Binary.hpp:914
bool has_symtab_symbol(const std::string &name) const
Check if the symbol with the given name exists in the symtab symbol table.
Definition ELF/Binary.hpp:614
bool has_dynamic_symbol(const std::string &name) const
Check if the symbol with the given name exists in the dynamic symbols table.
Definition ELF/Binary.hpp:598
DynamicEntry * operator[](DynamicEntry::TAG tag)
Definition ELF/Binary.hpp:1157
result< uint64_t > offset_to_virtual_address(uint64_t offset, uint64_t slide=0) const override
Convert the given offset into a virtual address.
ref_iterator< symbols_t &, Symbol * > it_symtab_symbols
Iterator which outputs the static/debug Symbol& object.
Definition ELF/Binary.hpp:179
const SymbolVersionRequirement * find_version_requirement(const std::string &libname) const
Try to find the SymbolVersionRequirement associated with the given library name (e....
it_const_symbols_version_definition symbols_version_definition() const
Definition ELF/Binary.hpp:402
const Section * get(Section::TYPE type) const
Return the first ELF::Section associated with the given type If a section can't be found,...
Section * hash_section()
Return the hash section. If the section can't be found, it returns a nullptr.
uint64_t next_virtual_address() const
Return the next virtual address available.
const Segment * segment_from_virtual_address(uint64_t address) const
Return the ELF::Segment from the given address. Return a nullptr if a segment can't be found.
Binary & operator-=(const DynamicEntry &entry)
Definition ELF/Binary.hpp:1129
uint64_t eof_offset() const
Return the last offset used by the ELF binary according to both: the sections table and the segments ...
void remove(DynamicEntry::TAG tag)
Remove all dynamic entries with the given tag.
uint64_t page_size() const override
Get the default memory page size according to the architecture and the format of the current binary.
it_segments segments()
Return binary's segments.
Definition ELF/Binary.hpp:309
void remove_library(const std::string &library_name)
Remove the given library from the dependencies.
result< uint64_t > get_function_address(const std::string &func_name, bool demangled) const
Return the address of the given function name.
it_dynamic_symbols dynamic_symbols()
Return an iterator over the binary's dynamic symbols The dynamic symbols are those located in the ....
Definition ELF/Binary.hpp:363
filter_iterator< std::vector< Symbol * > > it_imported_symbols
Iterator which outputs imported Symbol& object.
Definition ELF/Binary.hpp:198
const_filter_iterator< const relocations_t &, const Relocation * > it_const_object_relocations
Iterator which outputs const Relocation& object found in object files (.o).
Definition ELF/Binary.hpp:158
it_const_dynamic_entries dynamic_entries() const
Definition ELF/Binary.hpp:322
void remove_symtab_symbol(const std::string &name)
Remove symtab symbols with the given name.
Binary & operator-=(DynamicEntry::TAG tag)
Definition ELF/Binary.hpp:1134
it_relocations relocations()
Return all relocations present in the binary.
Definition ELF/Binary.hpp:454
Section * dynamic_section()
Return the .dynamic section. If the section can't be found, it returns a nullptr.
Segment * get(Segment::TYPE type)
Definition ELF/Binary.hpp:930
const DynamicEntryLibrary * get_library(const std::string &library_name) const
Get the library object (DynamicEntryLibrary) from the given name If the library can't be found,...
uint8_t ptr_size() const
Definition ELF/Binary.hpp:1086
const DynamicEntry * operator[](DynamicEntry::TAG tag) const
Definition ELF/Binary.hpp:1161
it_symbols symbols()
Return an iterator on both static and dynamic symbols.
Definition ELF/Binary.hpp:581
uint64_t relocate_phdr_table(PHDR_RELOC type)
Force relocating the segments table in a specific way.
std::vector< std::unique_ptr< Section > > sections_t
Internal container for storing ELF's Section.
Definition ELF/Binary.hpp:204
const_ref_iterator< const segments_t &, const Segment * > it_const_segments
Iterator which outputs const Segment& object.
Definition ELF/Binary.hpp:113
Segment * replace(const Segment &new_segment, const Segment &original_segment, uint64_t base=0)
Replace the segment given in 2nd parameter with the segment given in the first one and return the upd...
void remove(const Section &section, bool clear=false)
Remove the given section. The clear parameter can be used to zeroize the original content beforehand.
Symbol * get_dynamic_symbol(const std::string &name)
Definition ELF/Binary.hpp:607
Section * operator[](Section::TYPE type)
Definition ELF/Binary.hpp:1173
it_const_dynamic_symbols dynamic_symbols() const
Definition ELF/Binary.hpp:367
uint64_t virtual_size() const override
Return the size of the mapped binary.
bool has_section_with_offset(uint64_t offset) const
Check if a section that handles the given offset exists.
string_list_t strings(size_t min_size=5) const
Return list of the strings used by the ELF binary.
void remove_section(const std::string &name, bool clear=false) override
Remove a binary's section.
friend class Parser
Definition ELF/Binary.hpp:62
std::vector< uint8_t > raw()
Reconstruct the binary object and return its content as a byte vector.
const SysvHash * sysv_hash() const
Return the SysvHash object as a read-only object If the ELF binary does not use the legacy sysv hash ...
Definition ELF/Binary.hpp:512
SymbolVersionRequirement * find_version_requirement(const std::string &name)
Definition ELF/Binary.hpp:1072
bool has_section(const std::string &name) const
Check if a section with the given name exists in the binary.
Definition ELF/Binary.hpp:517
Relocation * get_relocation(const Symbol &symbol)
Definition ELF/Binary.hpp:474
Section * get(Section::TYPE type)
Definition ELF/Binary.hpp:944
static bool classof(const LIEF::Binary *bin)
Definition ELF/Binary.hpp:1099
it_const_relocations relocations() const
Definition ELF/Binary.hpp:458
Binary & operator-=(Note::TYPE type)
Definition ELF/Binary.hpp:1144
Symbol & add_exported_function(uint64_t address, const std::string &name="")
Create a symbol for the function at the given address and export it.
bool is_targeting_android() const
True if the current ELF is targeting Android.
it_const_segments segments() const
Definition ELF/Binary.hpp:313
DynamicEntry * get(DynamicEntry::TAG tag)
Definition ELF/Binary.hpp:923
Section * symtab_symbols_section()
Return section which holds the symtab symbols. If the section can't be found, it returns a nullptr.
uint64_t last_offset_segment() const
Return the last offset used in binary according to segments table.
bool use_sysv_hash() const
true if SYSV hash is used
Definition ELF/Binary.hpp:506
friend class Layout
Definition ELF/Binary.hpp:65
ref_iterator< sections_t &, Section * > it_sections
Iterator which outputs Section& object.
Definition ELF/Binary.hpp:207
void patch_pltgot(const Symbol &symbol, uint64_t address)
Patch the imported symbol with the address.
const_filter_iterator< const relocations_t &, const Relocation * > it_const_pltgot_relocations
Iterator which outputs plt/got const Relocation& object.
Definition ELF/Binary.hpp:142
filter_iterator< relocations_t &, Relocation * > it_dynamic_relocations
Iterator which outputs dynamic Relocation& object (not related to the PLT/GOT mechanism).
Definition ELF/Binary.hpp:147
ref_iterator< relocations_t &, Relocation * > it_relocations
Iterator which outputs Relocation& object.
Definition ELF/Binary.hpp:162
bool has_interpreter() const
Check if the binary uses a loader (also named linker or interpreter).
const Relocation * get_relocation(uint64_t address) const
Return relocation associated with the given address. It returns a nullptr if it is not found.
void remove_symbol(const std::string &name)
Remove symbols with the given name in both:
const Section * operator[](Section::TYPE type) const
Definition ELF/Binary.hpp:1177
const Segment * segment_from_offset(uint64_t offset) const
Return the ELF::Segment from the offset. Return a nullptr if a segment can't be found.
void remove(Note::TYPE type)
Remove all notes with the given type.
Relocation & add_dynamic_relocation(const Relocation &relocation)
Add a new dynamic relocation.
ref_iterator< symbols_t &, Symbol * > it_dynamic_symbols
Iterator which outputs the Dynamic Symbol& object.
Definition ELF/Binary.hpp:172
int64_t symtab_idx(const std::string &name) const
Symbol index from the .symtab section or -1 if the symbol is not present.
bool remove_version_requirement(const std::string &libname)
Deletes all required symbol versions linked to the specified library name. The function returns true ...
std::vector< uint64_t > get_relocated_dynamic_array(DynamicEntry::TAG tag) const
Return the array defined by the given tag (e.g. DynamicEntry::TAG::INIT_ARRAY) with relocations appli...
it_const_symbols_version_requirement symbols_version_requirement() const
Definition ELF/Binary.hpp:412
ref_iterator< std::vector< Symbol * > > it_symbols
Iterator which outputs static and dynamic Symbol& object.
Definition ELF/Binary.hpp:186
it_notes notes()
Definition ELF/Binary.hpp:1001
std::vector< std::unique_ptr< SymbolVersionDefinition > > symbols_version_definition_t
Internal container for storing SymbolVersionDefinition.
Definition ELF/Binary.hpp:94
ref_iterator< symbols_version_t &, SymbolVersion * > it_symbols_version
Iterator which outputs SymbolVersion& object.
Definition ELF/Binary.hpp:129
void patch_address(uint64_t address, const std::vector< uint8_t > &patch_value, LIEF::Binary::VA_TYPES addr_type=LIEF::Binary::VA_TYPES::AUTO) override
Patch the content at virtual address address with patch_value.
Note * operator[](Note::TYPE type)
Definition ELF/Binary.hpp:1165
const_filter_iterator< std::vector< Symbol * > > it_const_exported_symbols
Iterator which outputs exported const Symbol& object.
Definition ELF/Binary.hpp:195
Binary & operator+=(const Segment &segment)
Definition ELF/Binary.hpp:1119
Binary & operator=(const Binary &)=delete
filter_iterator< relocations_t &, Relocation * > it_pltgot_relocations
Iterator which outputs plt/got Relocation& object.
Definition ELF/Binary.hpp:139
Section * add(const Section &section, bool loaded=true, SEC_INSERT_POS pos=SEC_INSERT_POS::AUTO)
Add a new section in the binary.
Segment * segment_from_virtual_address(Segment::TYPE type, uint64_t address)
Definition ELF/Binary.hpp:903
void permute_dynamic_symbols(const std::vector< size_t > &permutation)
Apply the given permutation on the dynamic symbols table.
const_ref_iterator< const symbols_version_t &, const SymbolVersion * > it_const_symbols_version
Iterator which outputs const SymbolVersion& object.
Definition ELF/Binary.hpp:132
bool has_section_with_va(uint64_t va) const
Check if a section that handles the given virtual address exists.
const_ref_iterator< const notes_t &, const Note * > it_const_notes
Iterator which outputs const Note& object.
Definition ELF/Binary.hpp:78
void accept(LIEF::Visitor &visitor) const override
Method associated with the visitor pattern.
const Note * get(Note::TYPE type) const
Return the first ELF::Note associated with the given type If a note can't be found,...
ref_iterator< dynamic_entries_t &, DynamicEntry * > it_dynamic_entries
Iterator which outputs DynamicEntry& object.
Definition ELF/Binary.hpp:119
Symbol & export_symbol(const Symbol &symbol)
Export the given symbol and create it if it doesn't exist.
it_const_symbols_version symbols_version() const
Definition ELF/Binary.hpp:392
Relocation & add_pltgot_relocation(const Relocation &relocation)
Add a .plt.got relocation. This kind of relocation is usually associated with a PLT stub that aims at...
Binary & operator+=(const Note &note)
Definition ELF/Binary.hpp:1124
result< uint64_t > get_function_address(const std::string &func_name) const override
Return the address of the given function name.
const GnuHash * gnu_hash() const
Return the GnuHash object in readonly If the ELF binary does not use the GNU hash table,...
Definition ELF/Binary.hpp:499
void write(std::ostream &os)
Reconstruct the binary object and write it in os stream.
Definition ELF/Binary.hpp:809
ref_iterator< symbols_version_requirement_t &, SymbolVersionRequirement * > it_symbols_version_requirement
Iterator which outputs SymbolVersionRequirement& object.
Definition ELF/Binary.hpp:85
bool has_nx() const override
Check if the binary uses the NX protection (Non executable stack).
const_ref_iterator< const symbols_version_requirement_t &, const SymbolVersionRequirement * > it_const_symbols_version_requirement
Iterator which outputs const SymbolVersionRequirement& object.
Definition ELF/Binary.hpp:89
void remove(const DynamicEntry &entry)
Remove the given dynamic entry.
DynamicEntry & add(const DynamicEntry &entry)
Add the given dynamic entry and return the new entry.
bool has(Segment::TYPE type) const
Check if ELF::Segment associated with the given type exists.
Definition ELF/Binary.hpp:954
bool has(DynamicEntry::TAG tag) const
Check if an ELF::DynamicEntry associated with the given tag exists.
Definition ELF/Binary.hpp:949
Class which represents a DT_NEEDED entry in the dynamic table.
Definition DynamicEntryLibrary.hpp:32
Class which represents an entry in the dynamic table These entries are located in the ....
Definition DynamicEntry.hpp:37
TAG
Definition DynamicEntry.hpp:49
@ HASH
Definition DynamicEntry.hpp:55
@ GNU_HASH
Definition DynamicEntry.hpp:90
Class which provides a view over the GNU Hash implementation. Most of the fields are read-only since ...
Definition GnuHash.hpp:40
Class which represents the ELF's header. This class mirrors the raw ELF Elfxx_Ehdr structure.
Definition ELF/Header.hpp:35
CLASS
Match the result of Elfxx_Ehdr.e_ident[EI_CLASS].
Definition ELF/Header.hpp:74
@ ELF64
64-bit objects
Definition ELF/Header.hpp:77
@ ELF32
32-bit objects
Definition ELF/Header.hpp:76
Class which represents an ELF note. This class can be instantiated using the static Note::create func...
Definition Note.hpp:41
TYPE
LIEF representation of the ELF NT_ values.
Definition Note.hpp:51
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
Class that represents an ELF relocation.
Definition ELF/Relocation.hpp:40
Class which represents an ELF Section.
Definition ELF/Section.hpp:49
TYPE
Definition ELF/Section.hpp:64
Class which represents the ELF segments.
Definition Segment.hpp:49
TYPE
Definition Segment.hpp:74
Class which represents an entry defined in DT_VERDEF or .gnu.version_d.
Definition SymbolVersionDefinition.hpp:38
Class which represents an entry in the DT_VERNEED or .gnu.version_r table.
Definition SymbolVersionRequirement.hpp:41
Class which represents an entry defined in the DT_VERSYM dynamic entry.
Definition SymbolVersion.hpp:33
Class which represents an ELF symbol.
Definition ELF/Symbol.hpp:34
Class which represents the SYSV hash for the symbols resolution.
Definition SysvHash.hpp:39
static Header from(const LIEF::ELF::Binary &elf)
Definition Visitor.hpp:212
Iterator which returns a ref on container's values given predicates.
Definition iterators.hpp:323
Iterator which returns reference on container's values.
Definition iterators.hpp:47
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:79
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
@ not_found
Definition errors.hpp:26
tl::unexpected< lief_errors > make_error_code(lief_errors e)
Create a standard error code from lief_errors.
Definition errors.hpp:55
Definition ELF/Binary.hpp:40
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:41
filter_iterator< CT, U, typename decay_t< CT >::const_iterator > const_filter_iterator
Iterator which returns a const ref on container's values given predicates.
Definition iterators.hpp:583
tcb::span< ElementType, Extent > span
Definition span.hpp:22
lief_version_t version()
Return the current version.
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which returns a const ref on container's values.
Definition iterators.hpp:316
Configuration options to tweak the building process.
Definition ELF/Builder.hpp:55
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46