Pass the computed magic to createBinary and createObjectFile if available.
[oota-llvm.git] / lib / Object / ObjectFile.cpp
index fd2b024687c8462ef6475b0e12cd086bbb2c1782..6b14e78ff3d83b5dd94cc6871cda487a487bd385 100644 (file)
@@ -37,9 +37,11 @@ section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const {
   return section_iterator(SectionRef(Sec, this));
 }
 
-ErrorOr<ObjectFile *> ObjectFile::createObjectFile(MemoryBuffer *Object) {
+ErrorOr<ObjectFile *> ObjectFile::createObjectFile(MemoryBuffer *Object,
+                                                   sys::fs::file_magic Type) {
   OwningPtr<MemoryBuffer> ScopedObj(Object);
-  sys::fs::file_magic Type = sys::fs::identify_magic(Object->getBuffer());
+  if (Type == sys::fs::file_magic::unknown)
+    Type = sys::fs::identify_magic(Object->getBuffer());
 
   switch (Type) {
   case sys::fs::file_magic::unknown: