<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 - data32 ljmp in .code16 should select FARJMP32i instead of FARJMP16i"
   href="https://bugs.llvm.org/show_bug.cgi?id=47632">47632</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>data32 ljmp in .code16 should select FARJMP32i instead of FARJMP16i
          </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>This may be the last problem blocking assembling kexec-tools with the
integrated assembler (I reported another issue in <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - data32 prefix in .code16 block is not respected"
   href="show_bug.cgi?id=46942">bug 46942</a>)

git clone git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
cd kexec-tools
./bootstrap
./configure CC=clang
make -j10

There is a red-herring "relocation R_386_16 out of range" issue. The problem
(according to -debug-only=asm-matcher) is that the wrong FARJMP16i is selected.

% cat a.s
.code16
.space 0x104, 0x90
data32 ljmp $(0x10000)>>4, $2f-0x10000
2:
movw %cs,%ax
% as --32 a.s -o a.o && llvm-mc -filetype=obj -triple=i386 a.s -o b.o
% diff -u =(objdump -mi386 -Maddr16,data16 -wdrz a.o) =(objdump -mi386
-Maddr16,data16 -wdrz b.o)
--- /tmp/zshZyzVFz      2020-09-23 18:30:43.748829551 -0700
+++ /tmp/zshLrHrMy      2020-09-23 18:30:43.756829581 -0700
@@ -1,5 +1,5 @@

-a.o:     file format elf32-i386
+b.o:     file format elf32-i386


 Disassembly of section .text:
@@ -265,5 +265,4 @@
  101:  90                      nop
  102:  90                      nop
  103:  90                      nop
- 104:  66 ea 0c 01 ff ff 00 10         ljmpl  $0x1000,$0xffff010c      106:
R_386_32   .text
- 10c:  8c c8                   mov    %cs,%ax
+ 104:  66 ea 0a 01 00 10 8c c8         ljmpl  $0xc88c,$0x1000010a      106:
R_386_16   .text


% llvm-mc -triple=i386 a.s -debug-only=asm-matcher
...
Trying to match opcode FARJMP32i
  Matching formal operand class MCK_Imm against actual operand at index 1
(Imm:4096): match success using generic matcher
  Matching formal operand class MCK_Imm against actual operand at index 2 ():
match success using generic matcher
  Matching formal operand class InvalidMatchClass against actual operand at
index 3: actual operand index out of range Missing target features: 1
Trying to match opcode FARJMP16i
  Matching formal operand class MCK_Imm against actual operand at index 1
(Imm:4096): match success using generic matcher
  Matching formal operand class MCK_Imm against actual operand at index 2 ():
match success using generic matcher
  Matching formal operand class InvalidMatchClass against actual operand at
index 3: actual operand index out of range Opcode result: complete match,
selecting this opcode
        ljmpw   $4096, $.Ltmp0-65536            # imm = 0x1000</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>