[PATCH] D28898: [ELF] - Allow emulation to be different from input objects target.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 04:54:06 PST 2017


grimar created this revision.

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
  ...

All objects are i386, but invocation contains -m elf_x86_64 and we report a error.
That does not seem to be correct. Both gold and bfd allow to link that. Specification says:

  -m emulation
                Emulate  the  emulation  linker.   You can list the
                available emulations with the --verbose or  -V  op-
                tions.   This  option overrides the compiled-in de-
                fault, which is the system for which you configured
                ld.

Patch makes target to be created basing on machine type inferred from
first object. If that is not possible then emulation option is used to extract the same.
Then later default targets parameters like page sizes and image base are replaced with "emulated" ones,
if emulation was specified.

This is PR31678


https://reviews.llvm.org/D28898

Files:
  ELF/Driver.cpp
  ELF/Mips.cpp
  ELF/SymbolTable.cpp
  ELF/Target.cpp
  ELF/Target.h
  ELF/Writer.h
  test/ELF/driver.test
  test/ELF/emulation-override.s
  test/ELF/incompatible.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28898.84957.patch
Type: text/x-patch
Size: 8576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170119/0b73aa50/attachment.bin>


More information about the llvm-commits mailing list