title: What is the effect of a `section` command with an empty list of input sections in a GNU linker script?
body: <p>In an LD linker script I have the following fragment in the <code>SECTIONS</code> section:</p>
  
  <pre><code>. = (__BUFFER_LOCATION_); 
  BUFFER . : { } &gt; EXTERNAL_MEM
  </code></pre>
  
  <p>where <code>__BUFFER_LOCATION_</code> is defined to some address and <code>EXTERNAL_MEM</code> is defined in the <code>MEMORY</code> section.</p>
  
  <p>In the <code>C</code> program, I have a global buffer declared as:</p>
  
  <pre><code>char outbuf[4096] __attribute__((section("BUFFER")));
  </code></pre>
  
  <p>It can be seen that the linker script does not mention any input section named <code>BUFFER</code>, but the output section is named as such.</p>
  
  <p>When compiling the program I see that the linker placed the buffer in the supposed address (<code>BUFFER_LOCATION</code>), although the input section was not defined in the LDF. When I remove the <code>attribute</code> from the source, the buffer is placed in a completely different address.</p>
  
  <p>So, I assume that by default, an output-section-command of type "input section description" adds the output section's name to the input sections list implicitly, unless defined somewhere else. However, reading <a href="http://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS" rel="nofollow">the manual</a>, I could not find a description of such behaviour.</p>
  
  <p>Did I miss something, or is it an "undocumented feature"?</p>