<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 --- - RIP-relative memory references" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23986&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=CVCchxYYeNjupZscR9R8kMKWBHv6kUKNsgbI8d5zUE8&s=4xXJvF2wWdbIO2MSLmPMFkvuCLJWB6NwfAPXiHj7D-M&e=">23986</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>RIP-relative memory references
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.l.kreitzer@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>llvm-mc is encoding some RIP-relative instructions incorrectly by failing to
relax arith imm8 instruction forms.  For example:

------------- t.s -----------------
bar:
        .section imul
        imul $foo, bar(%rip),  %bx
        imul $foo, bar(%rip),  %ebx
        imul $foo, bar(%rip),  %rbx
-----------------------------------

This is the current behavior.  Note that in each case, $foo is encoded as an
8-bit immediate even though it is not guaranteed to fit in 8 bits.

bash-4.3$ llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu t.s -o t.o
bash-4.3$ objdump -d --section=imul t.o

t.o:     file format elf64-x86-64


Disassembly of section imul:

0000000000000000 <imul>:
   0:   66 6b 1d 00 00 00 00    imul   $0x0,0x0(%rip),%bx        # 8 <imul+0x8>
   7:   00 
   8:   6b 1d 00 00 00 00 00    imul   $0x0,0x0(%rip),%ebx        # f
<imul+0xf>
   f:   48 6b 1d 00 00 00 00    imul   $0x0,0x0(%rip),%rbx        # 17
<bar+0x17>
  16:   00</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>