16#ifndef LIEF_ELF_NOTE_H
17#define LIEF_ELF_NOTE_H
23#include "LIEF/Object.hpp"
24#include "LIEF/visibility.h"
25#include "LIEF/errors.hpp"
26#include "LIEF/span.hpp"
28#include "LIEF/ELF/Header.hpp"
62 GNU_BUILD_ATTRIBUTE_OPEN,
63 GNU_BUILD_ATTRIBUTE_FUNC,
101 CORE_TAGGED_ADDR_CTRL,
102 CORE_PAC_ENABLED_KEYS,
126 const std::string& name);
133 return type_to_section(note.
type());
143 const std::string& name, uint32_t type,
description_t description,
161 Note& operator=(
const Note& copy) =
default;
164 ~Note()
override =
default;
167 virtual std::unique_ptr<Note>
clone()
const {
168 return std::unique_ptr<Note>(
new Note(*
this));
172 const std::string&
name()
const {
185 return original_type_;
193 span<uint8_t> description() {
197 void name(std::string name) {
198 name_ = std::move(name);
203 description_ = std::move(description);
209 virtual void dump(std::ostream& os)
const;
211 void accept(
Visitor& visitor)
const override;
214 std::ostream& operator<<(std::ostream& os,
const Note& note) {
221 Note(std::string name, TYPE type, uint32_t original_type,
222 description_t description) :
223 name_(std::move(name)),
225 original_type_(original_type),
226 description_(std::move(description))
230 LIEF_LOCAL
result<T> read_at(
size_t offset)
const;
233 LIEF_LOCAL
ok_error_t write_at(
size_t offset,
const T& value);
235 LIEF_LOCAL
ok_error_t write_string_at(
size_t offset,
const std::string& value);
238 read_string_at(
size_t offset,
size_t maxsize = 0)
const;
241 TYPE type_ = TYPE::UNKNOWN;
242 uint32_t original_type_ = 0;
243 description_t description_;
246LIEF_API
const char* to_string(
Note::TYPE type);
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
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 represents an ELF note. This class can be instantiated using the static Note::create func...
Definition Note.hpp:36
static std::unique_ptr< Note > create(const std::string &name, TYPE type, description_t description, ARCH arch=ARCH::NONE, Header::CLASS cls=Header::CLASS::NONE)
Create a new note from the given parameters. Additional information such as the architecture or the E...
std::vector< uint8_t > description_t
Container used to handle the description data.
Definition Note.hpp:43
TYPE
LIEF representation of the ELF NT_ values.
Definition Note.hpp:46
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:178
static result< const char * > type_owner(TYPE type)
Try to determine the owner's name of the TYPE provided in parameter.
uint32_t original_type() const
The original NT_xxx integer value. The meaning of this value likely depends on the owner of the note.
Definition Note.hpp:184
static result< const char * > type_to_section(TYPE type)
Try to determine the ELF section name associated with the TYPE provided in parameter.
void description(description_t description)
Change the description of the note.
Definition Note.hpp:202
uint64_t size() const
Size of the raw note which includes padding.
static result< TYPE > convert_type(Header::FILE_TYPE ftype, uint32_t type, const std::string &name)
Convert the raw integer note type into a TYPE according to the owner.
static std::unique_ptr< Note > create(BinaryStream &stream, Header::FILE_TYPE ftype=Header::FILE_TYPE::NONE, ARCH arch=ARCH::NONE, Header::CLASS cls=Header::CLASS::NONE)
Create a new note from the given stream. Additional information such as the architecture or the ELF c...
const std::string & name() const
Return the name of the note (also known as 'owner' )
Definition Note.hpp:172
virtual std::unique_ptr< Note > clone() const
Clone the current note and keep its polymorphic type.
Definition Note.hpp:167
static std::unique_ptr< Note > create(const std::string &name, uint32_t type, description_t description, Header::FILE_TYPE ftype=Header::FILE_TYPE::NONE, ARCH arch=ARCH::NONE, Header::CLASS cls=Header::CLASS::NONE)
Create a new note from the given parameters. Additional information such as the architecture or the E...
span< const uint8_t > description() const
Return the description associated with the note.
Definition Note.hpp:189
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
Definition Visitor.hpp:219
ARCH
Machine architectures See current registered ELF machine architectures at: http://www....
Definition ELF/enums.hpp:30
LIEF namespace.
Definition Abstract/Binary.hpp:32
result< ok_t > ok_error_t
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:106
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:72