[llvm-bugs] [Bug 31678] New: [ELF] - Incompatible emulation should not lead to error

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 18 08:26:21 PST 2017


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

            Bug ID: 31678
           Summary: [ELF] - Incompatible emulation should not lead to
                    error
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: grimar at accesssoftek.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17853
  --> https://llvm.org/bugs/attachment.cgi?id=17853&action=edit
reproduce

I found that when tried to link "arch/x86/realmode/rm" component of linux
kernel,
LLD reports:

ld: arch/x86/realmode/rm/header.o is incompatible with elf_x86_64
ld: error: arch/x86/realmode/rm/header.o is incompatible with elf_x86_64
ld: arch/x86/realmode/rm/trampoline_64.o is incompatible with elf_x86_64

All objects are i386, but invocation contains -m elf_x86_64 and we report a
error.
That does not seem to be correct. I found some description here:
http://stackoverflow.com/questions/38951492/linkers-emulation-vs-output-format

And performed a test. Linked reproduce using bfd with -m elf_x86_64 and -m
i386.
Both runs successfully output a "Intel 80386" binary. Segments have different
offset/alignment though:

-m elf_x86_64:
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x200000 0x00000000 0x00000000 0x05258 0x05258 RWE 0x200000
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x10

-m i386:
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0x00000000 0x00000000 0x05258 0x05258 RWE 0x1000
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x10


So -m affects on some constants and should not emit error in this case.
I am going to investigate it more and fix. Comments are welcome.

-- 
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/20170118/e1b74b92/attachment.html>


More information about the llvm-bugs mailing list