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

        <tr>
          <th>Summary</th>
          <td>[ARM]
          </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>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>japaricious@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20635" name="attach_20635" title="Output of --reproduce">attachment 20635</a> <a href="attachment.cgi?id=20635&action=edit" title="Output of --reproduce">[details]</a></span>
Output of --reproduce

These are the input object files. Observe the instruction at <main+0x2>: `bl
<__nop>`.

    $ arm-none-eabi-objdump -Cd app.o | head -n11

    app.o:     file format elf32-littlearm


    Disassembly of section .text.main:

    00000000 <main>:
      0:   be00            bkpt    0x0000
      2:   f7ff fffe       bl      0 <__nop>
      6:   be00            bkpt    0x0000
      8:   e7fd            b.n     6 <main+0x6>

    $ arm-none-eabi-objdump -Cd libasm.a
    In archive libasm.a:

    asm.o:     file format elf32-littlearm


    Disassembly of section .text:

    00000000 <__nop>:
      0:   4770            bx      lr

When linking with LLD, <main+0x2> becomes `blx 8000050`. This instruction
causes a HardFault (SIGILL like) exception when executed. (AIUI the argument of
BLX should be a register, not an address)

    $ lld -flavor gnu app.o -o app --gc-sections -L . -Bstatic --whole-archive
-lasm --no-whole-archive -Tlink.x -Bdynamic --reproduce repro.tar

    $ arm-none-eabi-objdump -Cd app | head -n11

    app:     file format elf32-littlearm


    Disassembly of section .text:

    08000040 <main>:
    8000040:       be00            bkpt    0x0000
    8000042:       f000 e806       blx     8000050 <DefaultExceptionHandler>
    8000046:       be00            bkpt    0x0000
    8000048:       e7fd            b.n     8000046 <main+0x6>

When linking with GNU LD, <main+0x2> becomes `bl 8000052`. This program
executes without raising an exception.

    $ arm-none-eabi-ld app.o -o app --gc-sections -L . -Bstatic --whole-archive
-lasm --no-whole-archive -Tlink.x -Bdynamic

    $ arm-none-eabi-objdump -Cd app | head -n11

    app:     file format elf32-littlearm


    Disassembly of section .text:

    08000040 <main>:
    8000040:       be00            bkpt    0x0000
    8000042:       f000 f806       bl      8000052 <__nop>
    8000046:       be00            bkpt    0x0000
    8000048:       e7fd            b.n     8000046 <main+0x6>

Version information:

LLVM:
<a href="https://github.com/llvm-mirror/llvm/commit/0b5d0cfa8e55ac076285efb25e102597751db49c">https://github.com/llvm-mirror/llvm/commit/0b5d0cfa8e55ac076285efb25e102597751db49c</a>
LLD:
<a href="https://github.com/llvm-mirror/lld/commit/bcfc39dfc8e40fd7744828abfb4ae4f9e69dc32b">https://github.com/llvm-mirror/lld/commit/bcfc39dfc8e40fd7744828abfb4ae4f9e69dc32b</a>
GNU LD: 2.31</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>