[PATCH] D40291: [Support] Add WritableMemoryBuffer class

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 03:18:14 PST 2017


labath created this revision.

The motivation here is LLDB, where we need to fixup relocations in
mmapped files before their contents can be read correctly.  The
MemoryBuffer class does exactly what we need, *except* that it maps the
file in read-only mode.

MutableMemoryBuffer reuses the existing machinery for opening and
mmapping a file. The only difference is in the argument to the
mapped_file_region constructor -- we create a private copy-on-write
mapping, so that we can make changes to the mapped data, but the changes
aren't carried over to the underlying file.

This patch is based on an initial version by Zachary Turner.


https://reviews.llvm.org/D40291

Files:
  include/llvm/Support/MemoryBuffer.h
  lib/Support/MemoryBuffer.cpp
  unittests/Support/MemoryBufferTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40291.123752.patch
Type: text/x-patch
Size: 10720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171121/00015c13/attachment.bin>


More information about the llvm-commits mailing list