LIEF: Library to Instrument Executable Formats Version 1.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>
20#include <vector>
21
22#include "LIEF/visibility.h"
24
25namespace LIEF {
26namespace ELF {
27
32 public:
33 static constexpr char delimiter = ':';
37
38 DynamicEntryRpath(std::string rpath) :
40 rpath_(std::move(rpath)) {}
41
43 DynamicEntryRpath(const std::vector<std::string>& paths) :
45 this->paths(paths);
46 }
47
50
51 std::unique_ptr<DynamicEntry> clone() const override {
52 return std::unique_ptr<DynamicEntryRpath>(new DynamicEntryRpath(*this));
53 }
54
56 const std::string& rpath() const {
57 return rpath_;
58 }
59
60 void rpath(std::string name) {
61 rpath_ = std::move(name);
62 }
63
65 std::vector<std::string> paths() const;
66 void paths(const std::vector<std::string>& paths);
67
70 const std::string& path) LIEF_LIFETIMEBOUND;
71
74
76 DynamicEntryRpath& remove(const std::string& path) LIEF_LIFETIMEBOUND;
77
78 DynamicEntryRpath& operator+=(std::string path) {
79 return append(std::move(path));
80 }
81
82 DynamicEntryRpath& operator-=(const std::string& path) {
83 return remove(path);
84 }
85
86 static bool classof(const DynamicEntry* entry) {
87 return entry->tag() == DynamicEntry::TAG::RPATH;
88 }
89
90 void accept(Visitor& visitor) const override;
91
92 std::ostream& print(std::ostream& os) const override;
93
94 ~DynamicEntryRpath() = default;
95
96 private:
97 std::string rpath_;
98};
99}
100}
101
102#endif
DynamicEntryRpath(const DynamicEntryRpath &)=default
std::ostream & print(std::ostream &os) const override
const std::string & rpath() const
The actual rpath as a string.
Definition DynamicEntryRpath.hpp:56
void rpath(std::string name)
Definition DynamicEntryRpath.hpp:60
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:82
DynamicEntryRpath(const std::vector< std::string > &paths)
Constructor from a list of paths.
Definition DynamicEntryRpath.hpp:43
void accept(Visitor &visitor) const override
void paths(const std::vector< std::string > &paths)
static bool classof(const DynamicEntry *entry)
Definition DynamicEntryRpath.hpp:86
DynamicEntryRpath(std::string rpath)
Definition DynamicEntryRpath.hpp:38
DynamicEntryRpath()
Definition DynamicEntryRpath.hpp:35
static constexpr char delimiter
Definition DynamicEntryRpath.hpp:33
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryRpath.hpp:51
DynamicEntryRpath & operator+=(std::string path)
Definition DynamicEntryRpath.hpp:78
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:309
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
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:45