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 * 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_RPATH_H
17#define LIEF_ELF_DYNAMIC_ENTRY_RPATH_H
18
19#include <string_view>
20#include <memory>
21#include <string>
22#include <vector>
23
26#include "LIEF/visibility.h"
27
28
29namespace LIEF::ELF {
30
35 public:
36 static constexpr char delimiter = ':';
40
41 DynamicEntryRpath(std::string rpath) :
43 rpath_(std::move(rpath)) {}
44
46 DynamicEntryRpath(const std::vector<std::string>& paths) :
48 this->paths(paths);
49 }
50
53
54 std::unique_ptr<DynamicEntry> clone() const override {
55 return std::make_unique<DynamicEntryRpath>(*this);
56 }
57
59 std::string_view rpath() const LIEF_LIFETIMEBOUND {
60 return rpath_;
61 }
62
63 void rpath(std::string name) {
64 rpath_ = std::move(name);
65 }
66
68 std::vector<std::string> paths() const;
69 void paths(const std::vector<std::string>& paths);
70
73 const std::string& path) LIEF_LIFETIMEBOUND;
74
77
79 DynamicEntryRpath& remove(const std::string& path) LIEF_LIFETIMEBOUND;
80
81 DynamicEntryRpath& operator+=(std::string path) {
82 return append(std::move(path));
83 }
84
85 DynamicEntryRpath& operator-=(const std::string& path) {
86 return remove(path);
87 }
88
89 static bool classof(const DynamicEntry* entry) {
90 return entry->tag() == DynamicEntry::TAG::RPATH;
91 }
92
93 void accept(Visitor& visitor) const override;
94
95 std::ostream& print(std::ostream& os) const override;
96
97 ~DynamicEntryRpath() override = default;
98
99 private:
100 std::string rpath_;
101};
102}
103
104
105#endif
DynamicEntryRpath(const DynamicEntryRpath &)=default
std::ostream & print(std::ostream &os) const override
void rpath(std::string name)
Definition DynamicEntryRpath.hpp:63
DynamicEntryRpath & insert(size_t pos, const std::string &path)
Insert a path at the given position.
std::vector< std::string > paths() const
Paths as a list.
DynamicEntryRpath & operator=(const DynamicEntryRpath &)=default
DynamicEntryRpath & append(std::string path)
Append the given path.
DynamicEntryRpath & remove(const std::string &path)
Remove the given path.
DynamicEntryRpath & operator-=(const std::string &path)
Definition DynamicEntryRpath.hpp:85
std::string_view rpath() const
The actual rpath as a string.
Definition DynamicEntryRpath.hpp:59
~DynamicEntryRpath() override=default
DynamicEntryRpath(const std::vector< std::string > &paths)
Constructor from a list of paths.
Definition DynamicEntryRpath.hpp:46
void accept(Visitor &visitor) const override
void paths(const std::vector< std::string > &paths)
static bool classof(const DynamicEntry *entry)
Definition DynamicEntryRpath.hpp:89
DynamicEntryRpath(std::string rpath)
Definition DynamicEntryRpath.hpp:41
DynamicEntryRpath()
Definition DynamicEntryRpath.hpp:38
static constexpr char delimiter
Definition DynamicEntryRpath.hpp:36
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryRpath.hpp:54
DynamicEntryRpath & operator+=(std::string path)
Definition DynamicEntryRpath.hpp:81
TAG
Definition DynamicEntry.hpp:49
@ RPATH
Definition DynamicEntry.hpp:66
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