LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
ChainedBindingInfo.hpp
Go to the documentation of this file.
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_MACHO_CHAINED_BINDING_INFO_H
17#define LIEF_MACHO_CHAINED_BINDING_INFO_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
23
24namespace LIEF {
25namespace MachO {
26class BinaryParser;
27class Builder;
29class ChainedBindingInfoList;
30class Symbol;
31
32namespace details {
33struct dyld_chained_ptr_arm64e_bind;
34struct dyld_chained_ptr_arm64e_auth_bind;
35struct dyld_chained_ptr_arm64e_bind24;
36struct dyld_chained_ptr_arm64e_auth_bind24;
37struct dyld_chained_ptr_64_bind;
38struct dyld_chained_ptr_32_bind;
39}
49
50 friend class BinaryParser;
51 friend class Builder;
52 friend class DyldChainedFixupsCreator;
53 friend class ChainedBindingInfoList;
54
55 public:
57 explicit ChainedBindingInfo(DYLD_CHAINED_FORMAT fmt, bool is_weak);
58
59 ChainedBindingInfo& operator=(ChainedBindingInfo other);
60 ChainedBindingInfo(const ChainedBindingInfo& other);
61 ChainedBindingInfo(ChainedBindingInfo&&) noexcept;
62
63 void swap(ChainedBindingInfo& other) noexcept;
64 DYLD_CHAINED_FORMAT format() const {
67 return format_;
68 }
72 return ptr_format_;
73 }
74 uint32_t offset() const {
77 return offset_;
78 }
79
80 void offset(uint32_t offset) {
81 offset_ = offset;
82 }
83
84 uint64_t address() const override {
85 return address_;
86 }
87
88 void address(uint64_t address) override {
89 address_ = address;
90 }
91
92 uint64_t sign_extended_addend() const;
93
94 TYPES type() const override {
95 return TYPES::CHAINED;
96 }
97
98 static bool classof(const BindingInfo* info) {
99 return info->type() == TYPES::CHAINED;
100 }
101
102 ~ChainedBindingInfo() override;
103
104 void accept(Visitor& visitor) const override;
105
106 LIEF_API friend
107 std::ostream& operator<<(std::ostream& os, const ChainedBindingInfo& info) {
108 os << static_cast<const BindingInfo&>(info);
109 return os;
110 }
111
112 protected:
113 LIEF_LOCAL void clear();
114 enum class BIND_TYPES {
115 UNKNOWN = 0,
116
117 ARM64E_BIND,
118 ARM64E_AUTH_BIND,
119
120 ARM64E_BIND24,
121 ARM64E_AUTH_BIND24,
122
123 PTR64_BIND,
124 PTR32_BIND,
125 };
126
127 LIEF_LOCAL void set(const details::dyld_chained_ptr_arm64e_bind& bind);
128 LIEF_LOCAL void set(const details::dyld_chained_ptr_arm64e_auth_bind& bind);
129 LIEF_LOCAL void set(const details::dyld_chained_ptr_arm64e_bind24& bind);
130 LIEF_LOCAL void set(const details::dyld_chained_ptr_arm64e_auth_bind24& bind);
131 LIEF_LOCAL void set(const details::dyld_chained_ptr_64_bind& bind);
132 LIEF_LOCAL void set(const details::dyld_chained_ptr_32_bind& bind);
133
134 DYLD_CHAINED_FORMAT format_;
135 DYLD_CHAINED_PTR_FORMAT ptr_format_;
136 uint32_t offset_ = 0;
137
138 BIND_TYPES btypes_ = BIND_TYPES::UNKNOWN;
139
140 union {
141 details::dyld_chained_ptr_arm64e_bind* arm64_bind_ = nullptr;
142 details::dyld_chained_ptr_arm64e_auth_bind* arm64_auth_bind_;
143 details::dyld_chained_ptr_arm64e_bind24* arm64_bind24_;
144 details::dyld_chained_ptr_arm64e_auth_bind24* arm64_auth_bind24_;
145 details::dyld_chained_ptr_64_bind* p64_bind_;
146 details::dyld_chained_ptr_32_bind* p32_bind_;
147 };
148};
149
150}
151}
152#endif
BindingInfo.hpp
DyldChainedFormat.hpp
LIEF::MachO::BinaryParser
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:75
LIEF::MachO::BindingInfo
Class that provides an interface over a binding operation.
Definition BindingInfo.hpp:39
LIEF::MachO::Builder
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:58
LIEF::MachO::ChainedBindingInfo
This class represents a symbol binding operation associated with the LC_DYLD_CHAINED_FIXUPS command.
Definition ChainedBindingInfo.hpp:48
LIEF::MachO::ChainedBindingInfo::classof
static bool classof(const BindingInfo *info)
Definition ChainedBindingInfo.hpp:98
LIEF::MachO::ChainedBindingInfo::accept
void accept(Visitor &visitor) const override
LIEF::MachO::ChainedBindingInfo::offset
void offset(uint32_t offset)
Definition ChainedBindingInfo.hpp:80
LIEF::MachO::ChainedBindingInfo::operator<<
friend std::ostream & operator<<(std::ostream &os, const ChainedBindingInfo &info)
Definition ChainedBindingInfo.hpp:107
LIEF::MachO::ChainedBindingInfo::ChainedBindingInfo
ChainedBindingInfo(const ChainedBindingInfo &other)
LIEF::MachO::ChainedBindingInfo::ChainedBindingInfo
ChainedBindingInfo(ChainedBindingInfo &&) noexcept
LIEF::MachO::ChainedBindingInfo::ptr_format
DYLD_CHAINED_PTR_FORMAT ptr_format() const
Format of the pointer.
Definition ChainedBindingInfo.hpp:71
LIEF::MachO::ChainedBindingInfo::address
uint64_t address() const override
Address of the binding.
Definition ChainedBindingInfo.hpp:84
LIEF::MachO::ChainedBindingInfo::ChainedBindingInfo
ChainedBindingInfo()=delete
LIEF::MachO::ChainedBindingInfo::address
void address(uint64_t address) override
Definition ChainedBindingInfo.hpp:88
LIEF::MachO::ChainedBindingInfo::type
TYPES type() const override
The type of the binding. This type provides the origin of the binding (LC_DYLD_INFO or LC_DYLD_CHAINE...
Definition ChainedBindingInfo.hpp:94
LIEF::MachO::ChainedBindingInfo::sign_extended_addend
uint64_t sign_extended_addend() const
LIEF::MachO::ChainedBindingInfo::~ChainedBindingInfo
~ChainedBindingInfo() override
LIEF::MachO::ChainedBindingInfo::ChainedBindingInfo
ChainedBindingInfo(DYLD_CHAINED_FORMAT fmt, bool is_weak)
LIEF::MachO::ChainedBindingInfo::operator=
ChainedBindingInfo & operator=(ChainedBindingInfo other)
LIEF::MachO::ChainedBindingInfo::offset
uint32_t offset() const
Original offset in the chain of this binding.
Definition ChainedBindingInfo.hpp:76
LIEF::MachO::DyldChainedFixupsCreator
Definition DyldChainedFixupsCreator.hpp:41
LIEF::MachO::Symbol
Class that represents a Symbol in a Mach-O file.
Definition MachO/Symbol.hpp:47
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::MachO::MACHO_TYPES::UNKNOWN
@ UNKNOWN
Definition MachO/enums.hpp:25
LIEF::MachO::DYLD_CHAINED_PTR_FORMAT
DYLD_CHAINED_PTR_FORMAT
Definition DyldChainedFormat.hpp:29
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41
LIEF_LOCAL
#define LIEF_LOCAL
Definition visibility.h:42