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 8271665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:54:25+00:00 2026-06-08T06:54:25+00:00

I am in the process of writing a small operating system in C. I

  • 0

I am in the process of writing a small operating system in C. I have written a bootloader and I’m now trying to get a simple C file (the “kernel”) to compile with gcc:

int main(void) { return 0; }

I compile the file with the following command:

gcc kernel.c -o kernel.o -nostdlib -nostartfiles

I use the linker to create the final image using this command:

ld kernel.o -o kernel.bin -T linker.ld --oformat=binary

The contents of the linker.ld file are as follows:

SECTIONS
{
    . = 0x7e00;

    .text ALIGN (0x00) :
    {
        *(.text)
    }
}

(The bootloader loads the image at address 0x7e00.)

This seems to work quite well – ld produces a 128-byte file containing the following instructions in the first 11 bytes:

00000000 55                             push    ebp
00000001 48                             dec eax
00000002 89 E5                          mov ebp, esp
00000004 B8 00 00 00 00                 mov eax, 0x00000000
00000009 5D                             pop ebp
0000000A C3                             ret

However, I can’t figure out what the other 117 bytes are for. Disassembling them seems to produce a bunch of garbage that doesn’t make any sense. The existence of the additional bytes has me wondering if I’m doing something wrong.

Should I be concerned?

hexdump of the file

  • 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-06-08T06:54:26+00:00Added an answer on June 8, 2026 at 6:54 am

    These are additional sections, which were not stripped and not discarded. You want your linker.ld file to look like this:

    SECTIONS
    {
        . = 0x7e00;
    
        .text ALIGN (0x00) :
        {
            *(.text)
        }
    
        /DISCARD/ :
        {
            *(.comment)
            *(.eh_frame_hdr)
            *(.eh_frame)
        }
    }
    

    I know what sections to discard from the output of objdump -t kernel.o.

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

Sidebar

Related Questions

I'm in the process of writing a small text-editor that is supposed to have
I'm in the process of writing a small/basic CMS system using Symfony 1.4 and
I'm writing a small app that needs to have a super easy install process.
I'm writing a small file conversion utility. Files get automatically converted when they are
I am writing a small console app which have to overwrite a txt file
I am in the process of writing a small WordPress data sync plugin that
I'm in the process of writing a small lisp interpreter in haskell. In the
I'm in the process of writing a small overhead view RPG much in the
I am writing small process monitor script in Perl by reading values from Proc
I am in the process of writing a small javascript library to make form

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.