summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2013-04-05 20:10:04 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2013-04-05 20:10:04 +0000
commitb8055cbc9dde9d1386d85f1e6f0876cef1646c87 (patch)
treec91079b3b6908eeb4153d101a05a54d950cfd9d0 /llvm/lib
parent3add3e9c4aecc83c5dad9e5886282c68c5a5f69c (diff)
downloadbcm5719-llvm-b8055cbc9dde9d1386d85f1e6f0876cef1646c87.tar.gz
bcm5719-llvm-b8055cbc9dde9d1386d85f1e6f0876cef1646c87.zip
[Support][FileSystem] Fix identify_magic for big endian ELF.
llvm-svn: 178905
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/PathV2.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp
index 58a6ea720e7..ac53a9e9e6b 100644
--- a/llvm/lib/Support/PathV2.cpp
+++ b/llvm/lib/Support/PathV2.cpp
@@ -789,8 +789,11 @@ file_magic identify_magic(StringRef magic) {
case '\177':
if (magic[1] == 'E' && magic[2] == 'L' && magic[3] == 'F') {
- if (magic.size() >= 18 && magic[17] == 0)
- switch (magic[16]) {
+ bool Data2MSB = magic[5] == 2;
+ unsigned high = Data2MSB ? 16 : 17;
+ unsigned low = Data2MSB ? 17 : 16;
+ if (magic.size() >= 18 && magic[high] == 0)
+ switch (magic[low]) {
default: break;
case 1: return file_magic::elf_relocatable;
case 2: return file_magic::elf_executable;
OpenPOWER on IntegriCloud