16#ifndef LIEF_ELF_NOTE_H
17#define LIEF_ELF_NOTE_H
71 GNU_BUILD_ATTRIBUTE_OPEN,
72 GNU_BUILD_ATTRIBUTE_FUNC,
107 CORE_ARM_SYSTEM_CALL,
112 CORE_TAGGED_ADDR_CTRL,
113 CORE_PAC_ENABLED_KEYS,
141 const std::string&
name);
149 if (sec_name.empty()) {
152 return std::string(sec_name);
161 static std::unique_ptr<Note>
179 static std::unique_ptr<Note>
190 virtual std::unique_ptr<Note>
clone()
const {
191 return std::make_unique<Note>(*
this);
201 return section_name_;
213 return original_type_;
226 name_ = std::move(
name);
237 virtual void dump(std::ostream& os)
const;
248 static_assert(std::is_base_of_v<Note, T>,
"Require Note inheritance");
249 if (T::classof(
this)) {
250 return static_cast<const T*
>(
this);
257 return const_cast<T*
>(
static_cast<const Note*
>(
this)->cast<T>());
262 Note(std::string name, TYPE type, uint32_t original_type,
263 description_t description, std::string section) :
264 name_(std::move(name)),
266 original_type_(original_type),
267 description_(std::move(description)),
268 section_name_(std::move(section)) {}
279 size_t maxsize = 0)
const;
282 TYPE type_ = TYPE::UNKNOWN;
283 uint32_t original_type_ = 0;
284 description_t description_;
285 std::string section_name_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:35
Class which represents an ELF binary.
Definition ELF/Binary.hpp:61
Class which takes an ELF::Binary object and reconstructs a valid binary.
Definition ELF/Builder.hpp:48
Class which represents an ELF note. This class can be instantiated using the static Note::create func...
Definition Note.hpp:41
std::vector< uint8_t > description_t
Container used to handle the description data.
Definition Note.hpp:48
TYPE
LIEF representation of the ELF NT_ values.
Definition Note.hpp:51
const T * cast() const
Definition Note.hpp:247
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:206
static result< const char * > type_owner(TYPE type)
Try to determine the owner's name of the TYPE provided in parameter.
static std::unique_ptr< Note > create(const std::string &name, TYPE type, description_t description, std::string section_name, 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...
friend std::ostream & operator<<(std::ostream &os, const Note ¬e)
Definition Note.hpp:241
static result< std::string > note_to_section(const Note ¬e)
Definition Note.hpp:147
static std::unique_ptr< Note > create(const std::string &name, uint32_t type, description_t description, std::string section_name, 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...
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:212
static std::unique_ptr< Note > create(BinaryStream &stream, std::string section_name, 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...
virtual void dump(std::ostream &os) const
std::string_view name() const
Return the name of the note (also known as 'owner' ).
Definition Note.hpp:195
friend class Builder
Definition Note.hpp:43
static result< const char * > type_to_section(TYPE type)
Try to determine the ELF section name associated with the TYPE provided in parameter.
T * cast()
Definition Note.hpp:256
void description(description_t description)
Change the description of the note.
Definition Note.hpp:230
friend class Binary
Definition Note.hpp:44
uint64_t size() const
Size of the raw note which includes padding.
void accept(Visitor &visitor) const override
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.
friend class Parser
Definition Note.hpp:42
virtual std::unique_ptr< Note > clone() const
Clone the current note and keep its polymorphic type.
Definition Note.hpp:190
Note & operator=(const Note ©)=default
std::string_view section_name() const
Return the section name in which the note is or should be stored.
Definition Note.hpp:200
Note(const Note ©)=default
span< const uint8_t > description() const
Return the description associated with the note.
Definition Note.hpp:217
span< uint8_t > description()
Definition Note.hpp:221
void name(std::string name)
Definition Note.hpp:225
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition ELF/Parser.hpp:45
Definition Visitor.hpp:212
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:119
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:79
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
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:28
@ NONE
Definition ELF/enums.hpp:29
LIEF namespace.
Definition Abstract/Binary.hpp:41
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46