LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
ChainedBindingInfo.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
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_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}
40
49
50 friend class BinaryParser;
51 friend class Builder;
54
55 public:
57 explicit ChainedBindingInfo(DYLD_CHAINED_FORMAT fmt, bool is_weak);
58
61
63 ChainedBindingInfo& operator=(ChainedBindingInfo&&) noexcept;
64
67 return format_;
68 }
69
72 return ptr_format_;
73 }
74
76 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
103
104 void accept(Visitor& visitor) const override;
105
106 LIEF_API friend std::ostream& operator<<(std::ostream& os,
107 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
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:78
TYPES
Definition BindingInfo.hpp:46
@ CHAINED
Binding associated with the Dyld info opcodes.
Definition BindingInfo.hpp:49
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:63
static bool classof(const BindingInfo *info)
Definition ChainedBindingInfo.hpp:98
details::dyld_chained_ptr_64_bind * p64_bind_
Definition ChainedBindingInfo.hpp:145
void accept(Visitor &visitor) const override
void offset(uint32_t offset)
Definition ChainedBindingInfo.hpp:80
friend std::ostream & operator<<(std::ostream &os, const ChainedBindingInfo &info)
Definition ChainedBindingInfo.hpp:106
friend class ChainedBindingInfoList
Definition ChainedBindingInfo.hpp:53
ChainedBindingInfo(const ChainedBindingInfo &other)
ChainedBindingInfo(ChainedBindingInfo &&) noexcept
friend class BinaryParser
Definition ChainedBindingInfo.hpp:50
DYLD_CHAINED_PTR_FORMAT ptr_format() const
Format of the pointer.
Definition ChainedBindingInfo.hpp:71
DYLD_CHAINED_FORMAT format() const
Format of the imports.
Definition ChainedBindingInfo.hpp:66
friend class DyldChainedFixupsCreator
Definition ChainedBindingInfo.hpp:52
uint64_t address() const override
Address of the binding.
Definition ChainedBindingInfo.hpp:84
void address(uint64_t address) override
Definition ChainedBindingInfo.hpp:88
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
ChainedBindingInfo & operator=(const ChainedBindingInfo &other)
friend class Builder
Definition ChainedBindingInfo.hpp:51
details::dyld_chained_ptr_arm64e_auth_bind24 * arm64_auth_bind24_
Definition ChainedBindingInfo.hpp:144
uint64_t sign_extended_addend() const
details::dyld_chained_ptr_arm64e_auth_bind * arm64_auth_bind_
Definition ChainedBindingInfo.hpp:142
details::dyld_chained_ptr_32_bind * p32_bind_
Definition ChainedBindingInfo.hpp:146
details::dyld_chained_ptr_arm64e_bind * arm64_bind_
Definition ChainedBindingInfo.hpp:141
ChainedBindingInfo(DYLD_CHAINED_FORMAT fmt, bool is_weak)
details::dyld_chained_ptr_arm64e_bind24 * arm64_bind24_
Definition ChainedBindingInfo.hpp:143
uint32_t offset() const
Original offset in the chain of this binding.
Definition ChainedBindingInfo.hpp:76
Definition DyldChainedFixupsCreator.hpp:41
Class that represents a Symbol in a Mach-O file.
Definition MachO/Symbol.hpp:47
Definition Visitor.hpp:212
Definition endianness_support.hpp:60
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
DYLD_CHAINED_FORMAT
Definition DyldChainedFormat.hpp:22
@ UNKNOWN
Definition MachO/enums.hpp:24
DYLD_CHAINED_PTR_FORMAT
Definition DyldChainedFormat.hpp:29
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:43
#define LIEF_LOCAL
Definition visibility.h:44