Index: llvm/unittests/Object/ELFObjectFileTest.cpp =================================================================== --- llvm/unittests/Object/ELFObjectFileTest.cpp +++ llvm/unittests/Object/ELFObjectFileTest.cpp @@ -74,12 +74,23 @@ } // namespace +TEST(ELFObjectFileTest, MachineTestForNone) { + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_NONE}, + "elf64-unknown", Triple::UnknownArch); + + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_NONE}, + "elf32-unknown", Triple::UnknownArch); +} + TEST(ELFObjectFileTest, MachineTestForVE) { checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_VE}, "elf64-ve", Triple::ve); } TEST(ELFObjectFileTest, MachineTestForX86_64) { + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_X86_64}, + "elf32-x86-64", Triple::x86_64); + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_X86_64}, "elf64-x86-64", Triple::x86_64); } @@ -87,6 +98,9 @@ TEST(ELFObjectFileTest, MachineTestFor386) { checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_386}, "elf32-i386", Triple::x86); + + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_386}, + "elf64-i386", Triple::x86); } TEST(ELFObjectFileTest, MachineTestForMIPS) { @@ -102,3 +116,92 @@ checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2MSB, ELF::EM_MIPS}, "elf32-mips", Triple::mips); } + +TEST(ELFObjectFileTest, MachineTestForAMDGPU) { + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_AMDGPU}, + "elf64-amdgpu", Triple::UnknownArch); + + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_AMDGPU}, + "elf32-amdgpu", Triple::UnknownArch); +} + +TEST(ELFObjectFileTest, MachineTestForIAMCU) { + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_IAMCU}, + "elf32-iamcu", Triple::x86); +} + +TEST(ELFObjectFileTest, MachineTestForAARCH64) { + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_AARCH64}, + "elf64-littleaarch64", Triple::aarch64); + + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2MSB, ELF::EM_AARCH64}, + "elf64-bigaarch64", Triple::aarch64_be); +} + +TEST(ELFObjectFileTest, MachineTestForPPC) { + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_PPC64}, + "elf64-powerpcle", Triple::ppc64le); + + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2MSB, ELF::EM_PPC64}, + "elf64-powerpc", Triple::ppc64); + + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_PPC}, + "elf32-powerpc", Triple::ppc); +} + +TEST(ELFObjectFileTest, MachineTestForRISCV) { + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_RISCV}, + "elf64-littleriscv", Triple::riscv64); + + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_RISCV}, + "elf32-littleriscv", Triple::riscv32); +} + +TEST(ELFObjectFileTest, MachineTestForARM) { + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_ARM}, + "elf32-littlearm", Triple::arm); + + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2MSB, ELF::EM_ARM}, + "elf32-bigarm", Triple::arm); +} + +TEST(ELFObjectFileTest, MachineTestForS390) { + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_S390}, + "elf64-s390", Triple::systemz); +} + +TEST(ELFObjectFileTest, MachineTestForSPARC) { + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_SPARCV9}, + "elf64-sparc", Triple::sparcv9); + + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_SPARC}, + "elf32-sparc", Triple::sparcel); + + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_SPARC32PLUS}, + "elf32-sparc", Triple::sparcel); +} + +TEST(ELFObjectFileTest, MachineTestForBPF) { + checkFormatAndArch({ELF::ELFCLASS64, ELF::ELFDATA2LSB, ELF::EM_BPF}, + "elf64-bpf", Triple::bpfel); +} + +TEST(ELFObjectFileTest, MachineTestForAVR) { + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_AVR}, + "elf32-avr", Triple::avr); +} + +TEST(ELFObjectFileTest, MachineTestForHEXAGON) { + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_HEXAGON}, + "elf32-hexagon", Triple::hexagon); +} + +TEST(ELFObjectFileTest, MachineTestForLANAI) { + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_LANAI}, + "elf32-lanai", Triple::lanai); +} + +TEST(ELFObjectFileTest, MachineTestForMSP430) { + checkFormatAndArch({ELF::ELFCLASS32, ELF::ELFDATA2LSB, ELF::EM_MSP430}, + "elf32-msp430", Triple::msp430); +}