diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-15 21:07:59 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-15 21:07:59 +0200 |
commit | 8b88f3f7fd143fc542a5118d50a7a981464270d5 (patch) | |
tree | 86b4ca2b14b3594d3eaa7ff449db72920cad2b70 /src | |
parent | Enable ThinLTO (diff) | |
download | kernel.cpp-8b88f3f7fd143fc542a5118d50a7a981464270d5.tar.xz |
Fix compile failure without -O2
Linking fails without lto on
Diffstat (limited to 'src')
-rw-r--r-- | src/gdt.cc | 18 | ||||
-rw-r--r-- | src/gdt.h | 6 | ||||
-rw-r--r-- | src/memory.cc | 5 |
3 files changed, 16 insertions, 13 deletions
@@ -14,9 +14,9 @@ constexpr uint32_t kseg_start = 0; constexpr uint32_t kseg_sz = 0xffffffff; __attribute__((section(".constinit"))) static GDT::SegmentDescriptor segments[256]{ - [GDT::null0] = seg::make<null_sz>(0, {}), - [GDT::kcode] = seg::make<kseg_sz>(kseg_start, {.r_w = true, .exe = true, .segment = true, .present = true}), - [GDT::kdata] = seg::make<kseg_sz>(kseg_start, {.r_w = true, .segment = true, .present = true}), + seg::make<null_sz>(0, {}), + seg::make<kseg_sz>(kseg_start, {.r_w = true, .exe = true, .segment = true, .present = true}), + seg::make<kseg_sz>(kseg_start, {.r_w = true, .segment = true, .present = true}), }; GDT::GDT() { @@ -24,23 +24,19 @@ GDT::GDT() { asm volatile("lgdt %0" : : "p"(gdtr)); // flush the segment registers - const auto cs = descriptor(kcode); - const auto ds = descriptor(kdata); + constexpr auto cs = GDT::descriptor(kcode); + constexpr auto ds = GDT::descriptor(kdata); asm volatile( - "jmp %0,$.reload_cs\n\t" // far jump takes cs + "jmpl %0,$.reload_cs\n\t" // far jump: cs,location ".reload_cs:\n\t" " mov %1, %%ds\n\t" // ds " mov %1, %%es\n\t" " mov %1, %%fs\n\t" " mov %1, %%gs\n\t" " mov %1, %%ss\n\t" ::"i"(cs), - "r"(ds)); + "rm"(ds)); printk("GDT installed at ", uhex{gdtr.base}, '\n'); } -uint16_t GDT::descriptor(GDT::SegmentMap i) const { - return static_cast<uint16_t>(reinterpret_cast<const uint32_t>(&segments[i]) - - reinterpret_cast<const uint32_t>(&segments)); -} @@ -95,11 +95,13 @@ public: unsigned int base_31_24 : 8 = 0; // high bits of segment address } __attribute__((packed)); - enum SegmentMap { null0, kcode, kdata }; + enum SegmentMap { null0 = 0, kcode = 1, kdata = 2 }; GDT(); ~GDT() = default; - uint16_t descriptor(SegmentMap) const; + static constexpr uint16_t descriptor(GDT::SegmentMap i) { + return static_cast<uint16_t>(i * sizeof(SegmentDescriptor)); + } }; diff --git a/src/memory.cc b/src/memory.cc index a2a2561..2d440a3 100644 --- a/src/memory.cc +++ b/src/memory.cc @@ -4,3 +4,8 @@ void operator delete(void*) { printk("Calling delete\n"); abort(); } + +extern "C" void __cxa_pure_virtual() { + printk("__cxa_pure_virtual\n"); + abort(); +} |