LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
X86Feature.hpp
Go to the documentation of this file.
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
22#include "LIEF/visibility.h"
23
24namespace LIEF {
25namespace ELF {
33 public:
34 enum class FLAG {
37 NONE = 0,
38 USED,
39 NEEDED,
40 };
41 enum class FEATURE {
44 UNKNOWN = 0,
45
46 IBT,
47 SHSTK,
48 LAM_U48,
49 LAM_U57,
50 X86,
51 X87,
52 MMX,
53 XMM,
54 YMM,
55 ZMM,
56 FXSR,
57 XSAVE,
58 XSAVEOPT,
59 XSAVEC,
60 TMM,
61 MASK,
62 };
63 using features_t = std::vector<std::pair<FLAG, FEATURE>>;
70
71 static bool classof(const NoteGnuProperty::Property* prop) {
72 return prop->type() == NoteGnuProperty::Property::TYPE::X86_FEATURE;
73 }
74
75 static std::unique_ptr<X86Features> create(uint32_t type, BinaryStream& stream);
76 const features_t& features() const {
79 return features_;
80 }
81
82 void dump(std::ostream &os) const override;
83
84 ~X86Features() override = default;
85
86 protected:
87 inline static std::unique_ptr<X86Features> create_feat1(FLAG flag, BinaryStream& stream);
88 inline static std::unique_ptr<X86Features> create_feat2(FLAG flag, BinaryStream& stream);
89 X86Features(features_t values) :
90 NoteGnuProperty::Property(NoteGnuProperty::Property::TYPE::X86_FEATURE),
91 features_(std::move(values))
92 {}
93
94 features_t features_;
95};
96
97LIEF_API const char* to_string(X86Features::FLAG flag);
98LIEF_API const char* to_string(X86Features::FEATURE feat);
99
100}
101}
102
103#endif
NoteGnuProperty.hpp
LIEF::ELF::NoteGnuProperty::Property
This class wraps the different properties that can be used in a NT_GNU_PROPERTY_TYPE_0 note.
Definition NoteGnuProperty.hpp:35
LIEF::ELF::NoteGnuProperty::Property::type
TYPE type() const
Return the LIEF's mirror type of the note.
Definition NoteGnuProperty.hpp:52
LIEF::ELF::X86Features
This class interfaces the different GNU_PROPERTY_X86_FEATURE_* properties which includes:
Definition X86Feature.hpp:32
LIEF::ELF::X86Features::create
static std::unique_ptr< X86Features > create(uint32_t type, BinaryStream &stream)
LIEF::ELF::X86Features::classof
static bool classof(const NoteGnuProperty::Property *prop)
Definition X86Feature.hpp:71
LIEF::ELF::X86Features::FLAG
FLAG
Flag according to the _AND, _USED or _NEEDED suffixes.
Definition X86Feature.hpp:36
LIEF::ELF::X86Features::features
const features_t & features() const
List of the features.
Definition X86Feature.hpp:78
LIEF::ELF::X86Features::dump
void dump(std::ostream &os) const override
LIEF::ELF::X86Features::FEATURE
FEATURE
Features provided by these different properties.
Definition X86Feature.hpp:43
LIEF::ELF::X86Features::~X86Features
~X86Features() override=default
LIEF::ELF
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
LIEF::ELF::to_string
const char * to_string(DynamicEntry::TAG e)
LIEF::ELF::ARCH::NONE
@ NONE
Definition ELF/enums.hpp:31
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41