[PATCH] D32289: [ELF] - Linkerscript: support combination of linkerscript and --compress-debug-sections.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 03:34:52 PDT 2017


>George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
>> Index: ELF/OutputSections.cpp
>> ===================================================================
>> --- ELF/OutputSections.cpp
>> +++ ELF/OutputSections.cpp
>> @@ -93,6 +93,10 @@
>>        !Name.startswith(".debug_"))
>>      return;
>>
>> +  // We call maybeCompress() early and for linkerscript case need to assign offsets,
>> +  // because that was not done yet. That finalizes mergeable synthetic sections.
>> +  assignOffsets();
>> +
>
>It seems wrong to this in here.
>
>In the most general case (like for thunks), we will have to run
>assignAddresses multiple times.
>
>For debug info it should be trivial to change processCommands to compute
>the offsets.

I dont think I can simply set offsets in processCommands because for case when 
.debug_* sections are orphans: "SECTIONS {  }"
there is no commands for them at the point of call.

Intention to call assignOffsets() is not only to assign offsets, but
also to find the final output section size for doing compression.
Then when I assign the compressed size to OutputSection::Size, the latter should 
never be recalculated, because it is final value. I believe that requires
a bit different handling in LinkerScript::process, because we should not
work with input sections or any other commands anymore for compressed case.

I updated the patch and improved testcase. Debug string sections were mergeable
previously what resulted in a single synthetic mergeable input section, 
I added non-mergeable sections to demonstrate that offsets assigning and
compression-decompression works in this case.

>BTW, should we avoid compressing or error out if the linker script has a
>symbol assignment? For example:
>
>SECTIONS {
>.debug_str : { *(foo) sym=.; *(bar) }
>}
>
>Cheers,
>Rafael

George.


More information about the llvm-commits mailing list