summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/FileSystem.h1
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp1
-rw-r--r--lib/Object/Binary.cpp1
-rw-r--r--lib/Object/ObjectFile.cpp1
-rw-r--r--lib/Support/Path.cpp4
-rw-r--r--test/tools/llvm-readobj/Inputs/magic.coff-importlibbin0 -> 40 bytes
-rw-r--r--test/tools/llvm-readobj/file-headers.test17
-rw-r--r--unittests/Support/Path.cpp2
8 files changed, 27 insertions, 0 deletions
diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h
index 48ff224bcd..d301f842ea 100644
--- a/include/llvm/Support/FileSystem.h
+++ b/include/llvm/Support/FileSystem.h
@@ -238,6 +238,7 @@ struct file_magic {
macho_dsym_companion, ///< Mach-O dSYM companion file
macho_universal_binary, ///< Mach-O universal binary
coff_object, ///< COFF object file
+ coff_import_library, ///< COFF import library
pecoff_executable, ///< PECOFF executable file
windows_resource ///< Windows compiled resource file (.rc)
};
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index 6aa6576e2e..2c068be970 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -584,6 +584,7 @@ ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) {
case sys::fs::file_magic::bitcode:
case sys::fs::file_magic::archive:
case sys::fs::file_magic::coff_object:
+ case sys::fs::file_magic::coff_import_library:
case sys::fs::file_magic::pecoff_executable:
case sys::fs::file_magic::macho_universal_binary:
case sys::fs::file_magic::windows_resource:
diff --git a/lib/Object/Binary.cpp b/lib/Object/Binary.cpp
index d0a7009144..de57b4c9a7 100644
--- a/lib/Object/Binary.cpp
+++ b/lib/Object/Binary.cpp
@@ -91,6 +91,7 @@ error_code object::createBinary(MemoryBuffer *Source,
return object_error::success;
}
case sys::fs::file_magic::coff_object:
+ case sys::fs::file_magic::coff_import_library:
case sys::fs::file_magic::pecoff_executable: {
OwningPtr<Binary> ret(
ObjectFile::createCOFFObjectFile(scopedSource.take()));
diff --git a/lib/Object/ObjectFile.cpp b/lib/Object/ObjectFile.cpp
index 59395c640f..0e626d650f 100644
--- a/lib/Object/ObjectFile.cpp
+++ b/lib/Object/ObjectFile.cpp
@@ -69,6 +69,7 @@ ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
case sys::fs::file_magic::macho_dsym_companion:
return createMachOObjectFile(Object);
case sys::fs::file_magic::coff_object:
+ case sys::fs::file_magic::coff_import_library:
case sys::fs::file_magic::pecoff_executable:
return createCOFFObjectFile(Object);
}
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp
index dfa18aaa6d..c869b30a8e 100644
--- a/lib/Support/Path.cpp
+++ b/lib/Support/Path.cpp
@@ -848,6 +848,10 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
return file_magic::unknown;
switch ((unsigned char)Magic[0]) {
case 0x00: {
+ // COFF short import library file
+ if (Magic[1] == (char)0x00 && Magic[2] == (char)0xff &&
+ Magic[3] == (char)0xff)
+ 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) &&
diff --git a/test/tools/llvm-readobj/Inputs/magic.coff-importlib b/test/tools/llvm-readobj/Inputs/magic.coff-importlib
new file mode 100644
index 0000000000..b934afb41a
--- /dev/null
+++ b/test/tools/llvm-readobj/Inputs/magic.coff-importlib
Binary files differ
diff --git a/test/tools/llvm-readobj/file-headers.test b/test/tools/llvm-readobj/file-headers.test
index d88029addd..b2b454772d 100644
--- a/test/tools/llvm-readobj/file-headers.test
+++ b/test/tools/llvm-readobj/file-headers.test
@@ -10,6 +10,8 @@ RUN: llvm-readobj -h %p/Inputs/trivial.obj.elf-x86-64 \
RUN: | FileCheck %s -check-prefix ELF64
RUN: llvm-readobj -h %p/Inputs/magic.coff-unknown \
RUN: | FileCheck %s -check-prefix COFF-UNKNOWN
+RUN: llvm-readobj -h %p/Inputs/magic.coff-importlib \
+RUN: | FileCheck %s -check-prefix COFF-IMPORTLIB
COFF32: File: {{(.*[/\\])?}}trivial.obj.coff-i386
COFF32-NEXT: Format: COFF-i386
@@ -199,3 +201,18 @@ COFF-UNKNOWN-NEXT: OptionalHeaderSize: 0
COFF-UNKNOWN-NEXT: Characteristics [ (0x0)
COFF-UNKNOWN-NEXT: ]
COFF-UNKNOWN-NEXT: }
+
+COFF-IMPORTLIB: Format: COFF-<unknown arch>
+COFF-IMPORTLIB-NEXT: Arch: unknown
+COFF-IMPORTLIB-NEXT: AddressSize: 32bit
+COFF-IMPORTLIB-NEXT: ImageFileHeader {
+COFF-IMPORTLIB-NEXT: Machine: IMAGE_FILE_MACHINE_UNKNOWN (0x0)
+COFF-IMPORTLIB-NEXT: SectionCount: 65535
+COFF-IMPORTLIB-NEXT: TimeDateStamp: 1970-09-09 19:52:32 (0x14C0000)
+COFF-IMPORTLIB-NEXT: PointerToSymbolTable: 0x528542EB
+COFF-IMPORTLIB-NEXT: SymbolCount: 20
+COFF-IMPORTLIB-NEXT: OptionalHeaderSize: 0
+COFF-IMPORTLIB-NEXT: Characteristics [ (0x8)
+COFF-IMPORTLIB-NEXT: IMAGE_FILE_LOCAL_SYMS_STRIPPED (0x8)
+COFF-IMPORTLIB-NEXT: ]
+COFF-IMPORTLIB-NEXT: }
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index 2323029b58..031624162d 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -419,6 +419,7 @@ TEST_F(FileSystemTest, DirectoryIteration) {
const char archive[] = "!<arch>\x0A";
const char bitcode[] = "\xde\xc0\x17\x0b";
const char coff_object[] = "\x00\x00......";
+const char coff_import_library[] = "\x00\x00\xff\xff....";
const char elf_relocatable[] = { 0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1 };
const char macho_universal_binary[] = "\xca\xfe\xba\xbe...\0x00";
@@ -447,6 +448,7 @@ TEST_F(FileSystemTest, Magic) {
DEFINE(archive),
DEFINE(bitcode),
DEFINE(coff_object),
+ DEFINE(coff_import_library),
DEFINE(elf_relocatable),
DEFINE(macho_universal_binary),
DEFINE(macho_object),