flat assembler
Message board for the users of flat assembler.

Index > Windows > Recommended section flags for MS COFF

Author
Thread Post new topic Reply to topic
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 25 Jun 2018, 06:56
What is the recommended section flags for a statically-linked MS COFF format that works seamlessly in almost all situations?

Code:
section '.text' executable
section '.text' readable executable
section '.text' code readable executable    


For some reasons, certain linkers complain of inconsistent sections configurations. The third line seems to be acceptable by LINK without any warnings. But still, not very sure and haven't tested against other linkers.

Thanks for advises.
Post 25 Jun 2018, 06:56
View user's profile Send private message Visit poster's website Reply with quote
donn



Joined: 05 Mar 2010
Posts: 321
donn 26 Jun 2018, 04:58
Yeah, I've seen the COFF Linker warnings about inconsistent attributes also.

Vid's Mixing assembly with MS Visual C, available in the fasm downloads page, has been very instructive for me and uses your third option:

Code:
section '.text' code readable executable    


It also has a data example:

Code:
section '.data' data readable writeable    


The example is MS COFF 32, not 64. I would assume a writeable '.text' section is used when the instructions are re-written. I've been self-modifying instructions quite heavily lately but don't remember seeing problems without this flag. I have the writeable flag included now, though, along with align 16.

The MS COFF specs have a lot details such as flag binary values and say the number of sections can be variable though the loader limits the section count to 96.

A similar fasm thread that goes a little deeper here.
Post 26 Jun 2018, 04:58
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 26 Jun 2018, 06:18
Thanks for the clarifications and links, donn.

Seems that the safest option for me (for now) is to use full similar section flags as the PE (the third one), since IMO, most MS services (kernel, msvcrt) use similar section control flags.
Post 26 Jun 2018, 06:18
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.