title: GNU LD filling unused space
body: <p>I'm trying to understand the behaviour of the GNU linker and how sections are treated.</p>
  
  <p>I'm editing the <a href="https://github.com/nitsky/stm32-example/blob/master/stm32_flash.ld" rel="nofollow noreferrer">stm32_flash.ld</a> file in <a href="https://github.com/nitsky/stm32-example/" rel="nofollow noreferrer">this stm32 project</a>. </p>
  
  <p>When I modify the linker script to put the following as the first section:</p>
  
  <pre><code>.my_test :
  {
      . = ALIGN(4);
      KEEP(*(.my_test))
      LONG(0xdeadbeef);
      . = ALIGN(4);
  } &gt;FLASH
  </code></pre>
  
  <p>I can see the built binary has the <code>0xdeadbeef</code> as the first bytes, as I would expect.</p>
  
  <pre><code>$ od -An -tx1 -w1 -v build/program.bin | head
  ef
  be
  ad
  de
  00
  a0
  00
  20
  31
  5e
  </code></pre>
  
  <p>However, if I use the following as the first section:</p>
  
  <pre><code>.my_test :
  {
          . = ALIGN(8);
          KEEP(*(.my_test))
          FILL(0xDEADBEEF)
          . = 0x8000;
  } &gt; FLASH
  </code></pre>
  
  <p>Then it looks like the linker completely skips this section:</p>
  
  <pre><code>$ od -An -tx1 -w1 -v build/program.bin | head
  00
  a0
  00
  20
  2d
  de
  00
  08
  c1
  d9
  </code></pre>
  
  <p>But I would expect the first <code>0x8000</code> bytes to be filled with <code>0xdeadbeef</code>. Why is the linker ignoring my section?</p>