LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
DynamicEntryFlags.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 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_FLAGS_H
17#define LIEF_ELF_DYNAMIC_ENTRY_FLAGS_H
18
19#include <vector>
20#include <ostream>
21
22#include "LIEF/visibility.h"
24
25namespace LIEF {
26namespace ELF {
27
29 public:
30 static constexpr uint64_t BASE = 0x100000000;
31
32 enum class FLAG : uint64_t {
33 ORIGIN = 0x00000001,
34 SYMBOLIC = 0x00000002,
35 TEXTREL = 0x00000004,
36 BIND_NOW = 0x00000008,
37 STATIC_TLS = 0x00000010,
39 NOW = BASE + 0x000000001,
40 GLOBAL = BASE + 0x000000002,
41 GROUP = BASE + 0x000000004,
42 NODELETE = BASE + 0x000000008,
43 LOADFLTR = BASE + 0x000000010,
44 INITFIRST = BASE + 0x000000020,
45 NOOPEN = BASE + 0x000000040,
46 HANDLE_ORIGIN = BASE + 0x000000080,
47 DIRECT = BASE + 0x000000100,
48 TRANS = BASE + 0x000000200,
49 INTERPOSE = BASE + 0x000000400,
50 NODEFLIB = BASE + 0x000000800,
51 NODUMP = BASE + 0x000001000,
52 CONFALT = BASE + 0x000002000,
53 ENDFILTEE = BASE + 0x000004000,
54 DISPRELDNE = BASE + 0x000008000,
55 DISPRELPND = BASE + 0x000010000,
56 NODIRECT = BASE + 0x000020000,
57 IGNMULDEF = BASE + 0x000040000,
58 NOKSYMS = BASE + 0x000080000,
59 NOHDR = BASE + 0x000100000,
60 EDITED = BASE + 0x000200000,
61 NORELOC = BASE + 0x000400000,
62 SYMINTPOSE = BASE + 0x000800000,
63 GLOBAUDIT = BASE + 0x001000000,
64 SINGLETON = BASE + 0x002000000,
65 PIE = BASE + 0x008000000,
66 KMOD = BASE + 0x010000000,
67 WEAKFILTER = BASE + 0x020000000,
68 NOCOMMON = BASE + 0x040000000,
69 };
70
71 using flags_list_t = std::vector<FLAG>;
72
73 public:
74 using DynamicEntry::DynamicEntry;
76
77 static DynamicEntryFlags create_dt_flag(uint64_t value) {
78 return DynamicEntryFlags(DynamicEntry::TAG::FLAGS, value);
79 }
80
81 static DynamicEntryFlags create_dt_flag_1(uint64_t value) {
82 return DynamicEntryFlags(DynamicEntry::TAG::FLAGS_1, value);
83 }
84
87
88 std::unique_ptr<DynamicEntry> clone() const override {
89 return std::unique_ptr<DynamicEntryFlags>(new DynamicEntryFlags(*this));
90 }
91
93 bool has(FLAG f) const;
94
97
99 void add(FLAG f);
100
102 void remove(FLAG f);
103
105 add(f);
106 return *this;
107 }
108
110 remove(f);
111 return *this;
112 }
113
114 void accept(Visitor& visitor) const override;
115
116 static bool classof(const DynamicEntry* entry) {
117 return entry->tag() == DynamicEntry::TAG::FLAGS ||
118 entry->tag() == DynamicEntry::TAG::FLAGS_1;
119 }
120
122
123 std::ostream& print(std::ostream& os) const override;
124 private:
125 DynamicEntryFlags(DynamicEntry::TAG tag, uint64_t flags) :
126 DynamicEntry(tag, flags)
127 {}
128};
129
131
132}
133}
134
135#endif
Definition DynamicEntryFlags.hpp:28
static DynamicEntryFlags create_dt_flag_1(uint64_t value)
Definition DynamicEntryFlags.hpp:81
FLAG
Definition DynamicEntryFlags.hpp:32
DynamicEntryFlags & operator-=(FLAG f)
Definition DynamicEntryFlags.hpp:109
bool has(FLAG f) const
If the current entry has the given FLAG.
std::ostream & print(std::ostream &os) const override
static bool classof(const DynamicEntry *entry)
Definition DynamicEntryFlags.hpp:116
std::vector< FLAG > flags_list_t
Definition DynamicEntryFlags.hpp:71
void add(FLAG f)
Add the given FLAG.
void remove(FLAG f)
Remove the given FLAG.
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryFlags.hpp:88
DynamicEntryFlags & operator+=(FLAG f)
Definition DynamicEntryFlags.hpp:104
DynamicEntryFlags & operator=(const DynamicEntryFlags &)=default
flags_list_t flags() const
Return flags as a list of integers.
DynamicEntryFlags(const DynamicEntryFlags &)=default
void accept(Visitor &visitor) const override
static DynamicEntryFlags create_dt_flag(uint64_t value)
Definition DynamicEntryFlags.hpp:77
Class which represents an entry in the dynamic table These entries are located in the ....
Definition DynamicEntry.hpp:36
TAG
Definition DynamicEntry.hpp:45
TAG tag() const
Tag of the current entry. The most common tags are: DT_NEEDED, DT_INIT, ...
Definition DynamicEntry.hpp:200
Definition Visitor.hpp:224
const char * to_string(DynamicEntry::TAG e)
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41