<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - LLD refuses to link discarded ELF PHDRs"
   href="https://bugs.llvm.org/show_bug.cgi?id=42933">42933</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD refuses to link discarded ELF PHDRs
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>ftee@flametop.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22359" name="attach_22359" title="Example linker script">attachment 22359</a> <a href="attachment.cgi?id=22359&action=edit" title="Example linker script">[details]</a></span>
Example linker script

The change:

  <a href="https://reviews.llvm.org/rL311586">https://reviews.llvm.org/rL311586</a>

  Petr Hosek, 2 years ago   (August 23rd, 2017 7:44pm)

  [ELF] Don't output headers into a segment if there's no space for them

Implemented the routine 'LinkerScript::allocateHeaders' and in its
documentation details a technique used to discard headers;

// When using the default layout, we check if the headers fit below the first
// allocated section. When using a linker script, we also check if the headers
// are covered by the output section. This allows omitting the headers by not
// leaving enough space for them in the linker script; this pattern is common
// in embedded systems.

We have an system that uses just such a technique via the attached linker 
script.

Change:

 <a href="https://reviews.llvm.org/rL326441">https://reviews.llvm.org/rL326441</a>

 Rafael Espindola, a year ago   (March 1st, 2018 3:25pm)

 Don't allocate a header bellow address 0.

Appears to have intended to catch an underflow which could allocate the PHDRs
at a negative address. However, this change also catches the case of the 
PHDRs being discarded from address zero as detailed in the technique above.

Attempting to link the attached simple test program with the attached 'user.ld'
linker script results in the error:

  ld -nostdlib -T user.ld test.o
  ld: error: could not allocate headers

Neither GNU LD or GOLD generate any error in this case.</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>