[Lldb-commits] [PATCH] D40079: Make sure DataBufferLLVM contents are writable

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 15 09:42:29 PST 2017

Can we just extend llvm's mapped_file_region to support a boolean Writable

On Wed, Nov 15, 2017 at 8:03 AM Pavel Labath via Phabricator <
reviews at reviews.llvm.org> wrote:

> labath created this revision.
> Herald added subscribers: krytarowski, arichardson, aprantl, emaste.
> We sometimes need to write to the object file we've mapped into memory,
> generally to apply relocations to debug info sections. We've had that
> ability before, but with the introduction of DataBufferLLVM, we have
> lost it, as the underlying llvm class (MemoryBuffer) only supports
> read-only mappings. The way DataBufferLLVM implemented writable buffers
> was through the Private=true flag, which causes the file contents to be
> read into a malloc()ed buffer.
> This wasn't a problem then, since we weren't aware of any cases where we
> need to relocate the debug info, and we just always set Private=false
> for the cases where we mmapped the full object file. This has changed in
> https://reviews.llvm.org/D38142, where needed to relocate the FreeBSD
> kernel, and we've flipped
> the private flag to true, without even realising the full impact of
> that. (The impact is significant slowdown in debug info loading and a
> huge number of dirty pages).
> This (not particularly elegant) commit tries to restore the performance
> and bring down memory usage by bringing back the private copy-on-write
> file mappings. It does this by falling back to the lower-level llvm
> primitive (mapped_file_region), which supports this type of mappings.
> Unfortunately, this primitive does not support non-mmapped regions, so
> for volatile regions I have to still use the MemoryBuffer class.
> I have also removed the "Private" argument to DataBufferLLVM factory
> functions -- what it really meant was "read-only", but we generally
> assume all our databuffers are writable. If we ever want to have
> read-only buffers, we can bring it back with an appropriate name.
> https://reviews.llvm.org/D40079
> Files:
>   include/lldb/Utility/DataBufferLLVM.h
>   source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
>   source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
>   source/Utility/DataBufferLLVM.cpp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171115/a030afd3/attachment.html>

More information about the lldb-commits mailing list