<div dir="ltr"><div class="gmail_extra"><div>On Tue, Apr 16, 2013 at 2:37 AM, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>></span> wrote:<br></div><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi!<div><br></div><div>TL;DR WDYT of adding zlib decompression capabilities to LLVMObject library?</div>
</div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>ld.gold from GNU binutils has --compress-debug-sections=zlib option,</div>
<div>
which uses zlib to compress .debug_xxx sections and renames them to .zdebug_xxx.</div><div>binutils (and GDB) support this properly, while LLVM command line tools don't:</div><div><div><br></div><div>$ ld --version</div>

<div>GNU gold (GNU Binutils for Ubuntu 2.22) 1.11</div></div><div>$ ./bin/clang++ -g a.cc -Wl,--compress-debug-sections=zlib<br></div><div><div>$ objdump -h a.out | grep debug</div><div> 26 .debug_info   00000066  0000000000000000  0000000000000000  00002010  2**0</div>

<div> 27 .debug_abbrev 00000048  0000000000000000  0000000000000000  00002068  2**0</div><div> 28 .debug_aranges 00000000  0000000000000000  0000000000000000  000020bb  2**0</div><div> 29 .debug_macinfo 00000000  0000000000000000  0000000000000000  000020cf  2**0</div>

<div> 30 .debug_line   00000053  0000000000000000  0000000000000000  000020e3  2**0</div><div> 31 .debug_loc    00000000  0000000000000000  0000000000000000  0000213e  2**0</div><div> 32 .debug_pubtypes 00000000  0000000000000000  0000000000000000  00002152  2**0</div>

<div> 33 .debug_str    00000069  0000000000000000  0000000000000000  00002166  2**0</div><div> 34 .debug_ranges 00000000  0000000000000000  0000000000000000  000021d9  2**0</div></div><div><div>$ ./bin/llvm-objdump -h a.out | grep debug</div>

<div> 27 .zdebug_info  00000058 0000000000000000 </div><div> 28 .zdebug_abbrev 00000053 0000000000000000 </div><div> 29 .zdebug_aranges 00000014 0000000000000000 </div><div> 30 .zdebug_macinfo 00000014 0000000000000000 </div>

<div> 31 .zdebug_line  0000005b 0000000000000000 </div><div> 32 .zdebug_loc   00000014 0000000000000000 </div><div> 33 .zdebug_pubtypes 00000014 0000000000000000 </div><div> 34 .zdebug_str   00000073 0000000000000000 </div>

<div> 35 .zdebug_ranges 00000014 0000000000000000</div></div><div><br></div><div>Decompression and proper handling of debug info sections may be needed</div><div>in llvm-dwarfdump and llvm-symbolizer tools. We can implement this by:</div>

<div>1) Checking if zlib is present in the system during configuration.</div><div>2) Adding zlib decompression to llvm::MemoryBuffer, and section decompression to LLVMObject (this would require optional linking with -lz).</div>

<div>3) Using the methods in LLVM tools where needed.</div><div><br></div><div>Does this make sense to you?</div><span class=""><font color="#888888"><div><br></div><div>-- <br></div><div><div>Alexey Samsonov, MSK</div></div>
</font></span></div></blockquote><div><br></div><div style>I'm not sure MemoryBuffer is the right place to do this either. I'm also not sure if we want debug info decompression to be transparent in LLVMObject or not. I'm leaning towards no since it's not part of the standard yet, unless gold is actually using the SHF_COMPRESSED flag.</div>
<div style><br></div><div style>I think it should be part of Object, but as an external API that is used when you find a section you know from external factors (the name matches some list) is compressed.</div><div><br></div>
<div>- Michael Spencer</div><div> </div></div></div></div>