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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:59:26+00:00 2026-06-15T18:59:26+00:00

For program from http://bellard.org/mersenne.html GCC produces ~130MB executable. Why?

  • 0

For program from http://bellard.org/mersenne.html GCC produces ~130MB executable. Why?

  • 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-15T18:59:27+00:00Added an answer on June 15, 2026 at 6:59 pm

    Try changing t[1<<25]={2} to t[1<<25] and the size of the *executable** will drop down to 7.3 K. (Needless to say, you won’t get the right results)

    If it was just t[1<<25], it wouldn’t have taken any space at all.

    The catch here is that the array is being initialized (first element=2, the next 2^25-1 elements all 0), and the global array gets placed in the data segment only because it is initialized.


    Generating the assembly for the 2 versions and examining the difference makes it even more clear:

    [axiom@axiom ~]$ diff without_mem.s with_mem.s 
    15c15,21
    <   .comm   t,134217728,32
    ---
    >   .globl  t
    >   .align 32
    >   .type   t, @object
    >   .size   t, 134217728
    > t:                                ***<- HERE!***
    >   .long   2                
    >   .zero   134217724
    

    As we can notice, in the original version, the assembler is directed to generate 2^27 (134217728 ) bytes in the data segment. So it becomes a part of the object file itself. ( You can generate assembly by compiling with -S switch gcc -S -fverbose-asm t1.c)


    But why 129 MBs?

       1<< n= 2^n (1 left shifted n times). 
     =>  1<<25=2^25. 
         now 1 Integer= 4 bytes =2^2 bytes 
     => 2^25 Integers=2^27 bytes=2^7 * 1 M bytes= 128 MBs 
        

    For more details, see :

    • Related
      Question
      .
    • Wiki page on data
      segment
    • Reading ia32 Assembly

    *Note 1: It is an object file in strict terms.

    Note 2: As pointed out in the comments, It may also be noted that the total size of the process (program in execution) will be 129Mb even if the executable is of 7.3K. (The memory will be allocated once the program starts executing). You can see the memory usage of your program by using the top command.

    Note 3: It is worth emphasizing that this holds only because t is global. Allocation for data local to a function still happens at runtime on the stack. So if t was local, the object file would’ve taken 7.3K only.

    Note 4: Initialized static local variables, like initialized globals, are also kept in the data segment. A static global is same as a global except that you are limiting the scope of the variable to the current file only.

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

Sidebar

Related Questions

I'am trying to understand the example from program_options of the boost library ( http://www.boost.org/doc/libs/1_38_0/doc/html/program_options/tutorial.html#id3761458
We have installed RHQ monitoring system http://rhq-project.org/display/RHQ/Home . From that time our program started
I am trying with program code from http://liboauth.sourceforge.net/tests_2oauthexample_8c-example.html but every time I am getting
From http://pubs.opengroup.org/onlinepubs/009604599/functions/pipe.html : The pipe() function shall create a pipe and place two file
I am trying to make the buffer exploitation example (example3.c from http://insecure.org/stf/smashstack.html ) work
I downloaded the wget program from http://ftp.gnu.org/gnu/wget/ , and installed it using ./configure; make;
I've read upstream program from here ... http://xunitpatterns.com/Back%20Door%20Manipulation.html If the data store is external
I am trying to run the program from http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf61c8a-7ff4.html I am using Adbobe builder
Code first: '''this is main structure of my program''' from twisted.web import http from
I download FFMPEG from http://www.videohelp.com/tools/ffmpeg#download and saved it in my c:\program files\ffmpeg (Windows Vista).

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.