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: unassignedb...@nondot.org
          Reporter: i...@maskray.me
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    llvm-...@redking.me.uk, spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to