<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 --- - RuntimeDyldCOFFI386 ignores relocation addend"
   href="https://llvm.org/bugs/show_bug.cgi?id=28111">28111</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>RuntimeDyldCOFFI386 ignores relocation addend
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jon@kingstar.demon.co.uk
          </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>Created <span class=""><a href="attachment.cgi?id=16533" name="attach_16533" title="Illustrative patch">attachment 16533</a> <a href="attachment.cgi?id=16533&action=edit" title="Illustrative patch">[details]</a></span>
Illustrative patch

This stops mesa llvmpipe on Cygwin x86 from working usefully, but probably
affects many uses of MCJIT on x86/Windows.

For example, mesa's lp_test_arit test fails in sgn.v2.  Examining the JIT-ed
code before an after relocations
are applied shows the problem.

<span class="quote">> # gdb ./lp_test_arit
> [...]
> (gdb) b test_unary
> Breakpoint 1 at 0x401577: file ../../../../../src/gallium/drivers/llvmpipe/lp_test_arit.c, line 402.
> (gdb) ignore 1 7
> Will ignore next 7 crossings of breakpoint 1.
> (gdb) r
> [...]
> (gdb) b llvm::RuntimeDyldCOFFI386::resolveRelocation
> Breakpoint 2 at 0x6b756290: file /usr/src/debug/llvm-3.7.1-1.1/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h, line 126.
> (gdb) c
> [...]
> (gdb) up 8
> #8  0x00401670 in test_unary (verbose=0, fp=0x0, test=0x45b3a0 <unary_tests+64>, length=2) at ../../../../../src/gallium/drivers/llvmpipe/lp_test_arit.c:426
> (gdb) x/33i test_func_jit
>    0x7ffa0000:  push   %ebp
>    0x7ffa0001:  mov    %esp,%ebp
>    0x7ffa0003:  and    $0xfffffff8,%esp
>    0x7ffa0006:  sub    $0x8,%esp
>    0x7ffa0009:  mov    0x8(%ebp),%eax
>    0x7ffa000c:  mov    0xc(%ebp),%ecx
>    0x7ffa000f:  movss  (%ecx),%xmm0
>    0x7ffa0013:  movss  0x4(%ecx),%xmm1
>    0x7ffa0018:  movss  %xmm1,0x4(%esp)
>    0x7ffa001e:  movss  %xmm0,(%esp)
>    0x7ffa0023:  insertps $0x10,%xmm1,%xmm0
>    0x7ffa0029:  pmovzxdq (%esp),%xmm1
>    0x7ffa002f:  pand   0x0,%xmm1              <== addend 0
>    0x7ffa0037:  por    0x10,%xmm1             <== addend 10
>    0x7ffa003f:  xorps  %xmm2,%xmm2
>    0x7ffa0042:  movaps %xmm0,%xmm3
>    0x7ffa0045:  cmpeqps %xmm2,%xmm3
>    0x7ffa0049:  cmpunordps %xmm2,%xmm0
>    0x7ffa004d:  orps   %xmm3,%xmm0
>    0x7ffa0050:  pmovzxdq %xmm0,%xmm0
>    0x7ffa0055:  psllq  $0x20,%xmm0
>    0x7ffa005a:  pshufd $0xf5,%xmm0,%xmm3
>    0x7ffa005f:  psrad  $0x1f,%xmm0
>    0x7ffa0064:  pblendw $0x33,%xmm3,%xmm0
>    0x7ffa006a:  pshufd $0xe8,%xmm0,%xmm0
>    0x7ffa006f:  pslld  $0x1f,%xmm0
>    0x7ffa0074:  pshufd $0xe8,%xmm1,%xmm1
>    0x7ffa0079:  blendvps %xmm0,%xmm2,%xmm1
>    0x7ffa007e:  extractps $0x1,%xmm1,0x4(%eax)
>    0x7ffa0085:  movss  %xmm1,(%eax)
>    0x7ffa0089:  mov    %ebp,%esp
>    0x7ffa008b:  pop    %ebp
>    0x7ffa008c:  ret
> (gdb) disable 2
> (gdb) b 428
> Breakpoint 3 at 0x401673: file ../../../../../src/gallium/drivers/llvmpipe/lp_test_arit.c, line 428.
> (gdb) c
> [...]
> (gdb) x/33i test_func_jit
>    0x7ffa0000:  push   %ebp
>    0x7ffa0001:  mov    %esp,%ebp
>    0x7ffa0003:  and    $0xfffffff8,%esp
>    0x7ffa0006:  sub    $0x8,%esp
>    0x7ffa0009:  mov    0x8(%ebp),%eax
>    0x7ffa000c:  mov    0xc(%ebp),%ecx
>    0x7ffa000f:  movss  (%ecx),%xmm0
>    0x7ffa0013:  movss  0x4(%ecx),%xmm1
>    0x7ffa0018:  movss  %xmm1,0x4(%esp)
>    0x7ffa001e:  movss  %xmm0,(%esp)
>    0x7ffa0023:  insertps $0x10,%xmm1,%xmm0
>    0x7ffa0029:  pmovzxdq (%esp),%xmm1
>    0x7ffa002f:  pand   0x7ff90000,%xmm1    <== addend was 0
>    0x7ffa0037:  por    0x7ff90000,%xmm1    <== addend ignored
>    0x7ffa003f:  xorps  %xmm2,%xmm2
>    0x7ffa0042:  movaps %xmm0,%xmm3
>    0x7ffa0045:  cmpeqps %xmm2,%xmm3
>    0x7ffa0049:  cmpunordps %xmm2,%xmm0
>    0x7ffa004d:  orps   %xmm3,%xmm0
>    0x7ffa0050:  pmovzxdq %xmm0,%xmm0
>    0x7ffa0055:  psllq  $0x20,%xmm0
>    0x7ffa005a:  pshufd $0xf5,%xmm0,%xmm3
>    0x7ffa005f:  psrad  $0x1f,%xmm0
>    0x7ffa0064:  pblendw $0x33,%xmm3,%xmm0
>    0x7ffa006a:  pshufd $0xe8,%xmm0,%xmm0
>    0x7ffa006f:  pslld  $0x1f,%xmm0
>    0x7ffa0074:  pshufd $0xe8,%xmm1,%xmm1
>    0x7ffa0079:  blendvps %xmm0,%xmm2,%xmm1
>    0x7ffa007e:  extractps $0x1,%xmm1,0x4(%eax)
>    0x7ffa0085:  movss  %xmm1,(%eax)
>    0x7ffa0089:  mov    %ebp,%esp
>    0x7ffa008b:  pop    %ebp
>    0x7ffa008c:  ret</span >

Attached is an illustrative patch, based on how RuntimeDyldCOFFX86_64 handles
this.</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>