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