[llvm-bugs] [Bug 46952] New: movl nearer, %ebx in .code16 block needs to have 16-bit displacement (required by grub)

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 1 15:34:43 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46952

            Bug ID: 46952
           Summary: movl nearer, %ebx in .code16 block needs to have
                    16-bit displacement (required by grub)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: i at maskray.me
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

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
https://github.com/coreos/grub/commit/a0bf403f66dbaca4edd8e667bfc397dd91c8d71c


git clone https://github.com/coreos/grub
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>:
        ...

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200801/b5920659/attachment-0001.html>


More information about the llvm-bugs mailing list