This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Support of compressed debug sections creation(draft).
AbandonedPublic

Authored by grimar on May 12 2016, 9:20 AM.

Details

Reviewers
ruiu
rafael
Summary

This is a draft patch to support creation of all possible types of compressed debug sections.
Patch does not have testcases yet, I am going to update it soon, tomorrow probably.
Would be happy to hear any suggestions/opinions.

A bit belated question, probably: are we going to support that ? That is relatively
new feature, but both bfd/gold do.

Some info about compressed sections can be found at:
https://docs.oracle.com/cd/E53394_01/html/E54813/section_compression.html#scrolltoc
https://docs.oracle.com/cd/E53394_01/html/E54813/man-cds.html

Diff Detail

Event Timeline

grimar updated this revision to Diff 57052.May 12 2016, 9:20 AM
grimar retitled this revision from to [ELF] - Support of compressed debug sections sections (draft). .
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
grimar retitled this revision from [ELF] - Support of compressed debug sections sections (draft). to [ELF] - Support of compressed debug sections creation(draft). .May 12 2016, 9:23 AM
ruiu edited edge metadata.May 12 2016, 10:07 AM

Please add tests to verify that you are producing compressed sections that can be read by other tools.

ELF/Options.td
33

This help text is out of context.

ELF/OutputSections.cpp
833–837

Clang-format.

842

Please don't use an unrelated object's members.

859–862

This code creates an uncompressed a debug section in memory and then compress it at once. It consumes as much memory as the total size of the debug section. It is probably unacceptable.

zlib supports "streaming" compression, right? I think you can pass pieces of data to zlib object and let it construct compressed data incrementally. Please do that way so that the maximum memory is bounded to the largest input section size instead of the largest output section size.

869–874

I think we don't have to care about this edge case. Unless you are compressing random bits, it usually shrink.

1014–1025

Why we have two types of headers? If one is obsolete, we probably don't want to implement it.

ELF/Writer.cpp
1161–1163

You can move this to OutputSection class, no?

1172

This condition should be at the beginning of this function.

emaste added a subscriber: emaste.May 12 2016, 10:11 AM

are we going to support that

I would find it useful.

ruiu added a comment.May 12 2016, 10:12 AM

Yes, we want it.

grimar added inline comments.May 13 2016, 4:35 AM
ELF/OutputSections.cpp
842

Yep, I know, that is just because it was a draft patch.
I was thinking about it when did that. What is the good way ?
Actually I do not like how it is done now: we have lots of StringSaver instances in many places in lld.
Are there reasons for that instead of having one StringSaver for all with single Alloc and just global reference to it ?

869–874

I would leave it as is. That is mentioned in docs: "The .debug_line and .debug_pubnames sections would be larger compressed than in their original uncompressed form, and have therefore been left uncompressed." (https://docs.oracle.com/cd/E53394_01/html/E54813/section_compression.html#scrolltoc) and done both by gold/bfd and very transparent in implementation.
In addition I think that if feature is used then motivation and expected result is to consume less space, I do not think it is acceptable to consume more than without it, it is confusing and opposite to its description.

1014–1025

There are 2 different approaches used (https://docs.oracle.com/cd/E53394_01/html/E54813/section_compression.html):

  1. gnu-style renames sections to ".z*[NAME]" and do not uses SHF_COMPRESSED.
  2. zlib style. Sections have SHF_COMPRESSED flag and are not renamed.

"Unless there is a specific requirement to use the zlib-gnu style, the more general default zlib style is recommended." says https://docs.oracle.com/cd/E53394_01/html/E54813/man-cds.html, but it is not mentioned if that depricated or something.
Not supporting of zlib-gnu style would make implementation a bit cleaner.

It is not hard to support both though.

ELF/Writer.cpp
1172

Actually I assumed that is low user path to have zlib not available.
btw, since I am on windows I had some problems with it, it is well described at https://llvm.org/bugs/show_bug.cgi?id=19403.
So windows users currently will not able to use that feature atm, all *nix ones probably already have zlib installed.

But ok, I`ll move that since it is also logical for me that we first check if feature available at first before any other conditions.

rafael edited edge metadata.May 13 2016, 6:26 AM
rafael added a subscriber: rafael.

ruiu wrote:

I think we don't have to care about this edge case. Unless you are compressing random bits, it usually shrink.

I would leave it as is. That is mentioned in docs: "The .debug_line and .debug_pubnames sections would be larger compressed than in their original uncompressed form, and have therefore been left uncompressed." (https://docs.oracle.com/cd/E53394_01/html/E54813/section_compression.html#scrolltoc) and done both by gold/bfd and very transparent in implementation.
In addition I think that if feature is used then motivation and expected result is to consume less space, I do not think it is acceptable to consume more than without it, it is confusing and opposite to its description.

I think we can start without this and see how many case we hit in the
field when it gets bigger.

ruiu wrote:

Why we have two types of headers? If one is obsolete, we probably don't want to implement it.

There are 2 different approaches used (https://docs.oracle.com/cd/E53394_01/html/E54813/section_compression.html):

  1. gnu-style renames sections to ".z*[NAME]" and do not uses SHF_COMPRESSED.
  2. zlib style. Sections have SHF_COMPRESSED flag and are not renamed.

"Unless there is a specific requirement to use the zlib-gnu style, the more general default zlib style is recommended." says https://docs.oracle.com/cd/E53394_01/html/E54813/man-cds.html, but it is not mentioned if that depricated or something.
Not supporting of zlib-gnu style would make implementation a bit cleaner.

It is not hard to support both though.

Lets please start without support of the gnu style.

Cheers,
Rafael

So, currently we are putting this on hold, right ?

Patch implementing support for compressed input sections is prepared here: D20272

grimar added a comment.Jun 7 2016, 7:03 AM

If we do not plan to support compressed output sections, I would abandon this. Should I ? Rafael, Rui ?
Otherwise I can update this one.

grimar abandoned this revision.Jun 7 2016, 11:23 PM

Dropping it unless we find someone that is using this.