6.2 COFF Output Format

Asmc Macro Assembler

6.2 COFF Output Format

The COFF object module format is suitable for flat, non-segmented memory models. In most cases the COFF format is used for 32-bit code. However, it's possible to create a 64-bit COFF module if the current cpu is .x64 when the .MODEL directive is parsed ( note that -win64 is the usual way to create modules for 64-bit Windows ). To some extent 16-bit code is also supported with COFF, although OMF will always be the better choice then.

  • The -safeseh cmdline option and the .SAFESEH directive are supported by COFF only.
  • Not supported by COFF are:
    • the GROUP directive
    • the directives to control segment order: .ALPHA, .DOSSEG, .SEQ
    • code that will generate "far" fixups (i.e. direct FAR calls or jumps ).
  • A few, common segment names are translated in the output module when COFF is selected:
    • name _TEXT is translated to .text
    • name _DATA is translated to .data
    • name CONST is translated to .rdata
    • name _BSS is translated to .bss
    This also affects simplified segment directives, since _TEXT, _DATA, CONST and _BSS segments are internally generated when directives .CODE, .DATA, .CONST or .DATA? are detected.
  • If COFF is selected, Masm will ignore segment combine type STACK and treat stack segments just like normal data segments ( the MS linker and compatibles will set the stack's size with commandline options ). JWasm DOES NOT ignore combine type STACK for the COFF output format; additionally, unless the segment contains initialized data, JWasm will reset the size of stack segments to 0.
  • Directive EXTERN name (altname) : <type> will define a weak external with characteristics IMAGE_WEAK_EXTERN_SEARCH_LIBRARY ( see MS PE and COFF specification ).
  • Directive ALIAS <aliasname>=<actual name> will define a weak external with characteristics IMAGE_WEAK_EXTERN_SEARCH_ALIAS ( see MS PE and COFF specification ).
  • There are some cmdline options to control the extent of symbols that are written to the COFF output module: -zlf, -zlp and -zls.