<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 - Hardware Asan generating illegal instruction"
   href="https://bugs.llvm.org/show_bug.cgi?id=46427">46427</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Hardware Asan generating illegal instruction
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>derrick.mckee@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, peter@pcc.me.uk, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23641" name="attach_23641" title="Test program that generates illegal instruction">attachment 23641</a> <a href="attachment.cgi?id=23641&action=edit" title="Test program that generates illegal instruction">[details]</a></span>
Test program that generates illegal instruction

A simple Hello World program generates an illegal instruction when using the
aarch64-linux-gnu toolchain and hardware address sanitizer.  The cause of this
issue is detailed at <a href="https://reviews.llvm.org/D65857#1621335">https://reviews.llvm.org/D65857#1621335</a>, and can be fixed
by adding -fuse-ld=lld.

How to recreate:

# llvm-project/build-10.x/install/bin/clang --version
clang version 10.0.1 (<a href="mailto:git@github.com">git@github.com</a>:llvm/llvm-project.git
a634a80615b1e012f1a61aa0cd1e2e67ef77d0bd)
Target: x86_64-unknown-linux-gnu
Thread model: posix

llvm-project/build-10.x/install/bin/clang -o test --target=aarch64-linux-gnu
-march=armv8.5-a -fsanitize=hwaddress --sysroot=/usr/aarch64-linux-gnu/
-L/usr/lib/gcc/aarch64-linux-gnu/10.1.0/ -g test.c

llvm-project/build-10.x/install/bin/llvm-objdump -d
--disassemble-functions=main test

Expected output: A valid disassembly of the test binary

Actual output: See instruction 2d51c below.

000000000002d4c0 main:
   2d4c0: ff c3 00 d1                      sub    sp, sp, #48
   2d4c4: fd 7b 02 a9                      stp    x29, x30, [sp, #32]
   2d4c8: fd 83 00 91                      add    x29, sp, #32
   2d4cc: 08 01 00 d0                      adrp    x8, #139264
   2d4d0: 08 49 47 f9                      ldr    x8, [x8, #3728]
   2d4d4: 49 d0 3b d5                      mrs    x9, TPIDR_EL0
   2d4d8: 28 69 68 f8                      ldr    x8, [x9, x8]
   2d4dc: 08 7d 40 b2                      orr    x8, x8, #0xffffffff
   2d4e0: 08 05 00 91                      add    x8, x8, #1
   2d4e4: a2 13 00 d1                      sub    x2, x29, #4
   2d4e8: e9 03 08 aa                      mov    x9, x8
   2d4ec: df 64 ff 97                      bl    #-158852
<__hwasan_check_x2_18_short>
   2d4f0: ea 03 1f 2a                      mov    w10, wzr
   2d4f4: aa c3 1f b8                      stur    w10, [x29, #-4]
   2d4f8: a2 23 00 d1                      sub    x2, x29, #8
   2d4fc: e9 03 08 aa                      mov    x9, x8
   2d500: da 64 ff 97                      bl    #-158872
<__hwasan_check_x2_18_short>
   2d504: a0 83 1f b8                      stur    w0, [x29, #-8]
   2d508: e2 43 00 91                      add    x2, sp, #16
   2d50c: e9 03 08 aa                      mov    x9, x8
   2d510: ec 64 ff 97                      bl    #-158800
<__hwasan_check_x2_19_short>
   2d514: e1 0b 00 f9                      str    x1, [sp, #16]
   2d518: 40 00 00 d0                      adrp    x0, #40960
   2d51c: e0 ff e5 b2                      <unknown>
   2d520: 00 40 35 91                      add    x0, x0, #3408
   2d524: ea 0f 00 b9                      str    w10, [sp, #12]
   2d528: c2 64 ff 97                      bl    #-158968 <printf@plt>
   2d52c: ea 0f 40 b9                      ldr    w10, [sp, #12]
   2d530: e0 0b 00 b9                      str    w0, [sp, #8]
   2d534: e0 03 0a 2a                      mov    w0, w10
   2d538: fd 7b 42 a9                      ldp    x29, x30, [sp, #32]
   2d53c: ff c3 00 91                      add    sp, sp, #48
   2d540: c0 03 5f d6                      ret</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>