Pelles C forum

Assembly language => Assembly discussions => Topic started by: HellOfMice on February 07, 2025, 09:13:30 AM

Title: Some Stats
Post by: HellOfMice on February 07, 2025, 09:13:30 AM
Hello,

I had some free time, no biathlon on TV, time this morning so I made this:

File sqlite3.dll
Size on disk 788 Kb


File sqlite3.dll
Size on disk 788 Kb
                                                            DATA DIRECTORIES      SECTIONS       D / S %
Export Directory                            .rdata               7 036             104 028        6.76 %
Import Directory                            .data                   40              27 712        0.14 %
Resource Directory                          .rsrc                1 264               1 264      100.00 %
Exception Directory                         .pdata              21 204              21 204      100.00 %
Security Directory
Base Relocation Table                       .reloc               6 772               6 772      100.00 %
Debug Directory
Architecture Specific Data
Global Pointer Register
Thread Local Storage Directory (TLS)
Load Configuration Directory
Bound Import Directory
Import Address Table (IAT)                  .data                  872              27 712        3.14 %
Delay Load Import Descriptors
COM Runtime Descriptor
Reserved
".text" section                                                                    647 942        0.00 %
TOTAL                                                           37 188             808 922        4.59 %

Compare file size and sections size
                   File Size = 788.00 Kb
Sections Size 808 922 / 1024 = 789.96 Kb


The file size is equal to the sections total sizeSome sections store many data directoriesExcept ".text" and ".data", the directory data ".rdata" occupies a small part of the ".rdata" section.What does contain this section?
Title: Re: Some Stats
Post by: TimoVJL on February 07, 2025, 09:29:54 AM
.rdata is read only data section.
Title: Re: Some Stats
Post by: HellOfMice on February 07, 2025, 10:03:14 AM
Timo, I will see that but a last question:
We cannot see if there is a BSS. I don't know program without it.

Title: Re: Some Stats
Post by: TimoVJL on February 07, 2025, 10:17:01 AM
BSS can go to .data section and then raw size and virtual size differs

Borland and gcc might use BSS section
Title: Re: Some Stats
Post by: HellOfMice on February 07, 2025, 11:10:40 AM
When we have a ".Data?" segment it is a BSS and an empty Variable in C it also is in BSS
I would like to know the difference between a COMM variable and a variable declare in ".Data?"?
It it the same?
Title: Re: Some Stats
Post by: Vortex on May 22, 2025, 08:59:04 PM
Reading Pelle's manual :

QuoteThe COMM directive declares name as a communal symbol with the size of either a type or a constant expression. An optional naming convention may be specified for the name.

Communal symbols will be assigned storage space at link time, unless it has been explicitly defined in a module. The memory space may not be assigned until load time, so using communal symbols may reduce the size of the executable.

Examples:
COMM BuffSize:256
COMM MaxInt:DWORD
COMM Var1:DWORD, Var2:MYSTRUCT
Title: Re: Some Stats
Post by: Vortex on May 25, 2025, 12:44:28 PM
A quick example :

.386
.model flat,stdcall
option casemap:none

COMM CommVar:DWORD

END

.386
.model flat,stdcall
option casemap:none

includelib  \PellesC\Lib\Win\kernel32.lib
includelib  \PellesC\Lib\Win\user32.lib
includelib   msvcrt.lib

EXTERN CommVar:DWORD

printf PROTO C :DWORD,:VARARG
ExitProcess PROTO :DWORD

.data

msg db 'COMM variable = %u',0

.code

start:

    mov     CommVar,256
    invoke  printf,ADDR msg,CommVar

    invoke  ExitProcess,0

END start