1

Im learning C++ Operating System Development.

And i have 2 file in my OS Project: boot.asm kernel.cpp

this is code for boot.asm

[bits 32] ; hey, we're in Protected Mode

[global start]
[extern _kernel] ; always add a "_" in front of a C function to call it

start:
  call _kernel
  jmp $

And this is for kernel.cpp

void kernel()
{

}

But when i build the assembly boot file to .bin with this command: nasm boot.asm -f bin -o boot.bin

so i can test with qemu,i get this error: boot.asm:7: error: binary output format does not support external references Line 7:

call _kernel

so i tried the build command to these: nasm -felf boot.asm -o boot.bin or nasm -felf32 boot.asm -o boot.bin

its worked,but when i execute the .bin with qemu,i get this result: enter image description here

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
ELEMENTAL
  • 11
  • 2
  • 1
    An ELF file is a relocatable [object file](https://stackoverflow.com/questions/7718299/whats-an-object-file-in-c), not a bootable binary. You have to link it with the object file generated from the C++ source file. – Nate Eldredge Apr 28 '21 at 05:33

0 Answers0