/SECTION (Windows CE 5.0)

Send Feedback

This option changes the attributes of a section, overriding the attributes set when the .obj file for the section was compiled.

/SECTION:name,[E][C][I][R][W][S][D][K][L][P][X]

Remarks

A section in a portable executable (PE) file is roughly equivalent to a segment or the resources in a new executable (NE) file. Sections contain either code or data.

Unlike segments, sections are blocks of contiguous memory with no size constraints.

Some sections contain code or data that your program declared and uses directly, while other data sections are created for you by the linker and librarian and contain information vital to the operating system.

Specify a colon (:) and a section name. The name is case sensitive.

Do not use the following names, as they will conflict with standard names. For example, .sdata is used on RISC hardware platforms:

  • .arch
  • .bss
  • .data
  • .edata
  • .idata
  • .pdata
  • .rdata
  • .reloc
  • .rsrc
  • .sbss
  • .sdata
  • .srdata
  • .text
  • .xdata

Specify one or more attributes for the section. The attribute characters, listed below, are not case sensitive.

You must specify all attributes that you want the section to have; an omitted attribute character causes that attribute bit to be turned off. If you do not specify R, W, or E, the existing read, write, and executable status remains unchanged.

The meanings of the attribute characters are as follows.

Character Attribute Meaning
E Execute Allows code to be executed.
C Conforming Marks the section as conforming.
I IOPL Marks the section as IOPL.
R Read Allows read operations on data.
W Write Allows write operations on data.
S Shared Shares the section among all processes that load the image.
D Discardable Marks the section as discardable.
K Cacheable Marks the section as cacheable.

Caching is on by default. This flag is used in the negative as !K. To remove the default and reveal section characteristics including caching status, use

/SECTION:.text,!K
L Preload VxD only; marks the section as preload.
P Pageable Marks the section as pageable.

This flag is used in the negative. For example, to remove the default and mark a section as not pageable, use !P as follows

/SECTION:.text,!P
X Memory-resident VxD only; marks the section as memory-resident.

A section in the PE file that does not have E, R, or W set is probably invalid.

You can also use the exclamation point, "!", to negate the paging option, P. The following code segment shows how to mark a code segment non-pageable by enclosing it in pragmas

#pragma comment(linker, "/section:.no_page,ER!P")
#pragma code_seg(push, ".no_page")
// 
// Insert any NON-PAGEABLE CODE, such as 
//        code needed during suspend, resume or shutdown
//        ISTs
//        code used during paging
//        code called by non-pageable code
// ...
#pragma code_seg(pop)

Do not use any ROM strings in non-pageable code since they go into a separate data section.

See Also

Linker Options

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.