LIEF: Library to Instrument Executable Formats Version 0.17.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 - 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_MACHO_RPATH_COMMAND_H
17#define LIEF_MACHO_RPATH_COMMAND_H
18#include <string>
19#include <ostream>
20
21#include "LIEF/visibility.h"
22
24
25namespace LIEF {
26namespace MachO {
27
28namespace details {
29struct rpath_command;
30}
31class LIEF_API RPathCommand : public LoadCommand {
37 public:
38 RPathCommand() = default;
39 RPathCommand(std::string path);
40 RPathCommand(const details::rpath_command& rpathCmd);
41
42 RPathCommand& operator=(const RPathCommand& copy) = default;
43 RPathCommand(const RPathCommand& copy) = default;
44
45 std::unique_ptr<LoadCommand> clone() const override {
46 return std::unique_ptr<RPathCommand>(new RPathCommand(*this));
47 }
48 static std::unique_ptr<RPathCommand> create(std::string path) {
51 return std::unique_ptr<RPathCommand>(new RPathCommand(std::move(path)));
52 }
53
54 ~RPathCommand() override = default;
55 const std::string& path() const {
58 return path_;
59 }
60 uint32_t path_offset() const {
63 return path_offset_;
64 }
65
66 void path(std::string path) {
67 path_ = std::move(path);
68 }
69
70 void accept(Visitor& visitor) const override;
71
72 std::ostream& print(std::ostream& os) const override;
73
74 static bool classof(const LoadCommand* cmd) {
75 return cmd->command() == LoadCommand::TYPE::RPATH;
76 }
77
78 private:
79 uint32_t path_offset_ = 0;
80 std::string path_;
81};
82
83}
84}
85#endif
LoadCommand.hpp
LIEF::MachO::LoadCommand
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
LIEF::MachO::LoadCommand::command
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:125
LIEF::MachO::RPathCommand
Class that represents the LC_RPATH command.
Definition RPathCommand.hpp:36
LIEF::MachO::RPathCommand::RPathCommand
RPathCommand(const details::rpath_command &rpathCmd)
LIEF::MachO::RPathCommand::path
const std::string & path() const
The rpath value as a string.
Definition RPathCommand.hpp:57
LIEF::MachO::RPathCommand::path
void path(std::string path)
Definition RPathCommand.hpp:66
LIEF::MachO::RPathCommand::RPathCommand
RPathCommand(const RPathCommand &copy)=default
LIEF::MachO::RPathCommand::operator=
RPathCommand & operator=(const RPathCommand &copy)=default
LIEF::MachO::RPathCommand::classof
static bool classof(const LoadCommand *cmd)
Definition RPathCommand.hpp:74
LIEF::MachO::RPathCommand::clone
std::unique_ptr< LoadCommand > clone() const override
Definition RPathCommand.hpp:45
LIEF::MachO::RPathCommand::RPathCommand
RPathCommand()=default
LIEF::MachO::RPathCommand::path_offset
uint32_t path_offset() const
Original string offset of the path.
Definition RPathCommand.hpp:62
LIEF::MachO::RPathCommand::accept
void accept(Visitor &visitor) const override
LIEF::MachO::RPathCommand::RPathCommand
RPathCommand(std::string path)
LIEF::MachO::RPathCommand::print
std::ostream & print(std::ostream &os) const override
LIEF::MachO::RPathCommand::create
static std::unique_ptr< RPathCommand > create(std::string path)
Create a new RPath command for the provided path
Definition RPathCommand.hpp:50
LIEF::MachO::RPathCommand::~RPathCommand
~RPathCommand() override=default
LIEF::MachO::details
Definition endianness_support.hpp:59
LIEF::MachO
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41