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
This commit is contained in:
Chris Lattner
2008-07-09 05:14:23 +00:00
parent b02b8af378
commit 6fa6a32e4e
5 changed files with 179 additions and 9 deletions

View File

@ -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;