SECTIONS (C/C++)

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

Introduces a section of one or more definitions that are access specifiers on sections in your project's output file.

SECTIONS  
definitions  

Each definition must be on a separate line. The SECTIONS keyword can be on the same line as the first definition or on a preceding line. The .def file can contain one or more SECTIONS statements.

This SECTIONS statement sets attributes for one or more sections in the image file, and can be used to override the default attributes for each type of section.

The format for definitions is:

.section_name specifier

where .section_name is the name of a section in your program image and specifieris one or more of the following access modifiers:

ModifierDescription
EXECUTEThe section is executable
READAllows read operations on data
SHAREDShares the section among all processes that load the image
WRITEAllows write operations on data

Separate specifier names with a space. For example:

SECTIONS  
.rdata READ WRITE  

SECTIONS marks the beginning of a list of section definitions. Each definition must be on a separate line. The SECTIONS keyword can be on the same line as the first definition or on a preceding line. The .def file can contain one or more SECTIONS statements. The SEGMENTS keyword is supported as a synonym for SECTIONS.

Older versions of Visual C++ supported:

section [CLASS 'classname'] specifier  

The CLASS keyword is supported for compatibility, but is ignored.

An equivalent way to specify section attributes is with the /SECTION option.

Rules for Module-Definition Statements

Show: