### /SEGORDER Linker Option

Syntax: | Default:
/SEGO[RDER] /NOSEGO[RDER] |

Use /SEGORDER to change the default order in which the linker assigns sections to segments.

The linker keeps a list of sections that it encounters. Sections can be introduced to the linker by #pragma alloc_text, #pragma data_seg, or the /SECTION option. This list is maintained in the order the sections were encountered.

If /SEGORDER is in effect, the list is sorted as follows before assigning segments.

1. All executable sections are moved to the beginning of the list.
2. If building for OS/2 and the total size of the executable sections approaches 64K and the section _MSGSEG32 is present, it will be assigned as the only section in the first segment. This avoids a problem with DosGetMessage() in Warp Version 2 and Version 3 prior to Fixpack17.
3. All DGROUP sections are moved to the end of the list.
   Within DGROUP, sections are ordered as: BEGDATA, others, BSS, and STACK.
4. All non-writable data sections are moved earlier to follow the code sections.
5. The remaining non-executable sections before DGROUP are further sorted to minimize the number of segments that will be produced.

Within a segment, sections will maintain their initial order relative to one another.

The linker now traverses the section list assigning adjacent, compatible sections to the same segment. When a section with incompatible attributes is encountered, a new segment is started using the new attributes.

Section groups introduce one more complexity to this process: grouped sections will be adjacent and are assigned to the same segment regardless of attribute conflicts.

Summary of Linker Options