mirror of
https://github.com/lief-project/LIEF
synced 2026-06-08 15:30:44 +00:00
Add support for Mach-O LC_SUBCLIENT command
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
#include <LIEF/MachO/VersionMin.hpp>
|
||||
#include <LIEF/MachO/SegmentSplitInfo.hpp>
|
||||
#include <LIEF/MachO/SubFramework.hpp>
|
||||
#include <LIEF/MachO/SubClient.hpp>
|
||||
#include <LIEF/MachO/DyldEnvironment.hpp>
|
||||
#include <LIEF/MachO/EncryptionInfo.hpp>
|
||||
#include <LIEF/MachO/BuildVersion.hpp>
|
||||
@@ -105,6 +106,7 @@ void init_objects(nb::module_& m) {
|
||||
CREATE(VersionMin, m);
|
||||
CREATE(SegmentSplitInfo, m);
|
||||
CREATE(SubFramework, m);
|
||||
CREATE(SubClient, m);
|
||||
CREATE(DyldEnvironment, m);
|
||||
CREATE(EncryptionInfo, m);
|
||||
CREATE(BuildVersion, m);
|
||||
|
||||
@@ -37,6 +37,7 @@ target_sources(pyLIEF PRIVATE
|
||||
pySegmentSplitInfo.cpp
|
||||
pySourceVersion.cpp
|
||||
pySubFramework.cpp
|
||||
pySubClient.cpp
|
||||
pySymbol.cpp
|
||||
pySymbolCommand.cpp
|
||||
pyThreadCommand.cpp
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "LIEF/MachO/SegmentSplitInfo.hpp"
|
||||
#include "LIEF/MachO/SourceVersion.hpp"
|
||||
#include "LIEF/MachO/SubFramework.hpp"
|
||||
#include "LIEF/MachO/SubClient.hpp"
|
||||
#include "LIEF/MachO/Symbol.hpp"
|
||||
#include "LIEF/MachO/SymbolCommand.hpp"
|
||||
#include "LIEF/MachO/ThreadCommand.hpp"
|
||||
@@ -82,6 +83,7 @@ void create<Binary>(nb::module_& m) {
|
||||
init_ref_iterator<Binary::it_libraries>(bin, "it_libraries");
|
||||
init_ref_iterator<Binary::it_relocations>(bin, "it_relocations");
|
||||
init_ref_iterator<Binary::it_rpaths>(bin, "it_rpaths");
|
||||
init_ref_iterator<Binary::it_sub_clients>(bin, "it_sub_clients");
|
||||
|
||||
nb::class_<Binary::range_t>(bin, "range_t")
|
||||
.def_rw("start", &Binary::range_t::start)
|
||||
@@ -345,9 +347,14 @@ void create<Binary>(nb::module_& m) {
|
||||
"Return the binary's " RST_CLASS_REF(lief.MachO.SegmentSplitInfo) " if any, or None"_doc,
|
||||
nb::rv_policy::reference_internal)
|
||||
|
||||
.def_prop_ro("has_sub_framework",
|
||||
&Binary::has_sub_framework,
|
||||
"``True`` if the binary has a " RST_CLASS_REF(lief.MachO.SubFramework) " command"_doc)
|
||||
.def_prop_ro("subclients",
|
||||
nb::overload_cast<>(&Binary::subclients),
|
||||
"Return an iterator over the binary's " RST_CLASS_REF(lief.MachO.SubClient) ""_doc,
|
||||
nb::keep_alive<0, 1>())
|
||||
|
||||
.def_prop_ro("has_subclients",
|
||||
&Binary::has_subclients,
|
||||
"``True`` if the binary has a " RST_CLASS_REF(lief.MachO.SubClient) " command"_doc)
|
||||
|
||||
.def_prop_ro("sub_framework",
|
||||
nb::overload_cast<>(&Binary::sub_framework),
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 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 <string>
|
||||
#include <sstream>
|
||||
#include <nanobind/stl/string.h>
|
||||
|
||||
#include "LIEF/MachO/SubClient.hpp"
|
||||
|
||||
#include "MachO/pyMachO.hpp"
|
||||
|
||||
namespace LIEF::MachO::py {
|
||||
|
||||
template<>
|
||||
void create<SubClient>(nb::module_& m) {
|
||||
|
||||
nb::class_<SubClient, LoadCommand>(m, "SubClient",
|
||||
R"delim(
|
||||
Class that represents the SubClient command.
|
||||
Accodring to the Mach-O ``loader.h`` documentation:
|
||||
|
||||
> For dynamically linked shared libraries that are subframework of an umbrella
|
||||
> framework they can allow clients other than the umbrella framework or other
|
||||
> subframeworks in the same umbrella framework. To do this the subframework
|
||||
> is built with "-allowable_client client_name" and an LC_SUB_CLIENT load
|
||||
> command is created for each -allowable_client flag. The client_name is
|
||||
> usually a framework name. It can also be a name used for bundles clients
|
||||
> where the bundle is built with "-client_name client_name".
|
||||
)delim"_doc)
|
||||
|
||||
.def_prop_rw("client",
|
||||
nb::overload_cast<>(&SubClient::client, nb::const_),
|
||||
nb::overload_cast<std::string>(&SubClient::client),
|
||||
"Name of the sub client"_doc)
|
||||
|
||||
LIEF_DEFAULT_STR(SubClient);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user