[llvm-commits] [llvm] r159138 - in /llvm/trunk: lib/Support/Path.cpp test/MC/Mips/elf-objdump.s
Meador Inge
meadori at codesourcery.com
Mon Jun 25 07:48:43 PDT 2012
Author: meadori
Date: Mon Jun 25 09:48:43 2012
New Revision: 159138
URL: http://llvm.org/viewvc/llvm-project?rev=159138&view=rev
Log:
PR13013: ELF Type identification fails for MSB type ELF files.
Fix 'sys::IdentifyFileType' to work with big and little endian byte orderings
when reading the ELF object file type.
Initial patch by Stefan Hepp.
Added:
llvm/trunk/test/MC/Mips/elf-objdump.s
Modified:
llvm/trunk/lib/Support/Path.cpp
Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=159138&r1=159137&r2=159138&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Mon Jun 25 09:48:43 2012
@@ -60,8 +60,11 @@
case '\177':
if (magic[1] == 'E' && magic[2] == 'L' && magic[3] == 'F') {
- if (length >= 18 && magic[17] == 0)
- switch (magic[16]) {
+ bool Data2MSB = magic[5] == 2;
+ unsigned high = Data2MSB ? 16 : 17;
+ unsigned low = Data2MSB ? 17 : 16;
+ if (length >= 18 && magic[high] == 0)
+ switch (magic[low]) {
default: break;
case 1: return ELF_Relocatable_FileType;
case 2: return ELF_Executable_FileType;
Added: llvm/trunk/test/MC/Mips/elf-objdump.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/elf-objdump.s?rev=159138&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/elf-objdump.s (added)
+++ llvm/trunk/test/MC/Mips/elf-objdump.s Mon Jun 25 09:48:43 2012
@@ -0,0 +1,11 @@
+// 32 bit big endian
+// RUN: llvm-mc -filetype=obj -triple mips-unknown-linux %s -o - | llvm-objdump -d -triple mips-unknown-linux - | FileCheck %s
+// 32 bit little endian
+// RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o - | llvm-objdump -d -triple mips-unknown-linux - | FileCheck %s
+// 64 bit big endian
+// RUN: llvm-mc -filetype=obj -arch=mips64 -triple mips64-unknown-linux %s -o - | llvm-objdump -d -triple mips-unknown-linux - | FileCheck %s
+// 64 bit little endian
+// RUN: llvm-mc -filetype=obj -arch=mips64el -triple mips64el-unknown-linux %s -o - | llvm-objdump -d -triple mips-unknown-linux - | FileCheck %s
+
+// We just want to see if llvm-objdump works at all.
+// CHECK: .text
More information about the llvm-commits
mailing list