LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
RPathCommand.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2021 J. Rieck (based on R. Thomas's work)
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_MACHO_RPATH_COMMAND_H
17#define LIEF_MACHO_RPATH_COMMAND_H
18#include <string_view>
19#include <memory>
20#include <ostream>
21#include <string>
22
23#include "LIEF/visibility.h"
24
26
27
28namespace LIEF::MachO {
29
30namespace details {
31struct rpath_command;
32}
33
39 public:
40 RPathCommand() = default;
41 RPathCommand(std::string path);
42 RPathCommand(const details::rpath_command& rpathCmd);
43
44 RPathCommand& operator=(const RPathCommand& copy) = default;
45 RPathCommand(const RPathCommand& copy) = default;
46
47 std::unique_ptr<LoadCommand> clone() const override {
48 return std::make_unique<RPathCommand>(*this);
49 }
50
52 static std::unique_ptr<RPathCommand> create(std::string path) {
53 return std::make_unique<RPathCommand>(std::move(path));
54 }
55
56 ~RPathCommand() override = default;
57
59 std::string_view path() const LIEF_LIFETIMEBOUND {
60 return path_;
61 }
62
64 uint32_t path_offset() const {
65 return path_offset_;
66 }
67
68 void path(std::string path) {
69 path_ = std::move(path);
70 }
71
72 void accept(Visitor& visitor) const override;
73
74 std::ostream& print(std::ostream& os) const override;
75
76 static bool classof(const LoadCommand* cmd) {
77 return cmd->command() == LoadCommand::TYPE::RPATH;
78 }
79
80 private:
81 uint32_t path_offset_ = 0;
82 std::string path_;
83};
84
85}
86
87#endif
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:132
@ RPATH
Definition LoadCommand.hpp:76
RPathCommand(const details::rpath_command &rpathCmd)
void path(std::string path)
Definition RPathCommand.hpp:68
RPathCommand(const RPathCommand &copy)=default
RPathCommand & operator=(const RPathCommand &copy)=default
std::string_view path() const
The rpath value as a string.
Definition RPathCommand.hpp:59
static bool classof(const LoadCommand *cmd)
Definition RPathCommand.hpp:76
std::unique_ptr< LoadCommand > clone() const override
Definition RPathCommand.hpp:47
uint32_t path_offset() const
Original string offset of the path.
Definition RPathCommand.hpp:64
void accept(Visitor &visitor) const override
RPathCommand(std::string path)
std::ostream & print(std::ostream &os) const override
static std::unique_ptr< RPathCommand > create(std::string path)
Create a new RPath command for the provided path.
Definition RPathCommand.hpp:52
~RPathCommand() override=default
Definition Visitor.hpp:212
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
#define LIEF_API
Definition visibility.h:45