OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 2:56 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GRUB Error 13, can't statically link either
PostPosted: Thu Jul 20, 2023 4:32 am 
Offline

Joined: Thu Jul 20, 2023 4:16 am
Posts: 1
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 :)


Top
 Profile  
 
 Post subject: Re: GRUB Error 13, can't statically link either
PostPosted: Thu Jul 20, 2023 8:37 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
milkcool wrote:
What am I doing wrong?

  • Following a tutorial
  • Trying to include standard C libraries
  • Not switching to 64-bit mode

Most tutorials focused on or around OS development have mistakes. Usually the author is a beginner like you, documenting their process as they go, including their mistakes that they haven't noticed yet. Most tutorial authors give up before they reach the point where they could go back and correct their mistakes.

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.


Top
 Profile  
 
 Post subject: Re: GRUB Error 13, can't statically link either
PostPosted: Fri Jul 21, 2023 1:32 am 
Offline
Member
Member

Joined: Mon Jul 05, 2021 6:57 pm
Posts: 118
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 45 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group