aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-08 11:39:32 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-08 11:39:32 +0000
commit88818847446c010ccbfce0690a20a4e6531ca6fa (patch)
tree4964005101fb1c255b4200d30c0d3dd29d43d37e /arch/x86_64/src
parent7edd03e9a14a3025b4d2b2ff51d838d20b79b2c4 (diff)
downloadteachos-88818847446c010ccbfce0690a20a4e6531ca6fa.tar.xz
teachos-88818847446c010ccbfce0690a20a4e6531ca6fa.zip
Add additional sanity checks to elf parsing
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/kernel/main.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index 6486b7c..40b2fe5 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -63,13 +63,26 @@ namespace teachos::arch::kernel
// value should be zero :(
// assert(begin->is_null());
- // TODO: Check if only contains one DYNSYM or SYMTAB but not both!
- // TODO: Check if only contains one dynamic section
+ std::size_t symbol_table_section_count = 0U;
+ std::size_t dynamic_section_count = 0U;
for (auto section = begin; section != end; ++section)
{
+ if (section->type == arch::memory::elf_section_type::DYNAMIC_SYMBOL_TABLE ||
+ section->type == arch::memory::elf_section_type::SYMBOL_TABLE)
+ {
+ symbol_table_section_count++;
+ }
+ else if (section->type == arch::memory::elf_section_type::DYNAMIC)
+ {
+ dynamic_section_count++;
+ }
video::vga::text::write("Looping Code section", video::vga::text::common_attributes::green_on_black);
}
+
+ // TODO: Contains two symbol tables and 4 dynamic sections, that is definetly wrong, perhaps same reason as above?
+ assert(symbol_table_section_count == 1U);
+ assert(dynamic_section_count == 1U);
}
auto main() -> void