I've noticed a minor issue with data sections.
FASM sets the "initialized" data bit if there are any initialized
data objects in a section, it also sets the "uninitialized" attribute
if there are any uninitialized data objects in a section.
This invariably generates a warning in the linker if both kinds
of data objects appear in the same section.
At the very least, the attributes should be mutually exclusive.
If there is at least one initialized data object in a section, then
the section should have the "initialized" attribute and it should *not*
have the uninitialized attribute. A section should only have the
uninitialized attribute if *all* data objects in that section are
uninitialized.

I'd probably take it one step farther and use the <data> tag
on the section directive to force the initialized attribute, even if
all the objects in the section are uninitialized.

Cheers,
Randy Hyde
Posted on 2003-02-01 14:32:20 by rhyde
FASM sets the "initialized data" bit only if you specify it with "data" operator in the section declaration. And the "uninitialized data" bit is set only when section has the physical size of zero and non-zero virtual size, that is when section contains only unitialized data. After your post I've checked for possibility I've got some bug there, but it seems everything works OK.
BTW: It reminds me that I should put it into FAQ.
Posted on 2003-02-01 15:14:40 by Tomasz Grysztar

FASM sets the "initialized data" bit only if you specify it with "data" operator in the section declaration. And the "uninitialized data" bit is set only when section has the physical size of zero and non-zero virtual size, that is when section contains only unitialized data. After your post I've checked for possibility I've got some bug there, but it seems everything works OK.
BTW: It reminds me that I should put it into FAQ.


Yeah, my problem was that the compiler is emitting the following


.section '.data' data readable writeable
extrn a:dword
extrn b:dword

.section ....


So it sees the section as an uninitialized data section (I guess).
I tried the following, but it didn't seem to help:

.section '.data' data readable writeable
_origin_ = $
.
.
.
if _origin_ eq $
dd 0
end if

When I get a chance, I'll dig deeper and post some minimalist
sample code that exhibits my problem.
Randy Hyde
Posted on 2003-02-03 21:06:26 by rhyde

_origin_ = $
.
.
.
if _origin_ eq $
dd 0
end if

It doesn't work, because it's always false. And if you did it this way:


_origin_ equ $
...
if _origin_ eq $
dd 0
end if

it'd be always true (it uses symbolic constant and symbolic comparision then). To make it actually work,you should use numerical constant and numerical comparision:


_origin_ = $
...
if _origin_ = $
dd 0
end if
Posted on 2003-02-04 00:58:43 by Tomasz Grysztar
But generally you shouldn't declare section if you put only EXTRNs in it - because they are section-indepented and the zero-length sections should be avoided (I heard some linkers have problems with them).
Posted on 2003-02-04 02:10:53 by Tomasz Grysztar