summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-09-27 16:59:06 +0000
committerChris Lattner <sabre@nondot.org>2004-09-27 16:59:06 +0000
commitd7dc1ecd4292cf88488c9514c99b7e71ab63ce3f (patch)
tree0b56e70623b40d015480fe5ea46d54ebb905d4c9 /llvm/lib/Bytecode/Reader/Reader.cpp
parentdbf0a565974b38d11029baa7575c1b71d5fa687c (diff)
downloadbcm5719-llvm-d7dc1ecd4292cf88488c9514c99b7e71ab63ce3f.tar.gz
bcm5719-llvm-d7dc1ecd4292cf88488c9514c99b7e71ab63ce3f.zip
The system ranlib on darwin occasionally adds two extra newlines to the
end of files, breaking the CFE build. As a gross hack around this, ignore any trailing garbage on bytecode files. Thanks to Brian for digging in and identifying the problem. llvm-svn: 16525
Diffstat (limited to 'llvm/lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--llvm/lib/Bytecode/Reader/Reader.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp
index 18780208e2b..d44003c73a1 100644
--- a/llvm/lib/Bytecode/Reader/Reader.cpp
+++ b/llvm/lib/Bytecode/Reader/Reader.cpp
@@ -2139,10 +2139,16 @@ void BytecodeReader::ParseBytecode(BufPtr Buf, unsigned Length,
error("Expected Module Block! Type:" + utostr(Type) + ", Size:"
+ utostr(Size));
}
- if (At + Size != MemEnd) {
+
+ // It looks like the darwin ranlib program is broken, and adds trailing
+ // garbage to the end of some bytecode files. This hack allows the bc
+ // reader to ignore trailing garbage on bytecode files.
+ if (At + Size < MemEnd)
+ MemEnd = BlockEnd = At+Size;
+
+ if (At + Size != MemEnd)
error("Invalid Top Level Block Length! Type:" + utostr(Type)
+ ", Size:" + utostr(Size));
- }
// Parse the module contents
this->ParseModule();
OpenPOWER on IntegriCloud