<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Linker script orphan sections get an invalid address on AArch64"
   href="https://llvm.org/bugs/show_bug.cgi?id=30267">30267</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Linker script orphan sections get an invalid address on AArch64
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrew@fubar.geek.nz
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>emaste@freebsd.org, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17211" name="attach_17211" title="objdump -x of the linked kernel">attachment 17211</a> <a href="attachment.cgi?id=17211&action=edit" title="objdump -x of the linked kernel">[details]</a></span>
objdump -x of the linked kernel

While trying to link the FreeBSD arm64 kernel I received around 45141 of the
following error:
relocation R_AARCH64_ADR_PREL_PG_HI21 out of range

After commenting out the check I linked the kernel and found the orphaned
sections were placed at the end of the file and started with a virtual address
of 0. This caused an overflow in the relocation.

It would seem binutils has a heuristic to put these sections after a section
with similar attributes:
<a href="https://sourceware.org/binutils/docs/ld/Orphan-Sections.html">https://sourceware.org/binutils/docs/ld/Orphan-Sections.html</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>