<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 - movl nearer, %ebx in .code16 block needs to have 16-bit displacement (required by grub)"
   href="https://bugs.llvm.org/show_bug.cgi?id=46952">46952</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>movl nearer, %ebx in .code16 block needs to have 16-bit displacement (required by grub)
          </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>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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>i@maskray.me
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>grub cannot be assembled by integrated assembler because movl nearer, %ebx in a
.code16 block has 32-bit displacement instead of 16-bit. There is a
configure-time test catching MC's discrepancy
<a href="https://github.com/coreos/grub/commit/a0bf403f66dbaca4edd8e667bfc397dd91c8d71c">https://github.com/coreos/grub/commit/a0bf403f66dbaca4edd8e667bfc397dd91c8d71c</a>


git clone <a href="https://github.com/coreos/grub">https://github.com/coreos/grub</a>
cd grub

% clang -c asm-tests/i386-pc.S
asm-tests/i386-pc.S:13:7: error: invalid .org offset '11' (at offset '14')
 .org 11
      ^
asm-tests/i386-pc.S:13:7: error: invalid .org offset '11' (at offset '14')
 .org 11
      ^
asm-tests/i386-pc.S:13:7: error: invalid .org offset '11' (at offset '14')
 .org 11
      ^

The integrated assembler emits:

% llvm-mc -triple=i386 a.s --show-encoding --show-inst  
        .text
        .code16
        movl    nearer, %ebx                    # encoding:
[0x67,0x66,0x8b,0x1d,A,A,A,A]
                                        #   fixup A - offset: 4, value: nearer,
kind: FK_Data_4



The expected GNU as behavior:

% as asm-tests/i386-pc.S -o a.o
% objdump -mi386 -Maddr16,data16 --start-address=6 -dr a.o L

a.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000006 <nearer-0x69>:
   6:   66 8b 1e 00 00          mov    0x0,%ebx
                        9: R_X86_64_16  .text+0x6f
        ...

000000000000006f <nearer>:
        ...

0000000000000137 <far>:
        ...</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>