OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:01 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: error compiling Multiboot 2 bootloader: expected relocatable
PostPosted: Tue Jul 26, 2022 8:02 am 
Offline

Joined: Wed Apr 01, 2020 1:43 am
Posts: 3
I am writing a bootloader with Multiboot2. I referenced the example code from the specification.

Code:
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.


Top
 Profile  
 
 Post subject: Re: error compiling Multiboot 2 bootloader: expected relocat
PostPosted: Tue Jul 26, 2022 8:22 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
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".


Top
 Profile  
 
 Post subject: Re: error compiling Multiboot 2 bootloader: expected relocat
PostPosted: Tue Jul 26, 2022 8:25 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Have you defined multiboot_header_end somewhere in the code that you don't show?


Top
 Profile  
 
 Post subject: Re: error compiling Multiboot 2 bootloader: expected relocat
PostPosted: Tue Jul 26, 2022 8:28 am 
Offline

Joined: Wed Apr 01, 2020 1:43 am
Posts: 3
Thanks everyone!


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot] and 57 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