summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Path.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-09-11 21:09:57 +0000
committerRui Ueyama <ruiu@google.com>2014-09-11 21:09:57 +0000
commit2acb05843b6dd1a120aede664366444f3fedcbdb (patch)
tree83048b0dc0b8012f89d141a602b549bc275152b1 /llvm/lib/Support/Path.cpp
parent5d8f698ec194dbdb2c8c92abce02c9e82ae21b5c (diff)
downloadbcm5719-llvm-2acb05843b6dd1a120aede664366444f3fedcbdb.tar.gz
bcm5719-llvm-2acb05843b6dd1a120aede664366444f3fedcbdb.zip
Support: improve identify_magic to recognize COFF bigobj
identify_magic recognized a COFF bigobj as an import library file. This patch fixes that. llvm-svn: 217627
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r--llvm/lib/Support/Path.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index ef75fc1cd83..4d69b25f8fc 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -901,10 +901,16 @@ file_magic identify_magic(StringRef Magic) {
return file_magic::unknown;
switch ((unsigned char)Magic[0]) {
case 0x00: {
- // COFF short import library file
+ // COFF bigobj or short import library file
if (Magic[1] == (char)0x00 && Magic[2] == (char)0xff &&
- Magic[3] == (char)0xff)
- return file_magic::coff_import_library;
+ Magic[3] == (char)0xff) {
+ const char BigobjMagic[] =
+ "\xc7\xa1\xba\xd1\xee\xba\xa9\x4b\xaf\x20\xfa\xf6\x6a\xa4\xdc\xb8";
+ if (Magic.size() >= 28 &&
+ memcmp(Magic.data() + 12, BigobjMagic, sizeof(BigobjMagic)) == 0)
+ return file_magic::coff_object;
+ return file_magic::coff_import_library;
+ }
// Windows resource file
const char Expected[] = { 0, 0, 0, 0, '\x20', 0, 0, 0, '\xff' };
if (Magic.size() >= sizeof(Expected) &&
OpenPOWER on IntegriCloud