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 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_ELF_BINARY_H
16#define LIEF_ELF_BINARY_H
17
18#include <string_view>
19#include <memory>
20#include <utility>
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
44namespace details {
45class PhdrTableSections;
46}
47
48class ExeLayout;
49class GnuHash;
50class Layout;
51class ObjectFileLayout;
52class Parser;
53class Relocation;
54class Section;
55class Segment;
56class Symbol;
57class SymbolVersion;
61class SysvHash;
62struct sizing_info_t;
63
66 friend class Parser;
67 friend class Builder;
68 friend class ExeLayout;
69 friend class Layout;
70 friend class ObjectFileLayout;
71
72 public:
73 using string_list_t = std::vector<std::string>;
74
76 using notes_t = std::vector<std::unique_ptr<Note>>;
77
80
83
86 std::vector<std::unique_ptr<SymbolVersionRequirement>>;
87
91
96
99 std::vector<std::unique_ptr<SymbolVersionDefinition>>;
100
104
109
111 using segments_t = std::vector<std::unique_ptr<Segment>>;
112
115
118
120 using dynamic_entries_t = std::vector<std::unique_ptr<DynamicEntry>>;
121
124
128
130 using symbols_version_t = std::vector<std::unique_ptr<SymbolVersion>>;
131
134
138
140 using relocations_t = std::vector<std::unique_ptr<Relocation>>;
141
144
148
152
157
160
164
167
171
173 using symbols_t = std::vector<std::unique_ptr<Symbol>>;
174
177
181
184
188
191
194
197
200
203
206
208 using sections_t = std::vector<std::unique_ptr<Section>>;
209
212
215
216 public:
277
280 enum class SEC_INSERT_POS {
282 AUTO = 0,
283
289 POST_SEGMENT,
290
294 POST_SECTION,
295 };
296
297 public:
298 Binary& operator=(const Binary&) = delete;
299 Binary(const Binary& copy) = delete;
300
303 return type_;
304 }
305
308 return header_;
309 }
310
312 return header_;
313 }
314
317 uint64_t last_offset_section() const;
318
321 uint64_t last_offset_segment() const;
322
324 uint64_t next_virtual_address() const;
325
328 return sections_;
329 }
330
332 return sections_;
333 }
334
336 uint64_t entrypoint() const override {
337 return header_.entrypoint();
338 }
339
342 return segments_;
343 }
344
346 return segments_;
347 }
348
351 return dynamic_entries_;
352 }
353
355 return dynamic_entries_;
356 }
357
360
363
365 void remove(const DynamicEntry& entry);
366
369
375 void remove(const Section& section, bool clear = false);
376
378 void remove(const Note& note);
379
382
385 void remove(const Segment& seg, bool clear = false);
386
391 void remove(Segment::TYPE type, bool clear = false);
392
396 return dynamic_symbols_;
397 }
398
400 return dynamic_symbols_;
401 }
402
406
410
413 return symtab_symbols_;
414 }
415
417 return symtab_symbols_;
418 }
419
422 return symbol_version_table_;
423 }
424
426 return symbol_version_table_;
427 }
428
431 return symbol_version_definition_;
432 }
433
434 it_const_symbols_version_definition
436 return symbol_version_definition_;
437 }
438
441 return symbol_version_requirements_;
442 }
443
444 it_const_symbols_version_requirement
446 return symbol_version_requirements_;
447 }
448
454 std::pair<uint32_t, uint32_t> required_glibc_version() const;
455
459
467
474
483 const Section& section) LIEF_LIFETIMEBOUND;
484
488
492
495 return relocations_;
496 }
497
499 return relocations_;
500 }
501
504 const Relocation* get_relocation(uint64_t address) const LIEF_LIFETIMEBOUND;
506 return const_cast<Relocation*>(
507 static_cast<const Binary*>(this)->get_relocation(address)
508 );
509 }
510
515 return const_cast<Relocation*>(
516 static_cast<const Binary*>(this)->get_relocation(symbol)
517 );
518 }
519
522 const Relocation*
523 get_relocation(std::string_view symbol_name) const LIEF_LIFETIMEBOUND;
524 Relocation* get_relocation(std::string_view symbol_name) LIEF_LIFETIMEBOUND {
525 return const_cast<Relocation*>(
526 static_cast<const Binary*>(this)->get_relocation(symbol_name)
527 );
528 }
529
533 bool use_gnu_hash() const {
534 return gnu_hash_ != nullptr && has(DynamicEntry::TAG::GNU_HASH);
535 }
536
540 return use_gnu_hash() ? gnu_hash_.get() : nullptr;
541 }
542
546 bool use_sysv_hash() const {
547 return sysv_hash_ != nullptr && has(DynamicEntry::TAG::HASH);
548 }
549
553 return use_sysv_hash() ? sysv_hash_.get() : nullptr;
554 }
555
557 bool has_section(std::string_view name) const {
558 return get_section(name) != nullptr;
559 }
560
562 bool has_section_with_offset(uint64_t offset) const;
563
565 bool has_section_with_va(uint64_t va) const;
566
569 Section* get_section(std::string_view name) LIEF_LIFETIMEBOUND {
570 return const_cast<Section*>(
571 static_cast<const Binary*>(this)->get_section(name)
572 );
573 }
574 const Section* get_section(std::string_view name) const LIEF_LIFETIMEBOUND;
575
579 return get_section(".text");
580 }
581
585
589
593
598 uint64_t imagebase() const override;
599
601 uint64_t virtual_size() const override;
602
605 bool has_interpreter() const;
606
611 std::string_view interpreter() const LIEF_LIFETIMEBOUND {
612 return interpreter_;
613 }
614
616 void interpreter(std::string_view interpreter) {
617 interpreter_ = interpreter;
618 }
619
622 return symtab_dyn_symbols();
623 }
624
626 return symtab_dyn_symbols();
627 }
628
631
633 Symbol& export_symbol(std::string_view symbol_name,
634 uint64_t value = 0) LIEF_LIFETIMEBOUND;
635
638 bool has_dynamic_symbol(std::string_view name) const {
639 return get_dynamic_symbol(name) != nullptr;
640 }
641
644 const Symbol* get_dynamic_symbol(std::string_view name) const LIEF_LIFETIMEBOUND;
645
647 return const_cast<Symbol*>(
648 static_cast<const Binary*>(this)->get_dynamic_symbol(name)
649 );
650 }
651
653 bool has_symtab_symbol(std::string_view name) const {
654 return get_symtab_symbol(name) != nullptr;
655 }
656
659 const Symbol* get_symtab_symbol(std::string_view name) const LIEF_LIFETIMEBOUND;
660
662 return const_cast<Symbol*>(
663 static_cast<const Binary*>(this)->get_symtab_symbol(name)
664 );
665 }
666
670 string_list_t strings(size_t min_size = 5) const;
671
677 void remove_symbol(std::string_view name);
678
680 void remove_symtab_symbol(std::string_view name);
682
684 void remove_dynamic_symbol(std::string_view name);
685
692
694 result<uint64_t> get_function_address(std::string_view func_name) const override;
695
697 //
700 result<uint64_t> get_function_address(std::string_view func_name,
701 bool demangled) const;
702
714 Section* add(const Section& section, bool loaded = true,
716
717 Section* extend(const Section& section, uint64_t size) LIEF_LIFETIMEBOUND;
718
721
724 nullptr) LIEF_LIFETIMEBOUND;
725
727 Symbol& add_exported_function(uint64_t address,
728 std::string_view name = "") LIEF_LIFETIMEBOUND;
729
732 add_library(std::string_view library_name) LIEF_LIFETIMEBOUND;
733
735 void remove_library(std::string_view library_name);
736
740 get_library(std::string_view library_name) LIEF_LIFETIMEBOUND {
741 return const_cast<DynamicEntryLibrary*>(
742 static_cast<const Binary*>(this)->get_library(library_name)
743 );
744 }
745
749 get_library(std::string_view library_name) const LIEF_LIFETIMEBOUND;
750
752 bool has_library(std::string_view name) const {
753 return get_library(name) != nullptr;
754 }
755
763 Segment* add(const Segment& segment, uint64_t base = 0) LIEF_LIFETIMEBOUND;
764
769 Segment* replace(const Segment& new_segment, const Segment& original_segment,
770 uint64_t base = 0) LIEF_LIFETIMEBOUND;
771
772 Segment* extend(const Segment& segment, uint64_t size) LIEF_LIFETIMEBOUND;
773
774
781 void patch_address(uint64_t address, const std::vector<uint8_t>& patch_value,
782 LIEF::Binary::VA_TYPES addr_type =
783 LIEF::Binary::VA_TYPES::AUTO) override;
784
785
794 uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t),
795 LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO
796 ) override;
797
802 void patch_pltgot(const Symbol& symbol, uint64_t address);
803
804
809 void patch_pltgot(std::string_view symbol_name, uint64_t address);
810
812 void strip();
813
818 void remove_section(std::string_view name, bool clear = false) override;
819
826 void write(const std::string& filename) {
827 return write(filename, Builder::config_t{});
828 }
829
838 void write(const std::string& filename, const Builder::config_t& config);
839
846 void write(std::ostream& os) {
847 return write(os, Builder::config_t{});
848 }
849
855 void write(std::ostream& os, const Builder::config_t& config);
856
858 std::vector<uint8_t> raw();
859
861 result<uint64_t> virtual_address_to_offset(uint64_t virtual_address) const;
862
869 uint64_t slide = 0) const override;
870
875 bool is_pie() const override;
876
878 bool has_nx() const override;
879
882 int64_t dynsym_idx(std::string_view name) const;
883
884 int64_t dynsym_idx(const Symbol& sym) const;
885
887 int64_t symtab_idx(std::string_view name) const;
888
889 int64_t symtab_idx(const Symbol& sym) const;
890
897 const Section*
898 section_from_offset(uint64_t offset,
899 bool skip_nobits = true) const LIEF_LIFETIMEBOUND;
900 Section* section_from_offset(uint64_t offset,
901 bool skip_nobits = true) LIEF_LIFETIMEBOUND {
902 return const_cast<Section*>(
903 static_cast<const Binary*>(this)->section_from_offset(offset, skip_nobits)
904 );
905 }
906
913 uint64_t address, bool skip_nobits = true
914 ) const LIEF_LIFETIMEBOUND;
915
916 Section*
918 bool skip_nobits = true) LIEF_LIFETIMEBOUND {
919 return const_cast<Section*>(
920 static_cast<const Binary*>(this)->section_from_virtual_address(address,
921 skip_nobits)
922 );
923 }
924
927 const Segment*
929
931 return const_cast<Segment*>(
932 static_cast<const Binary*>(this)->segment_from_virtual_address(address)
933 );
934 }
935
936
937 const Segment*
939 uint64_t address) const LIEF_LIFETIMEBOUND;
941 uint64_t address) LIEF_LIFETIMEBOUND {
942 return const_cast<Segment*>(
943 static_cast<const Binary*>(this)->segment_from_virtual_address(type,
944 address)
945 );
946 }
947
950 const Segment* segment_from_offset(uint64_t offset) const LIEF_LIFETIMEBOUND;
951
953 return const_cast<Segment*>(
954 static_cast<const Binary*>(this)->segment_from_offset(offset)
955 );
956 }
957
959 uint64_t offset) const LIEF_LIFETIMEBOUND;
960
962 uint64_t offset) LIEF_LIFETIMEBOUND {
963 return const_cast<Segment*>(
964 static_cast<const Binary*>(this)->segment_from_offset(type, offset)
965 );
966 }
967
968
973 return const_cast<DynamicEntry*>(static_cast<const Binary*>(this)->get(tag));
974 }
975
980 return const_cast<Segment*>(static_cast<const Binary*>(this)->get(type));
981 }
982
987 return const_cast<Note*>(static_cast<const Binary*>(this)->get(type));
988 }
989
994 return const_cast<Section*>(static_cast<const Binary*>(this)->get(type));
995 }
996
998 bool has(DynamicEntry::TAG tag) const {
999 return get(tag) != nullptr;
1000 }
1001
1003 bool has(Segment::TYPE type) const {
1004 return get(type) != nullptr;
1005 }
1006
1008 bool has(Note::TYPE type) const {
1009 return get(type) != nullptr;
1010 }
1011
1013 bool has(Section::TYPE type) const {
1014 return get(type) != nullptr;
1015 }
1016
1019 uint64_t virtual_address, uint64_t size,
1021 ) const LIEF_LIFETIMEBOUND override;
1022
1024 void accept(LIEF::Visitor& visitor) const override;
1025
1027 void permute_dynamic_symbols(const std::vector<size_t>& permutation);
1028
1032
1036
1039
1041 bool has_notes() const;
1042
1047 return notes_;
1048 }
1049
1051 return notes_;
1052 }
1053
1056 uint64_t eof_offset() const;
1057
1059 bool has_overlay() const {
1060 return !overlay_.empty();
1061 }
1062
1065 return overlay_;
1066 }
1067
1069 void overlay(std::vector<uint8_t> overlay) {
1070 overlay_ = std::move(overlay);
1071 }
1072
1082
1085 std::vector<uint64_t> get_relocated_dynamic_array(DynamicEntry::TAG tag) const;
1086
1089
1092 auto it = std::find_if(sections_.begin(), sections_.end(),
1093 [&section](const std::unique_ptr<Section>& S) {
1094 return S.get() == &section;
1095 });
1096 if (it == sections_.end()) {
1098 }
1099 return std::distance(sections_.begin(), it);
1100 }
1101
1103 result<size_t> get_section_idx(std::string_view name) const {
1104 auto it = std::find_if(sections_.begin(), sections_.end(),
1105 [name](const std::unique_ptr<Section>& S) {
1106 return S->name() == name;
1107 });
1108 if (it == sections_.end()) {
1110 }
1111 return std::distance(sections_.begin(), it);
1112 }
1113
1117 find_version_requirement(std::string_view libname) const LIEF_LIFETIMEBOUND;
1118
1121 return const_cast<SymbolVersionRequirement*>(
1122 static_cast<const Binary*>(this)->find_version_requirement(name)
1123 );
1124 }
1125
1132 bool remove_version_requirement(std::string_view libname);
1133
1134 // Check if the given range is owned by a section or the section headers table
1135 bool contains_sections(uint64_t start, uint64_t end) const;
1136
1137 uint8_t ptr_size() const {
1138 switch (type()) {
1139 case Header::CLASS::ELF32: return sizeof(uint32_t);
1140 case Header::CLASS::ELF64: return sizeof(uint64_t);
1141 default: return 0;
1142 }
1143 return 0;
1144 }
1145
1146 uint64_t page_size() const override;
1147
1148 uint64_t layout_pagesize() const;
1149
1151 bool is_symbolic() const;
1152
1153 static bool classof(const LIEF::Binary* bin) {
1154 return bin->format() == Binary::FORMATS::ELF ||
1155 bin->format() == Binary::FORMATS::OAT;
1156 }
1157
1158 size_t hash(std::string_view name);
1159
1160 ~Binary() override;
1161
1162 std::ostream& print(std::ostream& os) const override;
1163
1165 add(entry);
1166 return *this;
1167 }
1168
1170 add(section);
1171 return *this;
1172 }
1173
1175 add(segment);
1176 return *this;
1177 }
1178
1180 add(note);
1181 return *this;
1182 }
1183
1185 remove(entry);
1186 return *this;
1187 }
1188
1190 remove(tag);
1191 return *this;
1192 }
1193
1195 remove(note);
1196 return *this;
1197 }
1198
1200 remove(type);
1201 return *this;
1202 }
1203
1207
1209 return get(type);
1210 }
1211
1215
1217 return get(tag);
1218 }
1219
1223
1225 return get(type);
1226 }
1227
1231
1233 return get(type);
1234 }
1235
1236 bool should_swap() const {
1237 return should_swap_;
1238 }
1239
1240 protected:
1241 friend class details::PhdrTableSections;
1242
1243 struct phdr_relocation_info_t {
1244 uint64_t new_offset = 0;
1245 size_t nb_segments = 0;
1246 void clear() {
1247 new_offset = 0;
1248 nb_segments = 0;
1249 }
1250 };
1251 uint64_t entry_size(DynamicEntry::TAG ent_tag, uint64_t fallback) const {
1252 if (const DynamicEntry* dt_ent = get(ent_tag)) {
1253 return dt_ent->value();
1254 }
1255 return fallback;
1256 }
1257
1258 LIEF_LOCAL Binary();
1259
1261 LIEF_LOCAL LIEF::Binary::sections_t get_abstract_sections() override;
1262
1263 LIEF_LOCAL LIEF::Header get_abstract_header() const override {
1264 return LIEF::Header::from(*this);
1265 }
1266
1268 get_abstract_exported_functions() const override;
1270 get_abstract_imported_functions() const override;
1271 LIEF_LOCAL std::vector<std::string>
1272 get_abstract_imported_libraries() const override;
1273 LIEF_LOCAL LIEF::Binary::symbols_t get_abstract_symbols() override;
1274 LIEF_LOCAL LIEF::Binary::relocations_t get_abstract_relocations() override;
1275
1276 template<ELF::ARCH ARCH>
1277 LIEF_LOCAL void patch_relocations(uint64_t from, uint64_t shift);
1278
1279 template<class T>
1280 LIEF_LOCAL void patch_addend(Relocation& relocatio, uint64_t from,
1281 uint64_t shift);
1282
1283 LIEF_LOCAL void shift_sections(uint64_t from, uint64_t shift,
1284 bool shift_address = true);
1285 LIEF_LOCAL void shift_segments(uint64_t from, uint64_t shift);
1286 LIEF_LOCAL void shift_dynamic_entries(uint64_t from, uint64_t shift);
1287 LIEF_LOCAL void shift_symbols(uint64_t from, uint64_t shift);
1288 LIEF_LOCAL void shift_relocations(uint64_t from, uint64_t shift);
1289 LIEF_LOCAL void shift_section_indices(size_t idx, bool removed);
1290 LIEF_LOCAL void unlink(const Section& section);
1291
1292 template<class ELF_T>
1293 LIEF_LOCAL void fix_got_entries(uint64_t from, uint64_t shift);
1294
1295 LIEF_LOCAL LIEF::Binary::functions_t eh_frame_functions() const;
1296 LIEF_LOCAL LIEF::Binary::functions_t armexid_functions() const;
1297
1298 template<Header::FILE_TYPE OBJECT_TYPE, bool note = false>
1299 LIEF_LOCAL Segment* add_segment(const Segment& segment,
1300 uint64_t base) LIEF_LIFETIMEBOUND;
1301
1302 LIEF_LOCAL uint64_t relocate_phdr_table_auto(size_t required_segments = 1);
1303 LIEF_LOCAL uint64_t reuse_phdr_table();
1304 LIEF_LOCAL uint64_t reuse_phdr_table_backward();
1305 LIEF_LOCAL uint64_t relocate_phdr_table_pie();
1306 LIEF_LOCAL uint64_t relocate_phdr_table_backward(size_t required_segments = 1);
1307 LIEF_LOCAL uint64_t relocate_phdr_table_sections(size_t required_segments = 1);
1308 LIEF_LOCAL uint64_t relocate_phdr_table_v1();
1309 LIEF_LOCAL uint64_t relocate_phdr_table_v2();
1310 LIEF_LOCAL uint64_t relocate_phdr_table_v3();
1311
1312 template<Segment::TYPE PT>
1313 LIEF_LOCAL Segment* extend_segment(const Segment& segment,
1314 uint64_t size) LIEF_LIFETIMEBOUND;
1315
1316 template<bool LOADED>
1317 LIEF_LOCAL Section* add_section(const Section& section,
1318 SEC_INSERT_POS pos) LIEF_LIFETIMEBOUND;
1319
1320 std::vector<Symbol*> symtab_dyn_symbols() const LIEF_LIFETIMEBOUND;
1321
1322 LIEF_LOCAL std::string_view shstrtab_name() const;
1323 LIEF_LOCAL Section* add_frame_section(const Section& sec) LIEF_LIFETIMEBOUND;
1324 LIEF_LOCAL Section* add_section(std::unique_ptr<Section> sec) LIEF_LIFETIMEBOUND;
1325
1326 LIEF_LOCAL LIEF::Binary::functions_t tor_functions(DynamicEntry::TAG tag) const;
1327 LIEF_LOCAL Symbol&
1328 set_export_attributes(Symbol& symbol LIEF_LIFETIMEBOUND) const;
1329
1330 Header::CLASS type_ = Header::CLASS::NONE;
1331 Header header_;
1332 sections_t sections_;
1333 segments_t segments_;
1334 dynamic_entries_t dynamic_entries_;
1335 symbols_t dynamic_symbols_;
1336 symbols_t symtab_symbols_;
1337 relocations_t relocations_;
1338 symbols_version_t symbol_version_table_;
1339 symbols_version_requirement_t symbol_version_requirements_;
1340 symbols_version_definition_t symbol_version_definition_;
1341 notes_t notes_;
1342 std::unique_ptr<GnuHash> gnu_hash_;
1343 std::unique_ptr<SysvHash> sysv_hash_;
1344 std::unique_ptr<DataHandler::Handler> datahandler_;
1345 phdr_relocation_info_t phdr_reloc_info_;
1346
1347 std::string interpreter_;
1348 std::vector<uint8_t> overlay_;
1349 std::unique_ptr<sizing_info_t> sizing_info_;
1350 uint64_t pagesize_ = 0;
1351 bool should_swap_ = false;
1352};
1353
1354}
1355
1356#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:70
const_ref_iterator< std::vector< Symbol * > > it_const_symbols
Iterator which outputs static and dynamic const Symbol& object.
Definition ELF/Binary.hpp:193
~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:533
bool has_library(std::string_view name) const
Check if the given library name exists in the current binary.
Definition ELF/Binary.hpp:752
std::vector< std::unique_ptr< SymbolVersionRequirement > > symbols_version_requirement_t
Internal container for storing SymbolVersionRequirement.
Definition ELF/Binary.hpp:85
const DynamicEntry * get(DynamicEntry::TAG tag) const
Return the first ELF::DynamicEntry associated with the given tag If the tag can't be found,...
result< uint64_t > get_function_address(std::string_view func_name) const override
Return the address of the given function name.
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 remove_library(std::string_view library_name)
Remove the given library from the dependencies.
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:302
std::vector< std::unique_ptr< Symbol > > symbols_t
Internal container for storing ELF's Symbol.
Definition ELF/Binary.hpp:173
const_ref_iterator< const sections_t &, const Section * > it_const_sections
Iterator which outputs const Section& object.
Definition ELF/Binary.hpp:214
bool should_swap() const
Definition ELF/Binary.hpp:1236
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:625
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:280
@ AUTO
Defer the choice to LIEF.
Definition ELF/Binary.hpp:282
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.
Symbol & export_symbol(std::string_view symbol_name, uint64_t value=0)
Export the symbol with the given name and create it if it doesn't exist.
PHDR_RELOC
Definition ELF/Binary.hpp:220
@ EXEC_BACKWARD
Definition ELF/Binary.hpp:264
@ PIE_SHIFT
Definition ELF/Binary.hpp:231
@ SECTIONS_SHIFT
Definition ELF/Binary.hpp:275
@ AUTO
Definition ELF/Binary.hpp:224
@ BSS_END
Definition ELF/Binary.hpp:237
@ BINARY_END
Definition ELF/Binary.hpp:241
@ SEGMENT_GAP
Definition ELF/Binary.hpp:247
Header & header()
Return Elf header .
Definition ELF/Binary.hpp:307
friend class ExeLayout
Definition ELF/Binary.hpp:68
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:350
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:569
it_symbols_version_requirement symbols_version_requirement()
Return Symbol version requirement.
Definition ELF/Binary.hpp:440
bool has_section(std::string_view name) const
Check if a section with the given name exists in the binary.
Definition ELF/Binary.hpp:557
void remove(Segment::TYPE type, bool clear=false)
Remove all segments associated with the given type.
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:79
filter_iterator< relocations_t &, Relocation * > it_object_relocations
Iterator which outputs Relocation& object found in object files (.o).
Definition ELF/Binary.hpp:159
void strip()
Strip the binary by removing symtab symbols.
Note & add(const Note &note)
Add the given note and return the created entry.
void remove_symtab_symbol(Symbol *symbol)
Binary & operator+=(const DynamicEntry &entry)
Definition ELF/Binary.hpp:1164
void remove(const Note &note)
Remove the given note.
const Note * operator[](Note::TYPE type) const
Definition ELF/Binary.hpp:1224
std::vector< std::unique_ptr< Relocation > > relocations_t
Internal container for storing ELF's Relocation.
Definition ELF/Binary.hpp:140
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
Segment * segment_from_virtual_address(uint64_t address)
Definition ELF/Binary.hpp:930
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:186
const Relocation * get_relocation(const Symbol &symbol) const
Return relocation associated with the given Symbol It returns a nullptr if it is not found.
Binary & operator-=(const Note &note)
Definition ELF/Binary.hpp:1194
const DynamicEntryLibrary * get_library(std::string_view library_name) const
Get the library object (DynamicEntryLibrary) from the given name If the library can't be found,...
void remove_dynamic_symbol(std::string_view name)
Remove dynamic symbols with the given name.
Symbol * get_symtab_symbol(std::string_view name)
Definition ELF/Binary.hpp:661
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.
ref_iterator< symbols_version_definition_t &, SymbolVersionDefinition * > it_symbols_version_definition
Iterator which outputs SymbolVersionDefinition& object.
Definition ELF/Binary.hpp:102
it_symtab_symbols symtab_symbols()
Return the debug symbols from the .symtab section.
Definition ELF/Binary.hpp:412
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.
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:130
Segment * operator[](Segment::TYPE type)
Definition ELF/Binary.hpp:1204
Relocation * get_relocation(uint64_t address)
Definition ELF/Binary.hpp:505
bool has_dynamic_symbol(std::string_view name) const
Check if the symbol with the given name exists in the dynamic symbols table.
Definition ELF/Binary.hpp:638
const Segment * segment_from_virtual_address(Segment::TYPE type, uint64_t address) const
bool is_pie() const override
Check if the binary has been compiled with -fpie -pie flags.
it_symbols_version symbols_version()
Return the symbol versions.
Definition ELF/Binary.hpp:421
Section * text_section()
Return the .text section. If the section can't be found, it returns a nullptr.
Definition ELF/Binary.hpp:578
filter_iterator< std::vector< Symbol * > > it_exported_symbols
Iterator which outputs exported Symbol& object.
Definition ELF/Binary.hpp:196
it_object_relocations object_relocations()
Return relocations used in an object file (*.o).
bool is_symbolic() const
Check if the binary is flagged with DT_SYMBOLIC or DF_SYMBOLIC.
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:111
it_sections sections()
Return an iterator over the binary's sections.
Definition ELF/Binary.hpp:327
it_const_notes notes() const
Return an iterator over the ELF's LIEF::ELF::Note.
Definition ELF/Binary.hpp:1046
const Symbol * get_symtab_symbol(std::string_view name) const
Get the symtab symbol from the given name Return a nullptr if it can't be found.
it_symbols_version_definition symbols_version_definition()
Return symbols version definition.
Definition ELF/Binary.hpp:430
Segment * segment_from_offset(Segment::TYPE type, uint64_t offset)
Definition ELF/Binary.hpp:961
bool has_symtab_symbol(std::string_view name) const
Check if the symbol with the given name exists in the symtab symbol table.
Definition ELF/Binary.hpp:653
it_dynamic_relocations dynamic_relocations()
Return dynamic relocations.
void overlay(std::vector< uint8_t > overlay)
Function to set the overlay.
Definition ELF/Binary.hpp:1069
Note * get(Note::TYPE type)
Definition ELF/Binary.hpp:986
DynamicEntryLibrary & add_library(std::string_view library_name)
Add a library as dependency.
result< size_t > get_section_idx(std::string_view name) const
Find the index of the section with the name given in the first parameter.
Definition ELF/Binary.hpp:1103
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:179
span< const uint8_t > overlay() const
Overlay data (if any).
Definition ELF/Binary.hpp:1064
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:106
bool has_overlay() const
True if data are present at the end of the binary.
Definition ELF/Binary.hpp:1059
std::pair< uint32_t, uint32_t > required_glibc_version() const
Highest glibc version (major, minor) required by this binary.
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:126
bool has(Section::TYPE type) const
Check if a ELF::Section associated with the given type exists.
Definition ELF/Binary.hpp:1013
std::ostream & print(std::ostream &os) const override
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:114
std::vector< std::unique_ptr< DynamicEntry > > dynamic_entries_t
Internal container for storing ELF's DynamicEntry.
Definition ELF/Binary.hpp:120
const Segment * segment_from_offset(Segment::TYPE type, uint64_t offset) const
Symbol & add_symtab_symbol(const Symbol &symbol)
Add a symtab symbol.
Binary & operator+=(const Section &section)
Definition ELF/Binary.hpp:1169
const_filter_iterator< std::vector< Symbol * > > it_const_imported_symbols
Iterator which outputs imported const Symbol& object.
Definition ELF/Binary.hpp:205
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:155
int64_t symtab_idx(const Symbol &sym) const
const Segment * operator[](Segment::TYPE type) const
Definition ELF/Binary.hpp:1208
it_const_sections sections() const
Definition ELF/Binary.hpp:331
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:169
const Header & header() const
Definition ELF/Binary.hpp:311
int64_t dynsym_idx(std::string_view name) const
Symbol index in the dynamic symbol table or -1 if the symbol does not exist.
size_t hash(std::string_view name)
std::vector< std::string > string_list_t
Definition ELF/Binary.hpp:73
it_const_symtab_symbols symtab_symbols() const
Definition ELF/Binary.hpp:416
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:611
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:1091
Section * extend(const Section &section, uint64_t size)
const Symbol * get_dynamic_symbol(std::string_view name) const
Get the dynamic symbol from the given name. Return a nullptr if it can't be found.
std::vector< std::unique_ptr< Note > > notes_t
Internal container for storing notes.
Definition ELF/Binary.hpp:76
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:336
void write(const std::string &filename)
Reconstruct the binary object and write it in filename.
Definition ELF/Binary.hpp:826
friend class Builder
Definition ELF/Binary.hpp:67
bool has(Note::TYPE type) const
Check if a ELF::Note associated with the given type exists.
Definition ELF/Binary.hpp:1008
Segment * segment_from_offset(uint64_t offset)
Definition ELF/Binary.hpp:952
DynamicEntry * operator[](DynamicEntry::TAG tag)
Definition ELF/Binary.hpp:1212
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:183
it_const_symbols_version_definition symbols_version_definition() const
Definition ELF/Binary.hpp:435
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.
int64_t symtab_idx(std::string_view name) const
Symbol index from the .symtab section or -1 if the symbol is not present.
bool contains_sections(uint64_t start, uint64_t end) const
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:1184
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:341
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:395
filter_iterator< std::vector< Symbol * > > it_imported_symbols
Iterator which outputs imported Symbol& object.
Definition ELF/Binary.hpp:202
bool remove_version_requirement(std::string_view libname)
Deletes all required symbol versions linked to the specified library name. The function returns true ...
Symbol & add_exported_function(uint64_t address, std::string_view name="")
Create a symbol for the function at the given address and export it.
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:162
it_const_dynamic_entries dynamic_entries() const
Definition ELF/Binary.hpp:354
Binary & operator-=(DynamicEntry::TAG tag)
Definition ELF/Binary.hpp:1189
it_relocations relocations()
Return all relocations present in the binary.
Definition ELF/Binary.hpp:494
Section * dynamic_section()
Return the .dynamic section. If the section can't be found, it returns a nullptr.
const SymbolVersionRequirement * find_version_requirement(std::string_view libname) const
Try to find the SymbolVersionRequirement associated with the given library name (e....
Segment * get(Segment::TYPE type)
Definition ELF/Binary.hpp:979
uint8_t ptr_size() const
Definition ELF/Binary.hpp:1137
const DynamicEntry * operator[](DynamicEntry::TAG tag) const
Definition ELF/Binary.hpp:1216
it_symbols symbols()
Return an iterator on both static and dynamic symbols.
Definition ELF/Binary.hpp:621
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:208
const_ref_iterator< const segments_t &, const Segment * > it_const_segments
Iterator which outputs const Segment& object.
Definition ELF/Binary.hpp:117
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.
Section * operator[](Section::TYPE type)
Definition ELF/Binary.hpp:1228
it_const_dynamic_symbols dynamic_symbols() const
Definition ELF/Binary.hpp:399
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.
void remove_symtab_symbol(std::string_view name)
Remove symtab symbols with the given name.
string_list_t strings(size_t min_size=5) const
Return list of the strings used by the ELF binary.
friend class Parser
Definition ELF/Binary.hpp:66
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:552
Symbol * get_dynamic_symbol(std::string_view name)
Definition ELF/Binary.hpp:646
Relocation * get_relocation(const Symbol &symbol)
Definition ELF/Binary.hpp:514
Section * get(Section::TYPE type)
Definition ELF/Binary.hpp:993
static bool classof(const LIEF::Binary *bin)
Definition ELF/Binary.hpp:1153
it_const_relocations relocations() const
Definition ELF/Binary.hpp:498
Binary & operator-=(Note::TYPE type)
Definition ELF/Binary.hpp:1199
SymbolVersionRequirement * find_version_requirement(std::string_view name)
Definition ELF/Binary.hpp:1120
bool is_targeting_android() const
True if the current ELF is targeting Android.
it_const_segments segments() const
Definition ELF/Binary.hpp:345
DynamicEntry * get(DynamicEntry::TAG tag)
Definition ELF/Binary.hpp:972
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:546
friend class Layout
Definition ELF/Binary.hpp:69
ref_iterator< sections_t &, Section * > it_sections
Iterator which outputs Section& object.
Definition ELF/Binary.hpp:211
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:146
void remove_section(std::string_view name, bool clear=false) override
Remove a binary's section.
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:151
ref_iterator< relocations_t &, Relocation * > it_relocations
Iterator which outputs Relocation& object.
Definition ELF/Binary.hpp:166
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.
const Section * operator[](Section::TYPE type) const
Definition ELF/Binary.hpp:1232
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.
result< uint64_t > get_function_address(std::string_view func_name, bool demangled) const
Return the address of the given function name.
void remove(Note::TYPE type)
Remove all notes with the given type.
Relocation & add_dynamic_relocation(const Relocation &relocation)
Add a new dynamic relocation.
void remove_symbol(std::string_view name)
Remove symbols with the given name in both:
ref_iterator< symbols_t &, Symbol * > it_dynamic_symbols
Iterator which outputs the Dynamic Symbol& object.
Definition ELF/Binary.hpp:176
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:445
ref_iterator< std::vector< Symbol * > > it_symbols
Iterator which outputs static and dynamic Symbol& object.
Definition ELF/Binary.hpp:190
it_notes notes()
Definition ELF/Binary.hpp:1050
std::vector< std::unique_ptr< SymbolVersionDefinition > > symbols_version_definition_t
Internal container for storing SymbolVersionDefinition.
Definition ELF/Binary.hpp:98
ref_iterator< symbols_version_t &, SymbolVersion * > it_symbols_version
Iterator which outputs SymbolVersion& object.
Definition ELF/Binary.hpp:133
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:1220
const_filter_iterator< std::vector< Symbol * > > it_const_exported_symbols
Iterator which outputs exported const Symbol& object.
Definition ELF/Binary.hpp:199
Binary & operator+=(const Segment &segment)
Definition ELF/Binary.hpp:1174
DynamicEntryLibrary * get_library(std::string_view library_name)
Get the library object (DynamicEntryLibrary) from the given name If the library can't be found,...
Definition ELF/Binary.hpp:740
Binary & operator=(const Binary &)=delete
filter_iterator< relocations_t &, Relocation * > it_pltgot_relocations
Iterator which outputs plt/got Relocation& object.
Definition ELF/Binary.hpp:143
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:940
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:136
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:82
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:123
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:425
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:1179
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:539
void interpreter(std::string_view interpreter)
Change the interpreter.
Definition ELF/Binary.hpp:616
void write(std::ostream &os)
Reconstruct the binary object and write it in os stream.
Definition ELF/Binary.hpp:846
ref_iterator< symbols_version_requirement_t &, SymbolVersionRequirement * > it_symbols_version_requirement
Iterator which outputs SymbolVersionRequirement& object.
Definition ELF/Binary.hpp:89
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:93
const Relocation * get_relocation(std::string_view symbol_name) const
Return relocation associated with the given Symbol name It returns a nullptr if it is not found.
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:1003
bool has(DynamicEntry::TAG tag) const
Check if an ELF::DynamicEntry associated with the given tag exists.
Definition ELF/Binary.hpp:998
Relocation * get_relocation(std::string_view symbol_name)
Definition ELF/Binary.hpp:524
Class which represents a DT_NEEDED entry in the dynamic table.
Definition DynamicEntryLibrary.hpp:31
Class which represents an entry in the dynamic table These entries are located in the ....
Definition DynamicEntry.hpp:36
TAG
Definition DynamicEntry.hpp:48
@ HASH
Definition DynamicEntry.hpp:54
@ GNU_HASH
Definition DynamicEntry.hpp:89
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:40
TYPE
LIEF representation of the ELF NT_ values.
Definition Note.hpp:50
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:46
Class that represents an ELF relocation.
Definition ELF/Relocation.hpp:42
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:48
TYPE
Definition Segment.hpp:73
Class which represents an entry defined in DT_VERDEF or .gnu.version_d.
Definition SymbolVersionDefinition.hpp:37
Class which represents an entry in the DT_VERNEED or .gnu.version_r table.
Definition SymbolVersionRequirement.hpp:40
Class which represents an entry defined in the DT_VERSYM dynamic entry.
Definition SymbolVersion.hpp:32
Class which represents an ELF symbol.
Definition ELF/Symbol.hpp:33
Class which represents the SYSV hash for the symbols resolution.
Definition SysvHash.hpp:38
static Header from(const LIEF::ELF::Binary &elf)
Definition Visitor.hpp:211
Iterator which returns a ref on container's values given predicates.
Definition iterators.hpp:392
Iterator which returns reference on container's values.
Definition iterators.hpp:120
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:78
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
@ not_found
Definition errors.hpp:25
tl::unexpected< lief_errors > make_error_code(lief_errors e)
Create a standard error code from lief_errors.
Definition errors.hpp:54
Definition ELF/Binary.hpp:40
Definition ELF/Binary.hpp:44
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:27
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:672
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:385
Configuration options to tweak the building process.
Definition ELF/Builder.hpp:54
#define LIEF_API
Definition visibility.h:44
#define LIEF_LOCAL
Definition visibility.h:45