Hello everyone! I'm new to os development also new to this forum. I've tried everything I could find online, but couldn't succeed.
When I'm compiling, linking and booting my OS GRUB gives me the error 13. I am trying to follow this tutorial https://hasinisama.medium.com/building- ... 6425adb084 (this is the 2nd part), but I'm trying to include standard C libraries as well as trying to make the system 64 bit.
kernel/main.c: https://pastebin.com/ceQjSGnJ
loader.s: https://pastebin.com/PUYi48Ve
Makefile: https://pastebin.com/GyHjPDmd
link.ld: https://pastebin.com/2qxCebER
What am I doing wrong? Thanks in advance
GRUB Error 13, can't statically link either
-
- Member
- Posts: 5560
- Joined: Mon Mar 25, 2013 7:01 pm
Re: GRUB Error 13, can't statically link either
milkcool wrote:What am I doing wrong?
- Following a tutorial
- Trying to include standard C libraries
- Not switching to 64-bit mode
Standard C libraries depend on an OS. You're trying to include standard C libraries designed to run on Linux. Your OS is not compatible with Linux (for now), so the Linux C libraries won't work. You can use freestanding C headers; those don't depend on an OS.
Multiboot says the CPU starts in 32-bit mode. You have to switch the CPU into 64-bit mode before you can run 64-bit code. Switching to 64-bit mode is not exactly simple; you need to set up a GDT and some page tables, and mess with a handful of control registers. If you really want to write a 64-bit OS, you might have an easier time if you use a bootloader that can handle switching to 64-bit mode (such as Limine). You'll still need to set up a GDT and some page tables eventually, but then you can put it off until you're more familiar with x86.
Re: GRUB Error 13, can't statically link either
You cannot use a system C library, designed to work in programs running in user space under a particular kernel, in your own kernel which does not run under that kernel.