LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
CoreAuxv.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2025 R. Thomas
2 * Copyright 2017 - 2025 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 <ostream>
20#include <map>
21#include <utility>
22
23#include "LIEF/visibility.h"
24#include "LIEF/ELF/enums.hpp"
25#include "LIEF/ELF/Note.hpp"
26
27namespace LIEF {
28namespace ELF {
29class LIEF_API CoreAuxv : public Note {
32 public:
33 enum class TYPE {
34 END = 0,
35 IGNORE,
36 EXECFD,
37 PHDR,
38 PHENT,
39 PHNUM,
40 PAGESZ,
41 BASE,
42 FLAGS,
43 ENTRY,
44 NOTELF,
45 UID,
46 EUID,
47 GID,
48 EGID,
49 TGT_PLATFORM,
50 HWCAP,
51 CLKTCK,
52 FPUCW,
53 DCACHEBSIZE,
54 ICACHEBSIZE,
55 UCACHEBSIZE,
56 IGNOREPPC,
57 SECURE,
58 BASE_PLATFORM,
59 RANDOM,
60 HWCAP2,
61 //ENTRY27,
62 //ENTRY28,
63 //ENTRY29,
64 //ENTRY30,
65 EXECFN = 31,
66 SYSINFO,
67 SYSINFO_EHDR,
68 };
69
70 CoreAuxv(ARCH arch, Header::CLASS cls, std::string name,
71 uint32_t type, description_t description) :
72 Note(std::move(name), Note::TYPE::CORE_AUXV, type, std::move(description), ""),
73 arch_(arch), class_(cls)
74 {}
75
76 std::unique_ptr<Note> clone() const override {
77 return std::unique_ptr<Note>(new CoreAuxv(*this));
78 }
79 std::map<TYPE, uint64_t> values() const;
82 result<uint64_t> get(TYPE type) const;
86
87 result<uint64_t> operator[](TYPE type) const {
88 return get(type);
89 }
90
91 bool set(TYPE type, uint64_t value);
92 bool set(const std::map<TYPE, uint64_t>& values);
93
94 void dump(std::ostream& os) const override;
95
96 void accept(Visitor& visitor) const override;
97
98 static bool classof(const Note* note) {
99 return note->type() == Note::TYPE::CORE_AUXV;
100 }
101
102 ~CoreAuxv() override = default;
103
104 LIEF_API friend
105 std::ostream& operator<<(std::ostream& os, const CoreAuxv& note) {
106 note.dump(os);
107 return os;
108 }
109
110 protected:
111 ARCH arch_ = ARCH::NONE;
112 Header::CLASS class_ = Header::CLASS::NONE;
113};
114
116
117} // namepsace ELF
118} // namespace LIEF
119
120#endif
Class representing core auxv object.
Definition CoreAuxv.hpp:31
std::unique_ptr< Note > clone() const override
Clone the current note and keep its polymorphic type.
Definition CoreAuxv.hpp:76
std::map< TYPE, uint64_t > values() const
A map of CoreAuxv::TYPE and the value.
TYPE
Definition CoreAuxv.hpp:33
void dump(std::ostream &os) const override
static bool classof(const Note *note)
Definition CoreAuxv.hpp:98
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:70
result< uint64_t > operator[](TYPE type) const
Definition CoreAuxv.hpp:87
friend std::ostream & operator<<(std::ostream &os, const CoreAuxv &note)
Definition CoreAuxv.hpp:105
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