aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2021-12-08 13:24:45 +0100
committerJan Svoboda <jan_svoboda@apple.com>2021-12-09 11:32:13 +0100
commitd0262c2394f46bb7da2a75529413d625c70908e5 (patch)
tree919e5bad5211507ec4c1692813f1495aba8b0840 /llvm/tools/llvm-objcopy/llvm-objcopy.cpp
parente04fc2d88efa60ed5527b90c15d8fc188739e989 (diff)
downloadllvm-d0262c2394f46bb7da2a75529413d625c70908e5.zip
llvm-d0262c2394f46bb7da2a75529413d625c70908e5.tar.gz
llvm-d0262c2394f46bb7da2a75529413d625c70908e5.tar.bz2
[llvm] Add null-termination capability to SmallVectorMemoryBuffer
Most of `MemoryBuffer` interfaces expose a `RequiresNullTerminator` parameter that's being used to: * determine how to open a file (`mmap` vs `open`), * assert newly initialized buffer indeed has an implicit null terminator. This patch adds the paramater to the `SmallVectorMemoryBuffer` constructors, meaning: * null terminator can now be added to `SmallVector`s that didn't have one before, * `SmallVectors` that had a null terminator before keep it even after the move. In line with existing code, the new parameter is defaulted to `true`. This patch makes sure all calls to the `SmallVectorMemoryBuffer` constructor set it to `false` to preserve the current semantics. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D115331
Diffstat (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/llvm-objcopy.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index ad16648..a596398 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -236,7 +236,8 @@ createNewArchiveMembers(const MultiFormatConfig &Config, const Archive &Ar) {
return createFileError(Ar.getFileName(), Member.takeError());
Member->Buf = std::make_unique<SmallVectorMemoryBuffer>(
- std::move(Buffer), ChildNameOrErr.get());
+ std::move(Buffer), ChildNameOrErr.get(),
+ /*RequiresNullTerminator=*/false);
Member->MemberName = Member->Buf->getBufferIdentifier();
NewArchiveMembers.push_back(std::move(*Member));
}