Sections Segment

Inside the sections segment, you define the contents of your memory segments, and define any global symbols to be used in the output file.

The format of a typical sections block looks like the following listing.

Note: As shown in the following listing, the .bss section always needs to be put at the end of a segment or in a standalone segment, because it is not a loadable section.
Listing: Sample SECTIONS segment
SECTIONS {
   .section_name : #the section name is for your reference
   {               #the section name must begin with a '.'
     filename.c  (.text) #put the .text section from filename.c
     filename2.c (.text) #then the .text section from filename2.c
     filename.c  (.data)
     filename2.c (.data)
     filename.c  (.bss)
     filename2.c (.bss)
      . = ALIGN (0x10);  #align next section on 16-byte boundary.
   } > segment_1    #this means "map these contents to segment_1"

   .next_section_name:
   {
      more content descriptions
   } > segment_x      # end of .next_section_name definition
   }                     # end of the sections block