<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Kasun,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The purpose of commit ccba42c7eb3cdfe7824cd4b473a9688e5738fa3a was to fix an issue that was causing incorrect segment file offset alignment for any non-empty segment that happens to start with a section that only contains symbols and no other content. If you look at the test case "ELF/linkerscript/symbol-only-align.test" that might help demonstrate the situation. This particular issue actually resulted in invalid ELF output.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I don't remember all the details, but at the time, this was the simplest fix given the code at that point. The alternatives would have required more significant and riskier changes, and it was a relatively urgent fix given that it was producing invalid ELF output.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">In your issue, just to clarify, is the ELF output from LLD also "large", or is it just the output from the llvm-objcopy operating on that ELF that is "large"? Do you have a simple sample to demonstrate this issue?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thank you.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Regards,</div><div class="gmail_default" style="font-size:small">Andrew</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 29 Mar 2020 at 22:50, Kasun Fernando <<a href="mailto:kasunf@blackmagicdesign.com">kasunf@blackmagicdesign.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi LLVM devs,<br>
<br>
<br>
  I came across an LLD bug in v 10.x where ELF parser / processor is <br>
setting .PROGBITS attribute for .heap and .stack sections, which leads <br>
to large binaries when we do `llvm-objcopy -o binary` to generate the <br>
binary output for armv6m. (e.g. for a 57Kb elf would yield a ~400Mb <br>
binary).<br>
<br>
This in comparison with LLVM 7.x , would produce the correct binary size <br>
of 35Kb and the elf sections have NOBITS for .heap and .stack sections.<br>
<br>
<br>
I narrowed down the problem to the following commit and the commits <br>
around this....Please see below:<br>
<br>
<br>
commit ccba42c7eb3cdfe7824cd4b473a9688e5738fa3a<br>
Author: Andrew Ng <<a href="mailto:anng.sw@gmail.com" target="_blank">anng.sw@gmail.com</a>><br>
Date:   Tue Apr 23 12:38:52 2019 +0000<br>
<br>
     [ELF] Change default output section type to SHT_PROGBITS<br>
<br>
     This fixes an issue where a symbol only section at the start of a<br>
     PT_LOAD segment, causes incorrect alignment of the file offset for the<br>
     start of the segment which results in the output of an invalid ELF.<br>
<br>
     SHT_PROGBITS was the default output section type in the past.<br>
<br>
     Differential Revision: <a href="https://reviews.llvm.org/D60131" rel="noreferrer" target="_blank">https://reviews.llvm.org/D60131</a><br>
<br>
     llvm-svn: 358981<br>
<br>
<br>
commit 5929553868ddfd3f53672253782260c2a0a52c79<br>
Author: Fangrui Song <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>><br>
Date:   Wed Apr 24 14:44:07 2019 +0000<br>
<br>
     [ELF] Delete a redundant SHT_NOBITS -> SHT_PROGBITS after D60131<br>
<br>
     Differential Revision: <a href="https://reviews.llvm.org/D61006" rel="noreferrer" target="_blank">https://reviews.llvm.org/D61006</a><br>
<br>
     llvm-svn: 359099<br>
<br>
<br>
What was the intention behind "Andrew Ng"'s commit? was it an oversight <br>
to set PROGBITS attribute unconditionally for sections that are <br>
allocation only?<br>
<br>
<br>
regards<br>
<br>
Kasun<br>
<br>
<br>
</blockquote></div>