[PATCH] D66149: [BinaryFormat] Teach identify_magic about Tapi files.
Cyndy Ishida via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 11:36:57 PDT 2019
cishida updated this revision to Diff 215181.
cishida added a comment.
This revision is now accepted and ready to land.
Reverse order of conditional for file_magic
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66149/new/
https://reviews.llvm.org/D66149
Files:
llvm/include/llvm/BinaryFormat/Magic.h
llvm/lib/BinaryFormat/Magic.cpp
llvm/lib/Object/Binary.cpp
llvm/lib/Object/ObjectFile.cpp
llvm/lib/Object/SymbolicFile.cpp
llvm/unittests/BinaryFormat/TestFileMagic.cpp
Index: llvm/unittests/BinaryFormat/TestFileMagic.cpp
===================================================================
--- llvm/unittests/BinaryFormat/TestFileMagic.cpp
+++ llvm/unittests/BinaryFormat/TestFileMagic.cpp
@@ -82,6 +82,8 @@
const char ms_dos_stub_broken[] = "\x4d\x5a\x20\x20";
const char pdb[] = "Microsoft C/C++ MSF 7.00\r\n\x1a"
"DS\x00\x00\x00";
+const char tapi_file[] = "--- !tapi-tbd-v1\n";
+const char tapi_file_tbd_v1[] = "---\narchs: [";
TEST_F(MagicTest, Magic) {
struct type {
@@ -114,6 +116,9 @@
DEFINE(pdb),
{"ms_dos_stub_broken", ms_dos_stub_broken, sizeof(ms_dos_stub_broken),
file_magic::unknown},
+ DEFINE(tapi_file),
+ {"tapi_file_tbd_v1", tapi_file_tbd_v1, sizeof(tapi_file_tbd_v1),
+ file_magic::tapi_file},
#undef DEFINE
};
Index: llvm/lib/Object/SymbolicFile.cpp
===================================================================
--- llvm/lib/Object/SymbolicFile.cpp
+++ llvm/lib/Object/SymbolicFile.cpp
@@ -53,6 +53,7 @@
case file_magic::windows_resource:
case file_magic::pdb:
case file_magic::minidump:
+ case file_magic::tapi_file:
return errorCodeToError(object_error::invalid_file_type);
case file_magic::elf:
case file_magic::elf_executable:
Index: llvm/lib/Object/ObjectFile.cpp
===================================================================
--- llvm/lib/Object/ObjectFile.cpp
+++ llvm/lib/Object/ObjectFile.cpp
@@ -127,6 +127,8 @@
case file_magic::pdb:
case file_magic::minidump:
return errorCodeToError(object_error::invalid_file_type);
+ case file_magic::tapi_file:
+ return errorCodeToError(object_error::invalid_file_type);
case file_magic::elf:
case file_magic::elf_relocatable:
case file_magic::elf_executable:
Index: llvm/lib/Object/Binary.cpp
===================================================================
--- llvm/lib/Object/Binary.cpp
+++ llvm/lib/Object/Binary.cpp
@@ -86,6 +86,9 @@
return errorCodeToError(object_error::invalid_file_type);
case file_magic::minidump:
return MinidumpFile::create(Buffer);
+ case file_magic::tapi_file:
+ // Placeholder until TAPI is supported for lib/Object
+ return errorCodeToError(object_error::invalid_file_type);
}
llvm_unreachable("Unexpected Binary File Type");
}
Index: llvm/lib/BinaryFormat/Magic.cpp
===================================================================
--- llvm/lib/BinaryFormat/Magic.cpp
+++ llvm/lib/BinaryFormat/Magic.cpp
@@ -210,6 +210,11 @@
return file_magic::coff_object;
break;
+ case 0x2d: // YAML '-'
+ if (startswith(Magic, "--- !tapi") || startswith(Magic, "---\narchs:"))
+ return file_magic::tapi_file;
+ break;
+
default:
break;
}
Index: llvm/include/llvm/BinaryFormat/Magic.h
===================================================================
--- llvm/include/llvm/BinaryFormat/Magic.h
+++ llvm/include/llvm/BinaryFormat/Magic.h
@@ -49,6 +49,7 @@
xcoff_object_64, ///< 64-bit XCOFF object file
wasm_object, ///< WebAssembly Object file
pdb, ///< Windows PDB debug info file
+ tapi_file, ///< Text-based Dynamic Library Stub file
};
bool is_object() const { return V != unknown; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66149.215181.patch
Type: text/x-patch
Size: 3268 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190814/61ea4e20/attachment.bin>
More information about the llvm-commits
mailing list