LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
DynamicEntryArray.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_DYNAMIC_ENTRY_ARRAY_H
17#define LIEF_ELF_DYNAMIC_ENTRY_ARRAY_H
18
19#include "LIEF/visibility.h"
21
22#include <vector>
23
24namespace LIEF {
25namespace ELF {
26
36 public:
37 using array_t = std::vector<uint64_t>;
39
44
47
48 std::unique_ptr<DynamicEntry> clone() const override {
49 return std::unique_ptr<DynamicEntryArray>(new DynamicEntryArray(*this));
50 }
51
54 return array_;
55 }
56
57 const array_t& array() const {
58 return array_;
59 }
60 void array(const array_t& array) {
61 array_ = array;
62 }
63
65 DynamicEntryArray& insert(size_t pos, uint64_t function);
66
68 DynamicEntryArray& append(uint64_t function) {
69 array_.push_back(function);
70 return *this;
71 }
72
74 DynamicEntryArray& remove(uint64_t function);
75
77 size_t size() const {
78 return array_.size();
79 }
80
82 return append(value);
83 }
84
86 return remove(value);
87 }
88
89 const uint64_t& operator[](size_t idx) const;
90 uint64_t& operator[](size_t idx);
91
92 void accept(Visitor& visitor) const override;
93
94 std::ostream& print(std::ostream& os) const override;
95
96 ~DynamicEntryArray() override = default;
97
98 static bool classof(const DynamicEntry* entry) {
99 const DynamicEntry::TAG tag = entry->tag();
103 }
104
105 private:
106 array_t array_;
107};
108}
109}
110
111#endif
DynamicEntryArray(DynamicEntry::TAG tag, array_t array)
Definition DynamicEntryArray.hpp:41
DynamicEntryArray & remove(uint64_t function)
Remove the given function.
const array_t & array() const
Definition DynamicEntryArray.hpp:57
DynamicEntryArray(const DynamicEntryArray &)=default
static bool classof(const DynamicEntry *entry)
Definition DynamicEntryArray.hpp:98
uint64_t & operator[](size_t idx)
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryArray.hpp:48
DynamicEntryArray & operator+=(uint64_t value)
Definition DynamicEntryArray.hpp:81
~DynamicEntryArray() override=default
std::vector< uint64_t > array_t
Definition DynamicEntryArray.hpp:37
DynamicEntryArray & operator-=(uint64_t value)
Definition DynamicEntryArray.hpp:85
std::ostream & print(std::ostream &os) const override
DynamicEntryArray & append(uint64_t function)
Append the given function.
Definition DynamicEntryArray.hpp:68
DynamicEntryArray & operator=(const DynamicEntryArray &)=default
size_t size() const
Number of function registred in this array.
Definition DynamicEntryArray.hpp:77
DynamicEntryArray & insert(size_t pos, uint64_t function)
Insert the given function at pos.
const uint64_t & operator[](size_t idx) const
void accept(Visitor &visitor) const override
void array(const array_t &array)
Definition DynamicEntryArray.hpp:60
array_t & array()
Return the array values (list of pointers).
Definition DynamicEntryArray.hpp:53
TAG
Definition DynamicEntry.hpp:48
@ PREINIT_ARRAY
Definition DynamicEntry.hpp:81
@ INIT_ARRAY
Definition DynamicEntry.hpp:75
@ FINI_ARRAY
Definition DynamicEntry.hpp:76
TAG tag() const
Tag of the current entry. The most common tags are: DT_NEEDED, DT_INIT, ...
Definition DynamicEntry.hpp:309
uint64_t value() const
Return the entry's value.
Definition DynamicEntry.hpp:317
Definition Visitor.hpp:212
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:40
Definition string.h:155
#define LIEF_API
Definition visibility.h:43