error compiling Multiboot 2 bootloader: expected relocatable

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
xtex
Posts: 4
Joined: Wed Apr 01, 2020 1:43 am
Contact:

error compiling Multiboot 2 bootloader: expected relocatable

Post by xtex »

I am writing a bootloader with Multiboot2. I referenced the example code from the specification.

Code: Select all

multiboot_header: // Multiboot Header
    .long   MULTIBOOT2_HEADER_MAGIC
    .long   MULTIBOOT_ARCHITECTURE_I386
    .long   multiboot_header_end - multiboot_header
    .long   -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
When I am trying to compile it with clang, a error happened on the last line: "error: expected relocatable expression"

Is there any way to solve it?

Thanks.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: error compiling Multiboot 2 bootloader: expected relocat

Post by Octocontrabass »

That error happens when Clang doesn't know the numeric value of one or more of the labels in that line. That can happen if you've made a mistake in copying the code, or if you're trying to assemble it without the C preprocessor.

Make sure your file has the correct extension. It must be ".S" or ".sx", not ".s".
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: error compiling Multiboot 2 bootloader: expected relocat

Post by iansjack »

Have you defined multiboot_header_end somewhere in the code that you don't show?
xtex
Posts: 4
Joined: Wed Apr 01, 2020 1:43 am
Contact:

Re: error compiling Multiboot 2 bootloader: expected relocat

Post by xtex »

Thanks everyone!
Post Reply