Zig Bare Bones: Difference between revisions

m
no edit summary
[unchecked revision][unchecked revision]
mNo edit summary
mNo edit summary
Line 220:
 
=== src/linker.ld ===
A [[linker script]] is also needed. This file tells the linker to place our code at the base address of 1M. In general user-space programming, code are placed at much higher areas, but that requires [[virtual memory]] to be available, or else only few computers could provide such a large physical memory space.
<syntaxhighlight>
 
We also asks the linker to place <code>.multiboot</code> section at first, because the Multiboot specification says that the Multiboot header must be at the first 8KiB of the kernel file.<syntaxhighlight>
ENTRY(_start)
Line 250 ⟶ 252:
 
=== src/grub.cfg ===
Finally, the last thing you need is a GRUB configuration, which tells the GRUB bootloader how to boot our kernel.
<syntaxhighlight lang="unixconfig">
 
<code>menuentry</code> adds a menu entry to the screen. When you press ENTER in the GRUB menu, GRUB will run the commands in the menu block.
 
<code>multiboot</code> asks GRUB to load our kernel from <code>/boot/kernel.elf</code>, and GRUB automatically runs <code>boot</code> after the menu block, which will fire the boot.<syntaxhighlight lang="unixconfig">
menuentry "Zig Bare Bones" {
multiboot /boot/kernel.elf
Line 257 ⟶ 263:
 
== Build ==
Now that our kernel code is done, we'll now build our kernel by running the command below:
the command below:
 
<syntaxhighlight lang="bash">