LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
DynamicEntryRpath.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_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
31 public:
32 static constexpr char delimiter = ':';
33 using DynamicEntry::DynamicEntry;
37
38 DynamicEntryRpath(std::string rpath) :
40 rpath_(std::move(rpath))
41 {}
42
44 DynamicEntryRpath(const std::vector<std::string>& paths) :
46 {
47 this->paths(paths);
48 }
49
52
53 std::unique_ptr<DynamicEntry> clone() const override {
54 return std::unique_ptr<DynamicEntryRpath>(new DynamicEntryRpath(*this));
55 }
56
58 const std::string& rpath() const {
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, const std::string& path);
72
74 DynamicEntryRpath& append(std::string path);
75
77 DynamicEntryRpath& remove(const std::string& path);
78
79 DynamicEntryRpath& operator+=(std::string path) {
80 return append(std::move(path));
81 }
82
83 DynamicEntryRpath& operator-=(const std::string& 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() = default;
96
97 private:
98 std::string rpath_;
99};
100}
101}
102
103#endif
Class which represents a DT_RPATH entry. This attribute is deprecated (cf. man ld) in favour of DT_RU...
Definition DynamicEntryRpath.hpp:30
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:58
void rpath(std::string name)
Definition DynamicEntryRpath.hpp:62
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:83
DynamicEntryRpath(const std::vector< std::string > &paths)
Constructor from a list of paths.
Definition DynamicEntryRpath.hpp:44
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:38
DynamicEntryRpath()
Definition DynamicEntryRpath.hpp:34
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryRpath.hpp:53
DynamicEntryRpath & operator+=(std::string path)
Definition DynamicEntryRpath.hpp:79
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
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41