LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
SysvHash.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_ELF_SYSV_HASH_H
16#define LIEF_ELF_SYSV_HASH_H
17
18#include <cstdint>
19#include <ostream>
20#include <vector>
21
22#include "LIEF/Object.hpp"
23#include "LIEF/visibility.h"
24
25
26namespace LIEF::ELF {
27
28class Parser;
29class Builder;
30class Binary;
31
38class LIEF_API SysvHash : public Object {
39
40 friend class Parser;
41 friend class Builder;
42 friend class Binary;
43
44 public:
45 SysvHash() = default;
46 SysvHash& operator=(const SysvHash& copy) = default;
47 SysvHash(const SysvHash& copy) = default;
48
50 SysvHash(SysvHash&&) = default;
51 ~SysvHash() override = default;
52
54 uint32_t nbucket() const {
55 return buckets_.size();
56 }
57
59 uint32_t nchain() const {
60 return chains_.size();
61 }
62
64 const std::vector<uint32_t>& buckets() const LIEF_LIFETIMEBOUND {
65 return buckets_;
66 }
67
69 const std::vector<uint32_t>& chains() const LIEF_LIFETIMEBOUND {
70 return chains_;
71 }
72
73 void nchain(uint32_t nb) {
74 chains_.resize(nb);
75 }
76
77 void accept(Visitor& visitor) const override;
78
79 LIEF_API friend std::ostream& operator<<(std::ostream& os,
80 const SysvHash& sysvhash);
81
82 private:
83 std::vector<uint32_t> buckets_;
84 std::vector<uint32_t> chains_;
85};
86
87}
88
89
90#endif
Class which represents an ELF binary.
Definition ELF/Binary.hpp:65
Class which takes an ELF::Binary object and reconstructs a valid binary.
Definition ELF/Builder.hpp:47
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:46
void accept(Visitor &visitor) const override
~SysvHash() override=default
SysvHash(SysvHash &&)=default
uint32_t nbucket() const
Return the number of buckets used.
Definition SysvHash.hpp:54
SysvHash & operator=(const SysvHash &copy)=default
friend class Builder
Definition SysvHash.hpp:41
void nchain(uint32_t nb)
Definition SysvHash.hpp:73
SysvHash(const SysvHash &copy)=default
uint32_t nchain() const
Return the number of chain used.
Definition SysvHash.hpp:59
const std::vector< uint32_t > & chains() const
Chains values.
Definition SysvHash.hpp:69
friend class Binary
Definition SysvHash.hpp:42
friend class Parser
Definition SysvHash.hpp:40
friend std::ostream & operator<<(std::ostream &os, const SysvHash &sysvhash)
SysvHash & operator=(SysvHash &&)=default
const std::vector< uint32_t > & buckets() const
Buckets values.
Definition SysvHash.hpp:64
Definition Object.hpp:24
Definition Visitor.hpp:211
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:27
#define LIEF_API
Definition visibility.h:44