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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:53:26+00:00 2026-05-26T05:53:26+00:00

Why do assembly programs load segments ( .data / .bss and .text ) into

  • 0

Why do assembly programs load segments (.data/.bss and .text) into separate memory blocks instead of loading both the data and the code segments into a single memory block?

My guess is that the OS can then move the segments around or somehow optimize memory for the type of data stored. Thoughts?

  • 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-26T05:53:26+00:00Added an answer on May 26, 2026 at 5:53 am

    This is not limited to assembly programs, it’s how the executable format for your OS is laid out, and most OS’s have decided to have a rather extensive format for executables, separating various parts of a program into sections(“segments”).

    Separating an executable in various sections have several advantages, e.g. the ones you mention:

    .bss: Stores information about memory that needs to be zeroed at program startup. Memory that needs to be zeroed is common, and an OS typically have special services for handing out zeroed memory, and if you happen to allocate a global array of 1Mb, you don’t need to embed 1Mb of 0’s in the executable – you can just encode that information in the .bss section, and the OS will allocate that 1Mb at program startup.

    .data: This is all your data that’s initialized to something other than zero at program startup.

    .text: this is the actual code

    There’s can be many more sections, e.g. special sections containing bootstrap code that needs to run to initialize the program but can be discarded once it’s been run, or sections containing debug information(that doesn’t need to be loaded into memory unless you run the program in a debugger). Another common section is a readonly data section:

    .rodata: contains non-writable data, e.g. all the strings or const data in your program.

    Moreover, CPUs can apply protection to memory, such as readable/writable/executable memory. Having separate sections allows for easily applying these memory protection. E.g. the code needs to be executable, but having the data be executable might be a bad idea.
    Read only sections can also more easily be shared among other processes, the code and readonly memory sections can be shared between multiple instances of the program. If parts of the text section needed to be swapped out, they can just be discarded, as they already reside in the executable itself, whereas the data/bss sections cannot, they have to be swapped out to a special swap area.

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

Sidebar

Related Questions

How to include any assembly code lines into my C program ? In turbo
Could not load file or assembly 'System.Data' or one of its dependencies. An attempt
Heyo, My class at college has us writing programs in assembly. I have never
How can I see the assembly code for a C++ program? What are the
Here's the deal. I've got a program that will load a given assembly, parse
I got the following error when executing an unmanaged assembly: Could not load file
I am trying to do some experiments using different segments besides the default code
The exact error is as follows Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=9.0.242.0,
I'm having a difficult time trying to load System.Data.SQLite.dll from PowerShell in Windows 7
I created a C++/CLI assembly that creates a wrapper around native C++ code. The

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.