LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
DynamicEntryRunPath.hpp
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"
23#include "LIEF/ELF/DynamicEntry.hpp"
24
25namespace LIEF {
26namespace ELF {
27
30class LIEF_API DynamicEntryRunPath : public DynamicEntry {
31
32 public:
33 static constexpr char delimiter = ':';
34 using DynamicEntry::DynamicEntry;
35
37 DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0)
38 {}
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
53 DynamicEntryRunPath& operator=(const DynamicEntryRunPath&) = default;
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
98 ~DynamicEntryRunPath() = default;
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
DynamicEntryRunPath & insert(size_t pos, const std::string &path)
Insert a path at the given position
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
DynamicEntryRunPath(const std::vector< std::string > &paths)
Constructor from a list of paths.
Definition DynamicEntryRunPath.hpp:47
const std::string & runpath() const
Runpath raw value.
Definition DynamicEntryRunPath.hpp:61
std::vector< std::string > paths() const
Paths as a list.
Class which represents an entry in the dynamic table These entries are located in the ....
Definition DynamicEntry.hpp:37
TAG
Definition DynamicEntry.hpp:46
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32