Program size, linking matter, and static this()
Walter Bright
newshound2 at digitalmars.com
Wed Jan 18 02:18:32 PST 2012
On 1/18/2012 1:43 AM, Marco Leise wrote:
> It is back again! The following struct in my main module increases the
> executable size by 10MB with DMD 2.075:
>
> struct Test {
> byte abcd[10 * 1024 * 1024];
> }
Compiling it and obj2asm'ing the result, and you'll see it goes into the BSS
segment:
_TEXT segment dword use32 public 'CODE' ;size is 0
_TEXT ends
_DATA segment para use32 public 'DATA' ;size is 12
_DATA ends
CONST segment para use32 public 'CONST' ;size is 0
CONST ends
_BSS segment para use32 public 'BSS' ;size is 10485760
_BSS ends
FLAT group
extrn _D19TypeInfo_S3foo4Test6__initZ
public _D3foo4Test6__initZ
FMB segment dword use32 public 'DATA' ;size is 0
FMB ends
FM segment dword use32 public 'DATA' ;size is 4
FM ends
FME segment dword use32 public 'DATA' ;size is 0
FME ends
extrn _D15TypeInfo_Struct6__vtblZ
public _D3foo12__ModuleInfoZ
_D19TypeInfo_S3foo4Test6__initZ COMDAT flags=x0 attr=x10 align=x0
_TEXT segment
assume CS:_TEXT
_TEXT ends
_DATA segment
_D3foo12__ModuleInfoZ:
db 004h,000h,000h,0ffffff80h,000h,000h,000h,000h ;........
db 066h,06fh,06fh,000h ;foo.
_DATA ends
CONST segment
CONST ends
_BSS segment
_BSS ends
FMB segment
FMB ends
FM segment
dd offset FLAT:_D3foo12__ModuleInfoZ
FM ends
FME segment
FME ends
_D19TypeInfo_S3foo4Test6__initZ comdat
dd offset FLAT:_D15TypeInfo_Struct6__vtblZ
db 000h,000h,000h,000h ;....
db 008h,000h,000h,000h ;....
dd offset FLAT:_D19TypeInfo_S3foo4Test6__initZ[03Ch]
db 000h,000h,0ffffffa0h,000h,000h,000h,000h,000h ;........
db 000h,000h,000h,000h,000h,000h,000h,000h ;........
db 000h,000h,000h,000h,000h,000h,000h,000h ;........
db 000h,000h,000h,000h,000h,000h,000h,000h ;........
db 000h,000h,000h,000h,000h,000h,000h,000h ;........
db 001h,000h,000h,000h,066h,06fh,06fh,02eh ;....foo.
db 054h,065h,073h,074h,000h ;Test.
_D19TypeInfo_S3foo4Test6__initZ ends
end
-------------------------------------------------
Adding a void main(){} yields an executable of 145,948 bytes.
More information about the Digitalmars-d
mailing list