LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
CoreAuxv.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_CORE_AUXV_H
17#define LIEF_ELF_CORE_AUXV_H
18
19#include <vector>
20#include <ostream>
21#include <map>
22#include <utility>
23
24#include "LIEF/visibility.h"
25#include "LIEF/ELF/enums.hpp"
26#include "LIEF/ELF/Note.hpp"
27
28namespace LIEF {
29namespace ELF {
30class LIEF_API CoreAuxv : public Note {
33 public:
34 enum class TYPE {
35 END = 0,
36 IGNORE,
37 EXECFD,
38 PHDR,
39 PHENT,
40 PHNUM,
41 PAGESZ,
42 BASE,
43 FLAGS,
44 ENTRY,
45 NOTELF,
46 UID,
47 EUID,
48 GID,
49 EGID,
50 TGT_PLATFORM,
51 HWCAP,
52 CLKTCK,
53 FPUCW,
54 DCACHEBSIZE,
55 ICACHEBSIZE,
56 UCACHEBSIZE,
57 IGNOREPPC,
58 SECURE,
59 BASE_PLATFORM,
60 RANDOM,
61 HWCAP2,
62 //ENTRY27,
63 //ENTRY28,
64 //ENTRY29,
65 //ENTRY30,
66 EXECFN = 31,
67 SYSINFO,
68 SYSINFO_EHDR,
69 };
70
71 CoreAuxv(ARCH arch, Header::CLASS cls, std::string name,
72 uint32_t type, description_t description) :
73 Note(std::move(name), Note::TYPE::CORE_AUXV, type, std::move(description), ""),
74 arch_(arch), class_(cls)
75 {}
76
77 std::unique_ptr<Note> clone() const override {
78 return std::unique_ptr<Note>(new CoreAuxv(*this));
79 }
80 std::map<TYPE, uint64_t> values() const;
83 result<uint64_t> get(TYPE type) const;
87
88 result<uint64_t> operator[](TYPE type) const {
89 return get(type);
90 }
91
92 bool set(TYPE type, uint64_t value);
93 bool set(const std::map<TYPE, uint64_t>& values);
94
95 void dump(std::ostream& os) const override;
96
97 void accept(Visitor& visitor) const override;
98
99 static bool classof(const Note* note) {
100 return note->type() == Note::TYPE::CORE_AUXV;
101 }
102
103 ~CoreAuxv() override = default;
104
105 LIEF_API friend
106 std::ostream& operator<<(std::ostream& os, const CoreAuxv& note) {
107 note.dump(os);
108 return os;
109 }
110
111 protected:
112 ARCH arch_ = ARCH::NONE;
113 Header::CLASS class_ = Header::CLASS::NONE;
114};
115
117
118} // namepsace ELF
119} // namespace LIEF
120
121#endif
Class representing core auxv object.
Definition CoreAuxv.hpp:32
std::unique_ptr< Note > clone() const override
Clone the current note and keep its polymorphic type.
Definition CoreAuxv.hpp:77
std::map< TYPE, uint64_t > values() const
A map of CoreAuxv::TYPE and the value.
TYPE
Definition CoreAuxv.hpp:34
void dump(std::ostream &os) const override
static bool classof(const Note *note)
Definition CoreAuxv.hpp:99
bool set(TYPE type, uint64_t value)
~CoreAuxv() override=default
bool set(const std::map< TYPE, uint64_t > &values)
CoreAuxv(ARCH arch, Header::CLASS cls, std::string name, uint32_t type, description_t description)
Definition CoreAuxv.hpp:71
result< uint64_t > operator[](TYPE type) const
Definition CoreAuxv.hpp:88
friend std::ostream & operator<<(std::ostream &os, const CoreAuxv &note)
Definition CoreAuxv.hpp:106
void accept(Visitor &visitor) const override
result< uint64_t > get(TYPE type) const
Return the value associated with the provided TYPE or a lief_errors::not_found if the type is not pre...
Class which represents an ELF note. This class can be instantiated using the static Note::create func...
Definition Note.hpp:39
TYPE type() const
Return the type of the note. This type does not match the NT_ type value. For accessing the original ...
Definition Note.hpp:195
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
const char * to_string(DynamicEntry::TAG e)
ARCH
Definition ELF/enums.hpp:30
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41