Difference between “section” and “segment” in NASM

From the nasm documentation:

The SECTION directive (SEGMENT is an exactly equivalent synonym)

Nasm can produce output in various formats, some of which support sections. Certain section names can be arbitrary (such as the three you listed), for them only the section flags count. The predefined ones are just convenience shortcuts, .text is marked as containing code, .data as read-write initialized data and .bss as zero-initialized read-write data. You could put your code in a section named foo as long as it was marked as a code section, and you can use multiple sections as you see fit.

Leave a Comment