-
Welcome back. I have a bootloader written in assembly language. And I wonder how to connect this to the kernel. I was browsing the files in the target folder and came across a file called "blog_os" in the path: ./target/x86_64-blog_os/debug/blog_os. I also noticed that every time qemu starts up, it starts the botimage-blog_os file. The bootimage-blog_os file has a bootloader provided because it is bootable. If I'm right when I use cargo objcopy to create blog_os.bin from blog_os and attach my bootloader to it, it should work. I'd like to know what you @phil-opp think. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
@phil-opp Recently you advised me to connect my bootloader to the system I have to compile it as static lib when I do this then you can't do anything about it. Neither use cargo objcopy nor anything else. |
Beta Was this translation helpful? Give feedback.
-
It's difficult to answer your question in general since it depends on your bootloader implementation and your build environment (e.g. Windows or Linux). You normally have two options:
If you're interested in details, I recommend reading the code of the |
Beta Was this translation helpful? Give feedback.
-
@phil-opp What's wrong with this command ld -n --gc-sections -T /src/arch/x86_64/linker.ld -o kernel.bin \
/build/arch/x86_64/boot.o \
/build/arch/x86_64/long_mode_init.o \
/build/arch/x86_64/multiboot_header.o \
/target/x86_64-blog_os/debug/libblog_os.a I mean the path to linker.ld |
Beta Was this translation helpful? Give feedback.
It's difficult to answer your question in general since it depends on your bootloader implementation and your build environment (e.g. Windows or Linux). You normally have two options:
Link your kernel directly with the bootloader by compiling at as a staticlib.
This requires that you use the same file types for the bootloader and kernel. If you're using Linux, you can just link the resulting
.a
staticlib with your other ELF object files. If you're using Windows, you probably need to compile your kernel as a Windows-compatible staticlib by modifying your target JSON file. I've never tried this, so I can't help you with it unfortunately.Build the kernel as a separate executable and loa…