summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Path.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-11-15 00:54:54 +0000
committerRui Ueyama <ruiu@google.com>2016-11-15 00:54:54 +0000
commit2d02166b430737a7ca910bfe72946b4119673da2 (patch)
tree0d5a50c0cbed9d402c16a176e328bca5472a7f78 /llvm/lib/Support/Path.cpp
parent07a6ae96fb0b309845ff0664b5b4aa21f7eb5327 (diff)
downloadbcm5719-llvm-2d02166b430737a7ca910bfe72946b4119673da2.tar.gz
bcm5719-llvm-2d02166b430737a7ca910bfe72946b4119673da2.zip
Add a file magic for CL.exe's object file created with /GL.
This patch makes it possible to identify object files created by CL.exe with /GL option. Such file contains Microsoft proprietary intermediate code instead of target machine code to do LTO. I need this to print out user-friendly error message from LLD. Differential Revision: https://reviews.llvm.org/D26645 llvm-svn: 286919
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r--llvm/lib/Support/Path.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index b2d645779b0..49279d03b76 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -986,22 +986,18 @@ file_magic identify_magic(StringRef Magic) {
return file_magic::unknown;
switch ((unsigned char)Magic[0]) {
case 0x00: {
- // COFF bigobj or short import library file
- if (Magic[1] == (char)0x00 && Magic[2] == (char)0xff &&
- Magic[3] == (char)0xff) {
+ // COFF bigobj, CL.exe's LTO object file, or short import library file
+ if (memcmp(Magic.data() + 1, "\0\xFF\xFF", 3) == 0) {
size_t MinSize = offsetof(COFF::BigObjHeader, UUID) + sizeof(COFF::BigObjMagic);
if (Magic.size() < MinSize)
return file_magic::coff_import_library;
- int BigObjVersion = read16le(
- Magic.data() + offsetof(COFF::BigObjHeader, Version));
- if (BigObjVersion < COFF::BigObjHeader::MinBigObjectVersion)
- return file_magic::coff_import_library;
-
const char *Start = Magic.data() + offsetof(COFF::BigObjHeader, UUID);
- if (memcmp(Start, COFF::BigObjMagic, sizeof(COFF::BigObjMagic)) != 0)
- return file_magic::coff_import_library;
- return file_magic::coff_object;
+ if (memcmp(Start, COFF::BigObjMagic, sizeof(COFF::BigObjMagic)) == 0)
+ return file_magic::coff_object;
+ if (memcmp(Start, COFF::ClGlObjMagic, sizeof(COFF::BigObjMagic)) == 0)
+ return file_magic::coff_cl_gl_object;
+ return file_magic::coff_import_library;
}
// Windows resource file
const char Expected[] = { 0, 0, 0, 0, '\x20', 0, 0, 0, '\xff' };
OpenPOWER on IntegriCloud