<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 elf/-bstatic creates crashing executable"
   href="https://bugs.llvm.org/show_bug.cgi?id=39587">39587</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lld elf/-bstatic creates crashing executable
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>ck@remobjects.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Trying to use lld to create a -Bstatic executable for linux raspberrypi (armv7)
 creates an invalid executable that crashes at run & fails to open in gdb.

The commandline was 
lld -flavor gnu "ConsoleApplication907.a" "ConsoleApplication907.o" "Island.a" 
"libgc.a" libgcc.a libgcc_eh.a libpthread.a librt.a libc.a --eh-frame-hdr
-Bstatic -o ConsoleApplication907

If I compile Island.a from bitcode to obj and use gnu ld it does work and run:

ld   -\( Island.a  "libgc.a" libgcc.a libgcc_eh.a libpthread.a librt.a libc.a
-\) ConsoleApplication907.o ConsoleApplication907.a Island.a --eh-frame-hdr
-Bstatic -o ConsoleApplication907

Neither linux nor anything else gives an indication of what is wrong, but ld
has no problem statically linking libc. The qemu linux emulator seems to jump
(blx) to _dl_hwcap which is a BSS symbol.

LLD repro file: <a href="https://1drv.ms/u/s!Au2nm7P_hgmawnGfF6vCLE7JGT21">https://1drv.ms/u/s!Au2nm7P_hgmawnGfF6vCLE7JGT21</a> (too big to
attach)</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>