Add EM_IAMCU support.

This patch adds "-m elf_iamcu" to ldd for IAMCU psABI:
https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI

Patch by H.J Lu.

llvm-svn: 277643
This commit is contained in:
Rui Ueyama 2016-08-03 20:15:56 +00:00
parent a6be60871f
commit 6c50990df6
4 changed files with 34 additions and 1 deletions

View File

@ -70,6 +70,7 @@ static std::pair<ELFKind, uint16_t> parseEmulation(StringRef S) {
.Case("elf64ltsmip", {ELF64LEKind, EM_MIPS})
.Case("elf64ppc", {ELF64BEKind, EM_PPC64})
.Case("elf_i386", {ELF32LEKind, EM_386})
.Case("elf_iamcu", {ELF32LEKind, EM_IAMCU})
.Case("elf_x86_64", {ELF64LEKind, EM_X86_64})
.Default({ELFNoneKind, EM_NONE});

View File

@ -579,7 +579,7 @@ static uint8_t getMachineKind(MemoryBufferRef MB) {
case Triple::ppc64:
return EM_PPC64;
case Triple::x86:
return EM_386;
return Triple(TripleStr).isOSIAMCU() ? EM_IAMCU : EM_386;
case Triple::x86_64:
return EM_X86_64;
default:

View File

@ -214,6 +214,7 @@ public:
TargetInfo *createTarget() {
switch (Config->EMachine) {
case EM_386:
case EM_IAMCU:
return new X86TargetInfo();
case EM_AARCH64:
return new AArch64TargetInfo();

View File

@ -122,6 +122,37 @@
# X86FBSD-NEXT: StringTableSectionIndex:
# X86FBSD-NEXT: }
# RUN: llvm-mc -filetype=obj -triple=i586-intel-elfiamcu %s -o %tiamcu
# RUN: ld.lld -m elf_iamcu %tiamcu -o %t2iamcu
# RUN: llvm-readobj -file-headers %t2iamcu | FileCheck --check-prefix=IAMCU %s
# RUN: ld.lld %tiamcu -o %t3iamcu
# RUN: llvm-readobj -file-headers %t3iamcu | FileCheck --check-prefix=IAMCU %s
# IAMCU: ElfHeader {
# IAMCU-NEXT: Ident {
# IAMCU-NEXT: Magic: (7F 45 4C 46)
# IAMCU-NEXT: Class: 32-bit (0x1)
# IAMCU-NEXT: DataEncoding: LittleEndian (0x1)
# IAMCU-NEXT: FileVersion: 1
# IAMCU-NEXT: OS/ABI: SystemV (0x0)
# IAMCU-NEXT: ABIVersion: 0
# IAMCU-NEXT: Unused: (00 00 00 00 00 00 00)
# IAMCU-NEXT: }
# IAMCU-NEXT: Type: Executable (0x2)
# IAMCU-NEXT: Machine: EM_IAMCU (0x6)
# IAMCU-NEXT: Version: 1
# IAMCU-NEXT: Entry:
# IAMCU-NEXT: ProgramHeaderOffset: 0x34
# IAMCU-NEXT: SectionHeaderOffset:
# IAMCU-NEXT: Flags [ (0x0)
# IAMCU-NEXT: ]
# IAMCU-NEXT: HeaderSize: 52
# IAMCU-NEXT: ProgramHeaderEntrySize: 32
# IAMCU-NEXT: ProgramHeaderCount:
# IAMCU-NEXT: SectionHeaderEntrySize: 40
# IAMCU-NEXT: SectionHeaderCount:
# IAMCU-NEXT: StringTableSectionIndex:
# IAMCU-NEXT: }
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %tppc64
# RUN: ld.lld -m elf64ppc %tppc64 -o %t2ppc64
# RUN: llvm-readobj -file-headers %t2ppc64 | FileCheck --check-prefix=PPC64 %s