LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
DynamicEntryRunPath.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_RUNPATH_H
17#define LIEF_ELF_DYNAMIC_ENTRY_RUNPATH_H
18
19#include <string_view>
20#include <string>
21#include <vector>
22
25#include "LIEF/visibility.h"
26
27
28namespace LIEF::ELF {
29
33
34 public:
35 static constexpr char delimiter = ':';
37
40
44 runpath_(std::move(runpath)) {}
45
47 DynamicEntryRunPath(const std::vector<std::string>& paths) :
49 this->paths(paths);
50 }
51
54
55 std::unique_ptr<DynamicEntry> clone() const override {
56 return std::unique_ptr<DynamicEntry>(new DynamicEntryRunPath(*this));
57 }
58
60 std::string_view runpath() const LIEF_LIFETIMEBOUND {
61 return runpath_;
62 }
63
64 void runpath(std::string runpath) {
65 runpath_ = std::move(runpath);
66 }
67
69 std::vector<std::string> paths() const;
70 void paths(const std::vector<std::string>& paths);
71
74 const std::string& path) LIEF_LIFETIMEBOUND;
75
78
81
82 DynamicEntryRunPath& operator+=(const std::string& path) {
83 return append(path);
84 }
85
86 DynamicEntryRunPath& operator-=(const std::string& path) {
87 return remove(path);
88 }
89
90 void accept(Visitor& visitor) const override;
91
92 static bool classof(const DynamicEntry* entry) {
93 return entry->tag() == DynamicEntry::TAG::RUNPATH;
94 }
95
96 std::ostream& print(std::ostream& os) const override;
97
98 ~DynamicEntryRunPath() override = default;
99
100 private:
101 std::string runpath_;
102};
103}
104
105#endif
void accept(Visitor &visitor) const override
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryRunPath.hpp:55
DynamicEntryRunPath & insert(size_t pos, const std::string &path)
Insert a path at the given position.
DynamicEntryRunPath(const DynamicEntryRunPath &)=default
DynamicEntryRunPath & append(const std::string &path)
Append the given path.
DynamicEntryRunPath & remove(const std::string &path)
Remove the given path.
DynamicEntryRunPath(std::string runpath)
Constructor from (run)path.
Definition DynamicEntryRunPath.hpp:42
void paths(const std::vector< std::string > &paths)
static constexpr char delimiter
Definition DynamicEntryRunPath.hpp:35
std::string_view runpath() const
Runpath raw value.
Definition DynamicEntryRunPath.hpp:60
DynamicEntryRunPath(const std::vector< std::string > &paths)
Constructor from a list of paths.
Definition DynamicEntryRunPath.hpp:47
void runpath(std::string runpath)
Definition DynamicEntryRunPath.hpp:64
std::ostream & print(std::ostream &os) const override
~DynamicEntryRunPath() override=default
std::vector< std::string > paths() const
Paths as a list.
DynamicEntryRunPath & operator-=(const std::string &path)
Definition DynamicEntryRunPath.hpp:86
DynamicEntryRunPath & operator+=(const std::string &path)
Definition DynamicEntryRunPath.hpp:82
static bool classof(const DynamicEntry *entry)
Definition DynamicEntryRunPath.hpp:92
DynamicEntryRunPath()
Definition DynamicEntryRunPath.hpp:38
DynamicEntryRunPath & operator=(const DynamicEntryRunPath &)=default
TAG
Definition DynamicEntry.hpp:49
@ RUNPATH
Definition DynamicEntry.hpp:80
TAG tag() const
Tag of the current entry. The most common tags are: DT_NEEDED, DT_INIT, ...
Definition DynamicEntry.hpp:252
Definition Visitor.hpp:212
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
#define LIEF_API
Definition visibility.h:45