diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-08 09:52:17 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-08 09:52:17 +0000 |
| commit | bb2089599007fb5e25e613e67088a05731df4347 (patch) | |
| tree | 77deff9406e9ace63476c8909fde2b04d7364476 /arch/x86_64/src | |
| parent | 8773024d1b4e756fe5d3494479247c64c7ad8491 (diff) | |
| parent | a6018f84cc8971859d90109740fbada8d77ff5a9 (diff) | |
| download | teachos-bb2089599007fb5e25e613e67088a05731df4347.tar.xz teachos-bb2089599007fb5e25e613e67088a05731df4347.zip | |
Merge branch 'feat_memory_manager' of ssh://gitlab.ost.ch:45022/teachos/kernel into feat_memory_manager
Diffstat (limited to 'arch/x86_64/src')
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 636ddf2..2ba4fe2 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -11,7 +11,12 @@ namespace teachos::arch::kernel video::vga::text::write("Assert failed", video::vga::text::common_attributes::green_on_black); while (!condition) { - ; + // Trick the compiler into thinking the variable is changes at run time, + // to prevent the while loop being optimized away + // See + // https://stackoverflow.com/questions/9495856/how-to-prevent-g-from-optimizing-out-a-loop-controlled-by-a-variable-that-can + // for mroe information. + asm volatile("" : "+g"(condition)); } } @@ -44,8 +49,20 @@ namespace teachos::arch::kernel constexpr auto actual_entry_size = sizeof(arch::memory::elf_section_header); assert(expected_entry_size == actual_entry_size); + auto expected_total_size = symbol->tag.size; + auto actual_total_entry_size = actual_entry_size * symbol->number_of_sections; + constexpr auto actual_total_section_size = + sizeof(arch::memory::elf_symbols_section) - actual_entry_size - sizeof(uint32_t); + auto actual_total_size = actual_total_entry_size + actual_total_section_size; + assert(expected_total_size == actual_total_size); + auto begin = &symbol->sections; auto end = begin + symbol->number_of_sections; + // TODO: Last value is completly wrong, should show 0 but shows huge value for size of entries in the table of the + // SHT_NULL elf section entry. Memory around value also make no sense and look even worse? But according to api + // value should be zero :( + // assert(begin->is_null()); + for (auto section = begin; section != end; ++section) { video::vga::text::write("Looping Code section", video::vga::text::common_attributes::green_on_black); |
