title: GCC LD NOLOAD linker section generates loadable segment
body: <p>I'm working on an Arm bare-metal application and I've marked some sections with <code>NOLOAD</code>. According to the explanation in <a href="https://stackoverflow.com/q/57181652/6271889">Understanding linker script NOLOAD sections in embedded software
  </a>, I expected the resulting ELF file to <em>not</em> have a loadable segment (program header) for these sections, but it does.</p>
  <p>Is this correct? Why are those sections marked as loadable in the ELF file?</p>
  <p>As the linker is still placing the data in <code>.bss</code>, how a loader is supposed to know that the sections shouldn't be loaded? Or am I missing the meaning of 'load' in the sense that <code>NOLOAD</code> only makes sense for <em>initialized</em> symbols (which would normally be placed into <code>.data</code>)?</p>
  <p>This is a part of my linker script:</p>
  <pre><code>    .bss (NOLOAD) :
      {
          . = ALIGN(4);
          __bss_start__ = .;
          *(.bss_begin .bss_begin.*)
  
          *(.bss .bss.*)
          *(COMMON)
  
          *(.bss_end .bss_end.*)
          . = ALIGN(4);
          __bss_end__ = .;
      } &gt;DRAM
  
      .noinit (NOLOAD) :
      {
          . = ALIGN(4);
          __noinit_start__ = .;
  
          *(.noinit .noinit.*)
  
           . = ALIGN(4) ;
          __noinit_end__ = .;
      } &gt; DRAM
      
      /* Check if there is enough space to allocate the main stack */
      ._stack (NOLOAD) :
      {
          . = ALIGN(4);
          
          . = . + __Main_Stack_Size ;
          
          . = ALIGN(4);
      } &gt;DRAM
  </code></pre>
  <p>This is the output ELF file:</p>
  <pre><code>arm-none-eabi-readelf.exe -l test.elf
  
  Elf file type is EXEC (Executable file)
  Entry point 0x601b9
  There are 2 program headers, starting at offset 52
  
  Program Headers:
    Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
    LOAD           0x010000 0x00060000 0x00060000 0x06840 0x06840 RWE 0x10000
    LOAD           0x020000 0x20010000 0x20010000 0x00000 0x06084 RW  0x10000
  
   Section to Segment mapping:
    Segment Sections...
     00     .text .ARM.exidx.reset .data
     01     .systemclock .bss ._stack
  </code></pre>
  <p>Why are the <code>.bss</code> and <code>._stack</code> sections there?</p>
  <p>Thanks!!</p>