When a linker or linking assembler needs to set the Characteristics (AKA Object Flags) of a section in PE header, it usually decides by the section name only. For instance, the section .text is granted Executable and Readable flag, section .bss is flagged Readable and Writable.
I want to let the user explicitly set what access flags should be given to a section at the moment of its declaration.

Which name would you recomend for the section attribute, which tells if the section contains code, initialized data or uninitialized data? Class is good but already occupied. What else?
Domain? Realm? Kind? Usage? Purpose?
Posted on 2004-01-29 05:05:18 by vit$oft
Afternoon, vit$oft.

How about:


#SECTION ".code" READABLE | EXECUTABLE


After the first time a sections name is used (i.e. ".data"), every other time the programmer wants to place stuff into that section (code/data/whatever) they wouldn't have to reenter the sections attributes. The Assembler would already know what those attributes are, after the first use of #SECTION.

Cheers,
Scronty
Posted on 2004-01-29 05:36:58 by Scronty
vit$oft, afaik the section flags are set at compile/assemble time, not link-time - assemblers like masm set section flags from the easy-section-declaration stuff like ".data" and ".code" etc. You can get more control if you declare the sections explicitly, bitRAKE has posted how to do this more than once on the board. You might want to look at how masm does it.

I like your idea, scronty... I'd probably do it something like


#SECTION("name", align, flags)

since I like C syntax :). But definitely having the name in quotes, and be able to specify alignment and flags is a good thing.
Posted on 2004-01-29 06:49:31 by f0dder
If syntax with ordinal operands were used, one would always had to count the separating commas and feed the function with fixed number of operands. I prefer syntax with keyword operands in arbitrary order, all defaulting to a reasonable value when omitted. At the moment, I have this syntax for segment declaration:


[SegName] SEGMENT ALIGN=DWORD,WIDTH=32,CLASS='stack', \
COMBINE=PUBLIC,???=BSS

Using a statement with only the segment name in square brackets will switch to the above declared segment.
My problem is linguistic rather than conceptual. Which name should I use for the ??? attribute with possible values BSS, CODE or DATA ?

Scronty's idea of separate setting access flags is not bad but it doesn't tell much about the nature of the segment.
Posted on 2004-01-30 12:22:41 by vit$oft
Hrm, shouldn't CLASS be used for this? I assume "???" would only be BSS or INITIALIZED?
Posted on 2004-01-30 16:21:22 by f0dder
The segment attribute CLASS is used to control segment ordering at link time. Its value is a arbitrary quoted 'name', not limited to 'stack' or 'bss', as examples imply. TASM2 doc says: All segments of a given class (=with identical 'classname') are placed in a contiguous block of memory, no matter what their order is in the source code.

I guess the properties CLASS, COMBINE, DGROUP is legacy from verbose designers of 16bit linkers . My ??? attribute serves for 32bit segments mostly and it is meant to be something different: it's enumerated value will be used

    [*] for setting COFF section access flags,
    [*] to select alignment stuff byte (0x90 in CODE, 0x00 otherwise)
    [*] to warn the user when emiting initialized data to BSS and vice versa
Posted on 2004-02-02 11:21:46 by vit$oft
MASM also allows a GROUP directive to cluster segments.

Maybe, change the current CLASS to be instead like GROUP, then CLASS will serve your purpose?

Example:

aCODE SEGMENT
aCODE ENDS

bCODE SEGMENT
bCODE ENDS

text GROUP aCODE,bCODE
Posted on 2004-02-02 22:23:44 by bitRAKE
Yes, overloading the CLASS property is one of the possibility. Is there any reason for having more than one PE section of each class in a 32bit executable? Each additional section occupies some file-alignment space in EXE image and increases the load time, so I think the answer is negative but I may be wrong.

Nevertheless, still I wonder which name (other than CLASS) would native English speaker give to this attribute.
Posted on 2004-02-03 11:24:22 by vit$oft