LIEF: Library to Instrument Executable Formats Version
Loading...
Searching...
No Matches
DyldBindingInfo.hpp
1/* Copyright 2017 - 2023 R. Thomas
2 * Copyright 2017 - 2023 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_DYLD_INFO_BINDING_INFO_H
17#define LIEF_MACHO_DYLD_INFO_BINDING_INFO_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21#include "LIEF/types.hpp"
22#include "LIEF/MachO/BindingInfo.hpp"
23#include "LIEF/MachO/enums.hpp"
24
25namespace LIEF {
26namespace MachO {
27
35class LIEF_API DyldBindingInfo : public BindingInfo {
36
37 friend class BinaryParser;
38
39 public:
41 DyldBindingInfo(BINDING_CLASS cls, BIND_TYPES type,
42 uint64_t address, int64_t addend = 0,
43 int32_t oridnal = 0, bool is_weak = false,
44 bool is_non_weak_definition = false, uint64_t offset = 0);
45
46 DyldBindingInfo& operator=(DyldBindingInfo other);
47 DyldBindingInfo(const DyldBindingInfo& other);
48
50
51 void swap(DyldBindingInfo& other);
52
55 void binding_class(BINDING_CLASS bind_class);
56
58 BIND_TYPES binding_type() const;
59 void binding_type(BIND_TYPES type);
60
61 bool is_non_weak_definition() const {
62 return this->is_non_weak_definition_;
63 }
64
65 void set_non_weak_definition(bool val) {
66 this->is_non_weak_definition_ = val;
67 }
68
70 uint64_t original_offset() const;
71
72 BindingInfo::TYPES type() const override {
73 return BindingInfo::TYPES::DYLD_INFO;
74 }
75
76 static bool classof(BindingInfo* info) {
77 return info->type() == BindingInfo::TYPES::DYLD_INFO;
78 }
79
80 ~DyldBindingInfo() override;
81
82 void accept(Visitor& visitor) const override;
83
84 LIEF_API friend std::ostream& operator<<(std::ostream& os, const DyldBindingInfo& binding_info);
85 private:
86 BINDING_CLASS class_ = BINDING_CLASS::BIND_CLASS_STANDARD;
87 BIND_TYPES binding_type_ = BIND_TYPES::BIND_TYPE_POINTER;
88 bool is_non_weak_definition_ = false;
89 uint64_t offset_ = 0;
90};
91
92}
93}
94#endif
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:73
Class that provides an interface over a binding operation.
Definition BindingInfo.hpp:40
TYPES
Definition BindingInfo.hpp:45
virtual TYPES type() const =0
The type of the binding. This type provides the origin of the binding (LC_DYLD_INFO or LC_DYLD_CHAINE...
This class represents a symbol binding operation associated with the LC_DYLD_INFO bytecode.
Definition DyldBindingInfo.hpp:35
uint64_t original_offset() const
Original relative offset of the binding opcodes.
BIND_TYPES binding_type() const
Type of the binding. Most of the times it's BIND_TYPES::BIND_TYPE_POINTER.
BindingInfo::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 DyldBindingInfo.hpp:72
BINDING_CLASS binding_class() const
Class of the binding (weak, lazy, ...)
Definition Visitor.hpp:219
BINDING_CLASS
Within the dyld_info_command there are differents area of binding. These enums tag these area.
Definition MachO/enums.hpp:257
LIEF namespace.
Definition Abstract/Binary.hpp:32