LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
SysvHash.hpp
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_ELF_SYSV_HASH_H
17#define LIEF_ELF_SYSV_HASH_H
18
19#include <cstdint>
20#include <vector>
21#include <ostream>
22
23#include "LIEF/Object.hpp"
24#include "LIEF/visibility.h"
25
26namespace LIEF {
27namespace ELF {
28
29class Parser;
30class Builder;
31class Binary;
32
39class LIEF_API SysvHash : public Object {
40
41 friend class Parser;
42 friend class Builder;
43 friend class Binary;
44
45 public:
46 SysvHash() = default;
47 SysvHash& operator=(const SysvHash& copy) = default;
48 SysvHash(const SysvHash& copy) = default;
49
50 SysvHash& operator=(SysvHash&&) = default;
51 SysvHash(SysvHash&&) = default;
52 ~SysvHash() override = default;
53
55 uint32_t nbucket() const {
56 return buckets_.size();
57 }
58
60 uint32_t nchain() const {
61 return chains_.size();
62 }
63
65 const std::vector<uint32_t>& buckets() const {
66 return buckets_;
67 }
68
70 const std::vector<uint32_t>& chains() const {
71 return chains_;
72 }
73
74 void nchain(uint32_t nb) {
75 chains_.resize(nb);
76 }
77
78 void accept(Visitor& visitor) const override;
79
80 LIEF_API friend std::ostream& operator<<(std::ostream& os, const SysvHash& sysvhash);
81
82 private:
83 std::vector<uint32_t> buckets_;
84 std::vector<uint32_t> chains_;
85};
86
87} // namepsace ELF
88} // namespace LIEF
89
90#endif
Class which represents an ELF binary.
Definition ELF/Binary.hpp:59
Class which takes an ELF::Binary object and reconstructs a valid binary.
Definition ELF/Builder.hpp:51
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
Class which represents the SYSV hash for the symbols resolution.
Definition SysvHash.hpp:39
uint32_t nbucket() const
Return the number of buckets used.
Definition SysvHash.hpp:55
uint32_t nchain() const
Return the number of chain used.
Definition SysvHash.hpp:60
const std::vector< uint32_t > & chains() const
Chains values.
Definition SysvHash.hpp:70
const std::vector< uint32_t > & buckets() const
Buckets values.
Definition SysvHash.hpp:65
Definition Object.hpp:25
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32