title: GNU Linker - orphan sections and symbol assignment
body: <p>After reading enough documentation about the GNU linker, I feel confused about combining two different concepts regarding implementing custom linker file.</p>
  <p>First concept is <a href="https://sourceware.org/binutils/docs/ld/Orphan-Sections.html#Orphan-Sections" rel="nofollow noreferrer"><em>orphan sections</em></a>-</p>
  <blockquote>
  <p>If there is no output section with a matching name then <strong>new output sections will be created</strong>. Each new output section will have the same name as the orphan section placed within it. <strong>If there are multiple orphan sections with the same name, these will all be combined into one new output section</strong>.
  If new output sections are created to hold orphaned input sections,
  then the linker must decide where to place these new output sections
  in relation to existing output sections. <strong>On most modern targets, the
  linker attempts to place orphan sections after sections of the same
  attribute, such as code vs data, loadable vs non-loadable, etc</strong>. If no
  sections with matching attributes are found, or your target lacks this
  support, the orphan section is placed at the end of the file.</p>
  </blockquote>
  <p>Second concept is about <a href="https://sourceware.org/binutils/docs/ld/Simple-Assignments.html" rel="nofollow noreferrer"><em>symbol assignment</em></a>-</p>
  <blockquote>
  <p>Here is an example showing the three different places that symbol
  assignments may be used:</p>
  </blockquote>
  <pre><code>floating_point = 0;
  SECTIONS
  {
    .text :
      {
        *(.text)
        _etext = .;
      }
    _bdata = (. + 3) &amp; ~ 3;
    .data : { *(.data) }
  }
  </code></pre>
  <blockquote>
  <p>In this example, the symbol ‘floating_point’ will be defined as zero.
  The symbol ‘_etext’ will be defined as the address following the last
  ‘.text’ input section. <strong>The symbol ‘_bdata’ will be defined as the
  address following the ‘.text’ output section aligned upward to a 4
  byte boundary.</strong></p>
  </blockquote>
  <p>So, the <strong>bold</strong> explanation regarding orphan sections dictates that is possible that in the above example, the linker will place another output sections after <code>.text</code> output section, which means that the <strong>bold</strong> text in the symbol assignment explanation is wrong.</p>
  <p>So, is this example can produce undesired value into the <code>_bdata</code> symbol if orphan section exist in it?</p>