Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
237 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* Copyright 2017 J.Rieck (based on R. Thomas's work) | ||
* Copyright 2017 Quarkslab | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <algorithm> | ||
|
||
#include <string> | ||
#include <sstream> | ||
|
||
#include "LIEF/visitors/Hash.hpp" | ||
#include "LIEF/MachO/RPathCommand.hpp" | ||
|
||
#include "pyMachO.hpp" | ||
|
||
template<class T> | ||
using getter_t = T (RPathCommand::*)(void) const; | ||
|
||
template<class T> | ||
using setter_t = void (RPathCommand::*)(T); | ||
|
||
|
||
void init_MachO_RPathCommand_class(py::module& m) { | ||
|
||
py::class_<RPathCommand, LoadCommand>(m, "RPathCommand") | ||
|
||
.def_property("path", | ||
static_cast<getter_t<const std::string&>>(&RPathCommand::path), | ||
static_cast<setter_t<const std::string&>>(&RPathCommand::path), | ||
"@rpath path", | ||
py::return_value_policy::reference_internal) | ||
|
||
|
||
.def("__eq__", &RPathCommand::operator==) | ||
.def("__ne__", &RPathCommand::operator!=) | ||
.def("__hash__", | ||
[] (const RPathCommand& rpath_command) { | ||
return LIEF::Hash::hash(rpath_command); | ||
}) | ||
|
||
|
||
.def("__str__", | ||
[] (const RPathCommand& rpath_command) | ||
{ | ||
std::ostringstream stream; | ||
stream << rpath_command; | ||
std::string str = stream.str(); | ||
return str; | ||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Copyright 2017 J. Rieck (based on R. Thomas's work) | ||
* Copyright 2017 Quarkslab | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef LIEF_MACHO_RPATH_COMMAND_H_ | ||
#define LIEF_MACHO_RPATH_COMMAND_H_ | ||
#include <string> | ||
#include <iostream> | ||
|
||
#include "LIEF/visibility.h" | ||
#include "LIEF/types.hpp" | ||
|
||
#include "LIEF/MachO/LoadCommand.hpp" | ||
|
||
namespace LIEF { | ||
namespace MachO { | ||
|
||
class DLL_PUBLIC RPathCommand : public LoadCommand { | ||
public: | ||
RPathCommand(void); | ||
RPathCommand(const rpath_command *rpathCmd); | ||
|
||
RPathCommand& operator=(const RPathCommand& copy); | ||
RPathCommand(const RPathCommand& copy); | ||
|
||
virtual ~RPathCommand(void); | ||
|
||
const std::string& path(void) const; | ||
void path(const std::string& path); | ||
|
||
bool operator==(const RPathCommand& rhs) const; | ||
bool operator!=(const RPathCommand& rhs) const; | ||
|
||
virtual void accept(Visitor& visitor) const override; | ||
|
||
virtual std::ostream& print(std::ostream& os) const override; | ||
|
||
private: | ||
std::string path_; | ||
}; | ||
|
||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* Copyright 2017 J.Rieck (based on R. Thomas's work) | ||
* Copyright 2017 Quarkslab | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <numeric> | ||
#include <iomanip> | ||
|
||
#include "LIEF/visitors/Hash.hpp" | ||
|
||
#include "LIEF/MachO/RPathCommand.hpp" | ||
|
||
namespace LIEF { | ||
namespace MachO { | ||
|
||
RPathCommand::RPathCommand(void) = default; | ||
RPathCommand& RPathCommand::operator=(const RPathCommand&) = default; | ||
RPathCommand::RPathCommand(const RPathCommand&) = default; | ||
RPathCommand::~RPathCommand(void) = default; | ||
|
||
RPathCommand::RPathCommand(const rpath_command *rpathCmd) : | ||
LoadCommand::LoadCommand{static_cast<LOAD_COMMAND_TYPES>(rpathCmd->cmd), rpathCmd->cmdsize} | ||
{ | ||
} | ||
|
||
const std::string& RPathCommand::path(void) const { | ||
return this->path_; | ||
} | ||
|
||
void RPathCommand::path(const std::string& path) { | ||
this->path_ = path; | ||
} | ||
|
||
|
||
void RPathCommand::accept(Visitor& visitor) const { | ||
LoadCommand::accept(visitor); | ||
visitor.visit(this->path()); | ||
} | ||
|
||
|
||
bool RPathCommand::operator==(const RPathCommand& rhs) const { | ||
size_t hash_lhs = Hash::hash(*this); | ||
size_t hash_rhs = Hash::hash(rhs); | ||
return hash_lhs == hash_rhs; | ||
} | ||
|
||
bool RPathCommand::operator!=(const RPathCommand& rhs) const { | ||
return not (*this == rhs); | ||
} | ||
|
||
|
||
std::ostream& RPathCommand::print(std::ostream& os) const { | ||
LoadCommand::print(os); | ||
os << std::left | ||
<< std::setw(10) << "Path: " << this->path(); | ||
return os; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters