C++ Bare Bones: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
mNo edit summary |
mNo edit summary |
||
Line 7:
==Preface==
This tutorial assumes you have a compiler
To make starting an OS easy, we will be using a lot of existing parts
==Overview==
Line 43:
|}
Because there is no environment executing your kernel (you can't expect the bootloader to do this), you have to execute your own constructors (and possibly destructors). Both are described below. <!-- I think the following sentence distracts from the objective at hand. There is however discussion about whether executing the global destructors in your kernel makes any sense when you're shutting down (seeing as you're shutting the computer or OS down). It would probably be best to call these destructors only if you have specific object destructors that need to clean something up before the kernel is shut down (and you can't or don't want to explicitly call these).
The vague <!-- ?? Explain! --> linking sections should be split across multiple sections: you should put them in text, rodata, data and bss. You will need a linker script only later on, but to understand the other source, have a look at it now (tip: you can use 'i586-elf-ld --verbose' to see LD's standard linker script for comparison):
<pre>
Line 99:
The script might require modification to suit your kernel's needs. Note that forgetting to add the vague linking sections might result in GRUB randomly not being able to load your kernel anymore (e.g. after modifying the most trivial code). It might also explain sudden rises in executable size by 50 kB and other issues.
Note that the .ctor and .dtor sections need to be properly aligned. The linker script shown here does that by placing them at the beginning of the .rodata section, which is aligned at a page boundary.
==loader.s==
|