From 53402f496ee07351923945f523565f9aa618005a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 5 Dec 2025 15:13:57 +0100 Subject: elf: add basic section_header flag tests --- libs/elf/include/elf/section_header.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libs') diff --git a/libs/elf/include/elf/section_header.hpp b/libs/elf/include/elf/section_header.hpp index 73e2e7b..3afe334 100644 --- a/libs/elf/include/elf/section_header.hpp +++ b/libs/elf/include/elf/section_header.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace elf { @@ -60,6 +61,24 @@ namespace elf compressed = 0x800, ///< Is compressed }; + //! Check if the section is allocated + [[nodiscard]] constexpr auto allocated() const noexcept -> bool + { + return std::to_underlying(flags) & std::to_underlying(header_flags::allocated); + } + + //! Check if the section is executable + [[nodiscard]] constexpr auto executable() const noexcept -> bool + { + return std::to_underlying(flags) & std::to_underlying(header_flags::executable); + } + + //! Check if the section is writeable + [[nodiscard]] constexpr auto writable() const noexcept -> bool + { + return std::to_underlying(flags) & std::to_underlying(header_flags::writeable); + } + std::uint32_t name_offset; ///< Offset into the section header string table, defining the section name header_type type; ///< Type of this section header_flags flags; ///< Flags of this section @@ -74,6 +93,7 @@ namespace elf static_assert(sizeof(section_header) == section_header_size); static_assert(sizeof(section_header) == section_header_size); + } // namespace elf #endif \ No newline at end of file -- cgit v1.2.3