aboutsummaryrefslogtreecommitdiff
path: root/libs/elf
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-12-05 15:13:57 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-12-05 15:13:57 +0100
commit53402f496ee07351923945f523565f9aa618005a (patch)
tree42a561bf8615c2617d5592675bf919d3dac720e5 /libs/elf
parentc01073b04a6dcdf067342cf17fe5363a66d85eed (diff)
downloadteachos-53402f496ee07351923945f523565f9aa618005a.tar.xz
teachos-53402f496ee07351923945f523565f9aa618005a.zip
elf: add basic section_header flag tests
Diffstat (limited to 'libs/elf')
-rw-r--r--libs/elf/include/elf/section_header.hpp20
1 files changed, 20 insertions, 0 deletions
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 <cstdint>
#include <limits>
#include <type_traits>
+#include <utility>
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<format::elf32>) == section_header_size<format::elf32>);
static_assert(sizeof(section_header<format::elf64>) == section_header_size<format::elf64>);
+
} // namespace elf
#endif \ No newline at end of file