LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
Abstract/Relocation.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_ABSTRACT_RELOCATION_H
17#define LIEF_ABSTRACT_RELOCATION_H
18
19#include <ostream>
20#include <cstdint>
21
22#include "LIEF/Object.hpp"
23#include "LIEF/visibility.h"
24
25namespace LIEF {
27class LIEF_API Relocation : public Object {
28
29 public:
30 Relocation() = default;
31
33 Relocation(uint64_t address, uint8_t size) :
34 address_(address),
35 size_(size) {}
36
37 ~Relocation() override = default;
38
39 Relocation& operator=(const Relocation&) = default;
40 Relocation(const Relocation&) = default;
41 void swap(Relocation& other) {
42 std::swap(address_, other.address_);
43 std::swap(size_, other.size_);
44 }
45
47 virtual uint64_t address() const {
48 return address_;
49 }
50
52 virtual size_t size() const {
53 return size_;
54 }
55
56 virtual void address(uint64_t address) {
57 address_ = address;
58 }
59
60 virtual void size(size_t size) {
61 size_ = (uint8_t)size;
62 }
63
65 void accept(Visitor& visitor) const override;
66
67
69 virtual bool operator<(const Relocation& rhs) const {
70 return address() < rhs.address();
71 }
72
74 virtual bool operator<=(const Relocation& rhs) const {
75 return !(address() > rhs.address());
76 }
77
79 virtual bool operator>(const Relocation& rhs) const {
80 return address() > rhs.address();
81 }
82
84 virtual bool operator>=(const Relocation& rhs) const {
85 return !(address() < rhs.address());
86 }
87
88 LIEF_API friend std::ostream& operator<<(std::ostream& os,
89 const Relocation& entry);
90
91 protected:
92 uint64_t address_ = 0;
93 uint8_t size_ = 0;
94};
95
96
97}
98#endif
friend std::ostream & operator<<(std::ostream &os, const Relocation &entry)
void swap(Relocation &other)
Definition Abstract/Relocation.hpp:41
Relocation()=default
virtual void address(uint64_t address)
Definition Abstract/Relocation.hpp:56
Relocation & operator=(const Relocation &)=default
virtual void size(size_t size)
Definition Abstract/Relocation.hpp:60
Relocation(const Relocation &)=default
virtual bool operator<(const Relocation &rhs) const
Comparison based on the Relocation's address.
Definition Abstract/Relocation.hpp:69
virtual size_t size() const
Relocation size in bits.
Definition Abstract/Relocation.hpp:52
virtual bool operator<=(const Relocation &rhs) const
Comparison based on the Relocation's address.
Definition Abstract/Relocation.hpp:74
virtual bool operator>(const Relocation &rhs) const
Comparison based on the Relocation's address.
Definition Abstract/Relocation.hpp:79
virtual uint64_t address() const
Relocation's address.
Definition Abstract/Relocation.hpp:47
virtual bool operator>=(const Relocation &rhs) const
Comparison based on the Relocation's address.
Definition Abstract/Relocation.hpp:84
void accept(Visitor &visitor) const override
Method so that the visitor can visit us.
Relocation(uint64_t address, uint8_t size)
Constructor from a relocation's address and size.
Definition Abstract/Relocation.hpp:33
~Relocation() override=default
Definition Visitor.hpp:212
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:45