[PATCH] D52917: Avoid unnecessary buffer allocation and memcpy for compressed sections.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 4 17:36:10 PDT 2018


ruiu added a comment.

> Out of curiosity - does LLD support compressed output? How/where does it do that? It'd be super nifty if it'd stream in the compressed data and stream it out through compression without having to have it all decompressed in memory. But that might hit problems with relocations that use the bytes in the section as part of the relocation computation :/

lld supports compressed output. When an output section compression is enabled, we allocate a temporary buffer and pass that buffer to `writeTo()` as if it were a real output buffer. Then, `writeTo()` copies input sections to a given buffer and apply relocations. We then compress it and write to a real output buffer.

As you guessed, I don't think we can stream-compress output section contents because relocation application is essentially a random access to the output buffer.



================
Comment at: lld/ELF/InputSection.cpp:144
+  size_t Size = UncompressedSize;
+  UncompressedBuf.reset(new char[Size]());
+
----------------
dblaikie wrote:
> Did you intend to zero out this allocation? (the '()' after the [] will cause the array to be zero initialized, I think - which might be unnecessary if you're about to write to all the bytes anyway?)
Ah thanks. We don't have to initialize the buffer.


https://reviews.llvm.org/D52917





More information about the llvm-commits mailing list