LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
X86Feature.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_NOTE_DETAILS_PROPERTIES_X86FEATURES_H
17#define LIEF_ELF_NOTE_DETAILS_PROPERTIES_X86FEATURES_H
18#include <vector>
19#include <utility>
20
21#include "LIEF/ELF/NoteDetails/NoteGnuProperty.hpp"
22
23namespace LIEF {
24namespace ELF {
25
32 public:
33
35 enum class FLAG {
36 NONE = 0,
37 USED,
38 NEEDED,
39 };
40
42 enum class FEATURE {
43 UNKNOWN = 0,
44
45 IBT,
46 SHSTK,
47 LAM_U48,
48 LAM_U57,
49 X86,
50 X87,
51 MMX,
52 XMM,
53 YMM,
54 ZMM,
55 FXSR,
56 XSAVE,
57 XSAVEOPT,
58 XSAVEC,
59 TMM,
60 MASK,
61 };
62
68 using features_t = std::vector<std::pair<FLAG, FEATURE>>;
69
70 static bool classof(const NoteGnuProperty::Property* prop) {
72 }
73
74 static std::unique_ptr<X86Features> create(uint32_t type, BinaryStream& stream);
75
77 const features_t& features() const {
78 return features_;
79 }
80
81 void dump(std::ostream &os) const override;
82
83 ~X86Features() override = default;
84
85 protected:
86 inline static std::unique_ptr<X86Features> create_feat1(FLAG flag, BinaryStream& stream);
87 inline static std::unique_ptr<X86Features> create_feat2(FLAG flag, BinaryStream& stream);
88 X86Features(features_t values) :
89 NoteGnuProperty::Property(NoteGnuProperty::Property::TYPE::X86_FEATURE),
90 features_(std::move(values))
91 {}
92
93 features_t features_;
94};
95
96LIEF_API const char* to_string(X86Features::FLAG flag);
97LIEF_API const char* to_string(X86Features::FEATURE feat);
98
99}
100}
101
102#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
This class wraps the different properties that can be used in a NT_GNU_PROPERTY_TYPE_0 note.
Definition NoteGnuProperty.hpp:35
TYPE
LIEF's mirror types of the original GNU_PROPERTY_ values.
Definition NoteGnuProperty.hpp:39
@ X86_FEATURE
Mirror of GNU_PROPERTY_X86_FEATURE_*
TYPE type() const
Return the LIEF's mirror type of the note.
Definition NoteGnuProperty.hpp:51
Class that wraps the NT_GNU_PROPERTY_TYPE_0 note.
Definition NoteGnuProperty.hpp:30
This class interfaces the different GNU_PROPERTY_X86_FEATURE_* properties which includes:
Definition X86Feature.hpp:31
FLAG
Flag according to the _AND, _USED or _NEEDED suffixes.
Definition X86Feature.hpp:35
@ NEEDED
For the original GNU_PROPERTY_X86_FEATURE_2_NEEDED property.
@ NONE
For the original GNU_PROPERTY_X86_FEATURE_1_AND property.
@ USED
For the original GNU_PROPERTY_X86_FEATURE_2_USED property.
const features_t & features() const
List of the features.
Definition X86Feature.hpp:77
FEATURE
Features provided by these different properties.
Definition X86Feature.hpp:42
std::vector< std::pair< FLAG, FEATURE > > features_t
List of the features as a pair of FLAG, FEATURE.
Definition X86Feature.hpp:68
LIEF namespace.
Definition Abstract/Binary.hpp:32