[llvm] r211891 - [ELF][Mips] Fix recognition of MIPS 64-bit arch in the ELFObjectFile:getArch() method.
Simon Atanasyan
simon at atanasyan.com
Fri Jun 27 04:36:45 PDT 2014
Author: atanasyan
Date: Fri Jun 27 06:36:45 2014
New Revision: 211891
URL: http://llvm.org/viewvc/llvm-project?rev=211891&view=rev
Log:
[ELF][Mips] Fix recognition of MIPS 64-bit arch in the ELFObjectFile:getArch() method.
Added:
llvm/trunk/test/Object/Inputs/program-headers.mips64
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/test/tools/llvm-readobj/program-headers.test
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=211891&r1=211890&r2=211891&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Fri Jun 27 06:36:45 2014
@@ -917,6 +917,7 @@ StringRef ELFObjectFile<ELFT>::getFileFo
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()
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;
Added: llvm/trunk/test/Object/Inputs/program-headers.mips64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/program-headers.mips64?rev=211891&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/program-headers.mips64 (added) and llvm/trunk/test/Object/Inputs/program-headers.mips64 Fri Jun 27 06:36:45 2014 differ
Modified: llvm/trunk/test/tools/llvm-readobj/program-headers.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/program-headers.test?rev=211891&r1=211890&r2=211891&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/program-headers.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/program-headers.test Fri Jun 27 06:36:45 2014
@@ -4,6 +4,8 @@ RUN: llvm-readobj -program-headers %p/..
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: ]
More information about the llvm-commits
mailing list