[ELF][Mips] Fix recognition of MIPS 64-bit arch in the ELFObjectFile:getArch() method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Simon Atanasyan 2014-06-27 11:36:45 +00:00
parent 4363b0729b
commit fc9897f66f
3 changed files with 37 additions and 5 deletions

View File

@ -917,6 +917,7 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
template <class ELFT>
unsigned ELFObjectFile<ELFT>::getArch() const {
bool IsLittleEndian = ELFT::TargetEndianness == support::little;
switch (EF.getHeader()->e_machine) {
case ELF::EM_386:
return Triple::x86;
@ -929,11 +930,16 @@ unsigned ELFObjectFile<ELFT>::getArch() const {
case ELF::EM_HEXAGON:
return Triple::hexagon;
case ELF::EM_MIPS:
return (ELFT::TargetEndianness == support::little) ? Triple::mipsel
: Triple::mips;
switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
case ELF::ELFCLASS32:
return IsLittleEndian ? Triple::mipsel : Triple::mips;
case ELF::ELFCLASS64:
return IsLittleEndian ? Triple::mips64el : Triple::mips64;
default:
report_fatal_error("Invalid ELFCLASS!");
}
case ELF::EM_PPC64:
return (ELFT::TargetEndianness == support::little) ? Triple::ppc64le
: Triple::ppc64;
return IsLittleEndian ? Triple::ppc64le : Triple::ppc64;
case ELF::EM_S390:
return Triple::systemz;

Binary file not shown.

View File

@ -4,6 +4,8 @@ RUN: llvm-readobj -program-headers %p/../../Object/Inputs/program-headers.elf-x8
RUN: | FileCheck %s -check-prefix ELF-X86-64
RUN: llvm-readobj -program-headers %p/../../Object/Inputs/program-headers.mips \
RUN: | FileCheck %s -check-prefix ELF-MIPS
RUN: llvm-readobj -program-headers %p/../../Object/Inputs/program-headers.mips64 \
RUN: | FileCheck %s -check-prefix ELF-MIPS64
ELF-I386: ProgramHeaders [
ELF-I386-NEXT: ProgramHeader {
@ -75,7 +77,11 @@ ELF-X86-64-NEXT: Alignment: 8
ELF-X86-64-NEXT: }
ELF-X86-64-NEXT: ]
ELF-MIPS: ProgramHeaders [
ELF-MIPS: Format: ELF32-mips
ELF-MIPS-NEXT: Arch: mips
ELF-MIPS-NEXT: AddressSize: 32bit
ELF-MIPS-NEXT: LoadName:
ELF-MIPS-NEXT: ProgramHeaders [
ELF-MIPS-NEXT: ProgramHeader {
ELF-MIPS-NEXT: Type: PT_MIPS_REGINFO (0x70000000)
ELF-MIPS-NEXT: Offset: 0x74
@ -102,3 +108,23 @@ ELF-MIPS-NEXT: ]
ELF-MIPS-NEXT: Alignment: 65536
ELF-MIPS-NEXT: }
ELF-MIPS-NEXT: ]
ELF-MIPS64: Format: ELF64-mips
ELF-MIPS64-NEXT: Arch: mips64
ELF-MIPS64-NEXT: AddressSize: 64bit
ELF-MIPS64-NEXT: LoadName:
ELF-MIPS64-NEXT: ProgramHeaders [
ELF-MIPS64-NEXT: ProgramHeader {
ELF-MIPS64-NEXT: Type: PT_LOAD (0x1)
ELF-MIPS64-NEXT: Offset: 0x0
ELF-MIPS64-NEXT: VirtualAddress: 0x120000000
ELF-MIPS64-NEXT: PhysicalAddress: 0x120000000
ELF-MIPS64-NEXT: FileSize: 136
ELF-MIPS64-NEXT: MemSize: 136
ELF-MIPS64-NEXT: Flags [ (0x5)
ELF-MIPS64-NEXT: PF_R (0x4)
ELF-MIPS64-NEXT: PF_X (0x1)
ELF-MIPS64-NEXT: ]
ELF-MIPS64-NEXT: Alignment: 65536
ELF-MIPS64-NEXT: }
ELF-MIPS64-NEXT: ]