Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:19:18+00:00 2026-05-30T19:19:18+00:00

I am currently writing a simple bootloader as a personal project. I have a

  • 0

I am currently writing a simple bootloader as a personal project. I have a working prototype that was built using NASM as my assembler. However I would like to get more familiar with GNU tools, and so I am attempting to rewrite my work using them.

There is this small sample online ‘Hello World’ Bootloader that demonstrates the use of several tools for writing and building the ‘Bootloader’. However, after some reading, it is to my understanding that ‘gas’ is a backend to gcc, and that it should not be directly invoked. I came across this information when I was trying to write expressions inside my assembly file that used symbols to caclulate the size of the program so I would know how many 0 bytes I would have to write before writing 0x55, and 0xAA, which can be accomplished using this bit of NASM code:

;---------------------------------------------
; Write Zeros up to end of program - 2 then boot signature
;---------------------------------------------
size    equ     $ - entry
        times   (512 - size - 2) db 0
        db      0x55, 0xAA              ;2  byte boot signature

Is there a way to write this equivalent set of expressions using the syntax natively read by GAS? My attempts have failed, for example:

.size len, ( 512 - ( (message + 12) - _start) )

Using this expression and passing it to as gives me the following error:

./gasbootloader.asm:24: Error: invalid sections for operation on `message' and `_start'

Do I need to pass my program through gcc so the symbols can get resolved?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:19:19+00:00Added an answer on May 30, 2026 at 7:19 pm

    The GNU assembler has a .org directive which makes the math you had to do in NASM unnecessary. Here’s an example source file:

    entry:
      xor %eax, %eax
      ret
    
      .org 510
      .byte 0x55, 0xAA
    

    And a dump of the object file after building:

    $ clang -c -o example.o example.s
    $ otool -t example.o
    example.o:
    (__TEXT,__text) section
    0000000000000000 31 c0 c3 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    0000000000000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000001c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00000000000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa 
    

    As you can see, the 0x55 0xAA ends up where you want it to without any special effort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a simple FTP client (using C# and .NET). It's important that
I am currently writing a simple, timer-based mini app in C# that performs an
I have a relatively simple program that currently uses 1 thread (main). The application
I'm currently writing a simple client/server in Java using sockets. I want the server
I'm currently writing my own shell as a project for a class, and have
I'm currently writing a simple Python (2.7) program using the Python Image Library .
I'm currently writing a simple .sh script to parse an Exim log file for
I'm currently writing a very simple game engine for an assignment and to make
Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to
I'm currently writing a simple multicaster module. Only one process can open a proc

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.