<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 --- - [lld] Support -pie"
   href="https://llvm.org/bugs/show_bug.cgi?id=26923">26923</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[lld] Support -pie
          </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>All
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chisophugis@gmail.com
          </td>
        </tr>

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

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I ran into this with LTO. In:
<a href="http://llvm.org/klaus/lld/blob/master/ELF/SymbolTable.cpp#L-125">http://llvm.org/klaus/lld/blob/master/ELF/SymbolTable.cpp#L-125</a>
We set the reloc model to PIC or Static depending just on Config->Shared. On
platforms requiring pie, we will incorrectly codegen the combined LTO object as
static, resulting in failures during dynamic linking.

I haven't looked at where else in the linker needs to be updated for -pie, but
at the very least LTO needs to be aware of it.

       -pie
       --pic-executable
           Create a position independent executable.  This is currently only
           supported on ELF platforms.  Position independent executables are
           similar to shared libraries in that they are relocated by the
           dynamic linker to the virtual address the OS chooses for them
           (which can vary between invocations).  Like normal dynamically
           linked executables they can be executed and symbols defined in the
           executable cannot be overridden by shared libraries.</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>