LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
DynamicEntryRunPath.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_RUNPATH_H
17#define LIEF_ELF_DYNAMIC_ENTRY_RUNPATH_H
18
19#include <string>
20#include <vector>
21
22#include "LIEF/visibility.h"
24
25namespace LIEF {
26namespace ELF {
27
31
32 public:
33 static constexpr char delimiter = ':';
34 using DynamicEntry::DynamicEntry;
35
39
41 DynamicEntryRunPath(std::string runpath) :
43 runpath_(std::move(runpath))
44 {}
45
47 DynamicEntryRunPath(const std::vector<std::string>& paths) :
49 {
50 this->paths(paths);
51 }
52
55
56 std::unique_ptr<DynamicEntry> clone() const override {
57 return std::unique_ptr<DynamicEntry>(new DynamicEntryRunPath(*this));
58 }
59
61 const std::string& runpath() const {
62 return runpath_;
63 }
64
65 void runpath(std::string runpath) {
66 runpath_ = std::move(runpath);
67 }
68
70 std::vector<std::string> paths() const;
71 void paths(const std::vector<std::string>& paths);
72
74 DynamicEntryRunPath& insert(size_t pos, const std::string& path);
75
77 DynamicEntryRunPath& append(const std::string& path);
78
80 DynamicEntryRunPath& remove(const std::string& path);
81
82 DynamicEntryRunPath& operator+=(std::string path) {
83 return append(std::move(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
99
100 private:
101 std::string runpath_;
102};
103}
104}
105#endif
Class that represents a DT_RUNPATH wich is used by the loader to resolve libraries (DynamicEntryLibra...
Definition DynamicEntryRunPath.hpp:30
void accept(Visitor &visitor) const override
std::unique_ptr< DynamicEntry > clone() const override
Definition DynamicEntryRunPath.hpp:56
DynamicEntryRunPath & insert(size_t pos, const std::string &path)
Insert a path at the given position
DynamicEntryRunPath(const DynamicEntryRunPath &)=default
DynamicEntryRunPath & operator+=(std::string path)
Definition DynamicEntryRunPath.hpp:82
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:41
void paths(const std::vector< std::string > &paths)
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:65
std::ostream & print(std::ostream &os) const override
const std::string & runpath() const
Runpath raw value.
Definition DynamicEntryRunPath.hpp:61
std::vector< std::string > paths() const
Paths as a list.
DynamicEntryRunPath & operator-=(const std::string &path)
Definition DynamicEntryRunPath.hpp:86
static bool classof(const DynamicEntry *entry)
Definition DynamicEntryRunPath.hpp:92
DynamicEntryRunPath()
Definition DynamicEntryRunPath.hpp:36
DynamicEntryRunPath & operator=(const DynamicEntryRunPath &)=default
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