summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/Binary.cpp
diff options
context:
space:
mode:
authorDavid Major <dmajor@mozilla.com>2019-01-09 23:36:32 +0000
committerDavid Major <dmajor@mozilla.com>2019-01-09 23:36:32 +0000
commit30ba0a0c950a0cdf23a70fce6c16d501c5f238c8 (patch)
tree15bca9082414c8a958960309d18180999070afc7 /llvm/lib/Object/Binary.cpp
parentf3a4770475c7d503ed66667f0085f0cdbfc3bbe9 (diff)
downloadbcm5719-llvm-30ba0a0c950a0cdf23a70fce6c16d501c5f238c8.tar.gz
bcm5719-llvm-30ba0a0c950a0cdf23a70fce6c16d501c5f238c8.zip
Don't require a null terminator when loading objects
When a null terminator is required and the file size is a multiple of the system page size, MemoryBuffer will prefer pread() over mmap(), which can result in excessive memory usage. Patch by Mike Hommey! Differential Revision: https://reviews.llvm.org/D56475 llvm-svn: 350774
Diffstat (limited to 'llvm/lib/Object/Binary.cpp')
-rw-r--r--llvm/lib/Object/Binary.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp
index d7c25921ec3..fe41987f5c2 100644
--- a/llvm/lib/Object/Binary.cpp
+++ b/llvm/lib/Object/Binary.cpp
@@ -88,7 +88,8 @@ Expected<std::unique_ptr<Binary>> object::createBinary(MemoryBufferRef Buffer,
Expected<OwningBinary<Binary>> object::createBinary(StringRef Path) {
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
- MemoryBuffer::getFileOrSTDIN(Path);
+ MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
+ /*RequiresNullTerminator=*/false);
if (std::error_code EC = FileOrErr.getError())
return errorCodeToError(EC);
std::unique_ptr<MemoryBuffer> &Buffer = FileOrErr.get();
OpenPOWER on IntegriCloud