From 6fa6a32e4e2fdbb77c82fd7f64a7232cdcac994e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 9 Jul 2008 05:14:23 +0000 Subject: Add a little wrapper header that is put around bc files when emitting bc files for modules with a target triple that indicates they are for darwin. The reader unconditionally handles this, and the writer could turn this on for more targets if we care. This change has two benefits for darwin: 1) it allows us to encode the cpu type of the file in an easy to read place that doesn't require decoding the bc file. 2) it works around a bug (IMO) in darwin's AR where it is incapable of handling files that are not a multiple of 8 bytes long. BC files are only guaranteed to be multiples of 4 bytes long. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53275 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/System/Path.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/System/Path.cpp') diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp index fbb6b6629c..88479fe508 100644 --- a/lib/System/Path.cpp +++ b/lib/System/Path.cpp @@ -52,10 +52,15 @@ Path::GetLLVMConfigDir() { } LLVMFileType -sys::IdentifyFileType(const char*magic, unsigned length) { +sys::IdentifyFileType(const char *magic, unsigned length) { assert(magic && "Invalid magic number string"); assert(length >=4 && "Invalid magic number length"); switch (magic[0]) { + case 0xDE: // 0x0B17C0DE = BC wraper + if (magic[1] == (char)0xC0 && magic[2] == (char)0x17 && + magic[3] == (char)0x0B) + return Bitcode_FileType; + break; case 'B': if (magic[1] == 'C' && magic[2] == (char)0xC0 && magic[3] == (char)0xDE) return Bitcode_FileType; -- cgit v1.2.3