Weird issues when migrating from custom bootloader to GRUB

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
lochyj
Posts: 10
Joined: Fri Nov 11, 2022 10:28 pm

Weird issues when migrating from custom bootloader to GRUB

Post by lochyj »

I am having trouble migrating my OS from a custom boot loader to GRUB. When i load up the ISO file in QEMU, GRUB loads perfectly fine but when i enter into my OS it boots from the DVD/CD and then just loads up GRUB again (image attached). Due to the output of my linker, i feel as if the linker may be the problem.

I tested loading another, more basic os/kernel i made into GRUB, and it works perfectly fine so i feel confident that it isnt NASM or GCC or grub-mkrescue

I also tried only loading just the main function with the boot asm, nothing else, and it still doesn't work...

Compiling with arch on WSL with gcc, nasm and grub-mkrescue; running with QEMU as cdrom.

Repo: https://github.com/lochyj/OS

Sorry is this is a really simple solution, i am just getting into OSDev and i dont really know that much. Thanks in advance!

Build output:

Code: Select all

ld: ./out/boot.out: warning: relocation in read-only section `.text'
ld: warning: creating DT_TEXTREL in a shared object

xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:./out/image/BlinkOS.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data,  175g free
Added to ISO image: directory '/'='/tmp/grub.FqJ8ew'
xorriso : UPDATE :     976 files added in 1 seconds
Added to ISO image: directory '/'='/mnt/c/Users/me/OS/isodir'
xorriso : UPDATE :     980 files added in 1 seconds
xorriso : NOTE : Copying to System Area: 512 bytes from file '/usr/lib/grub/i386-pc/boot_hybrid.img'
xorriso : UPDATE :  73.80% done
ISO image produced: 13398 sectors
Written to medium : 13398 sectors at LBA 0
Writing to 'stdio:./out/image/BlinkOS.iso' completed successfully.
Attachments
Capture.PNG
Capture.PNG
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Weird issues when migrating from custom bootloader to GR

Post by klange »

It looks like you’re trying to build a shared object, but a multiboot kernel should be an executable.
lochyj
Posts: 10
Joined: Fri Nov 11, 2022 10:28 pm

Re: Weird issues when migrating from custom bootloader to GR

Post by lochyj »

Thanks for the help, removing the -shared flag fixed my issue. It however, caused more issues with the actual OS itself, but ill fix that myself. Thanks!
Post Reply