flat assembler
Message board for the users of flat assembler.

Index > Main > resulting binary size is weird

Author
Thread Post new topic Reply to topic
gens



Joined: 18 Feb 2013
Posts: 161
gens 22 Sep 2014, 10:42
i have a project with lots of included code (data and macros)
format is elf64 using import64.inc

in one of the includes is

PLY_BUFFSIZE equ 1024*1024*100
ply_buffer: rb PLY_BUFFSIZE

a 100MB piece of memory

if i list all the includes in one order the binary will be over 100MB (as expected)
but if i include in another order the binary will be 22kB
and it will work

data from includes goes in "segment readable writeable" at the start of the binary

in curious why the smaller version works
Post 22 Sep 2014, 10:42
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 22 Sep 2014, 11:16
The "R" in "RB" stands for "reserved". If it appears at the end of the data section it will be initialized at runtime, however, when there is defined data after it, this forces it to be initialized at compile time.

Code:
;;2 bytes compiled
rb 1
db 'h'
    


Code:
;;1 byte compiled
db 'h'
rb 1
    
Post 22 Sep 2014, 11:16
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens 22 Sep 2014, 18:04
nice explained, thx

hmm
i have 15 includes
6'th is ply.inc where that 100MB reserve is defined
model.inc is last and is where a macro defined in ply.inc is used
thou the reserved memory declaration is separate from the macro

so ply.inc is 6'th and there are plenty of db, dd, dq and such in includes after it but fasm still puts it last and makes a 22k binary
but if i put model.inc as anything but last it will be 100MB, even thou the data is separate from the macro

i thought includes are flat too Smile
Post 22 Sep 2014, 18:04
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 22 Sep 2014, 18:45
I guess it is depending on sections.
If following includes are only code this would maybe not affect the data section.
Post 22 Sep 2014, 18:45
View user's profile Send private message Send e-mail Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens 22 Sep 2014, 20:20
almost all of them are

-------------
data
-------------
macros
-------------

so when i include them in a readable/writeable section i get the data there and macros where ever i use them
Post 22 Sep 2014, 20:20
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.