[llvm-dev] LLD bug causing objcopy ELF to binary generation to create large binaries

Andrew Ng via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 30 03:50:36 PDT 2020


Hi Kasun,

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.

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.

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?

Thank you.

Regards,
Andrew

On Sun, 29 Mar 2020 at 22:50, Kasun Fernando <kasunf at blackmagicdesign.com>
wrote:

> Hi LLVM devs,
>
>
>   I came across an LLD bug in v 10.x where ELF parser / processor is
> setting .PROGBITS attribute for .heap and .stack sections, which leads
> to large binaries when we do `llvm-objcopy -o binary` to generate the
> binary output for armv6m. (e.g. for a 57Kb elf would yield a ~400Mb
> binary).
>
> This in comparison with LLVM 7.x , would produce the correct binary size
> of 35Kb and the elf sections have NOBITS for .heap and .stack sections.
>
>
> I narrowed down the problem to the following commit and the commits
> around this....Please see below:
>
>
> commit ccba42c7eb3cdfe7824cd4b473a9688e5738fa3a
> Author: Andrew Ng <anng.sw at gmail.com>
> Date:   Tue Apr 23 12:38:52 2019 +0000
>
>      [ELF] Change default output section type to SHT_PROGBITS
>
>      This fixes an issue where a symbol only section at the start of a
>      PT_LOAD segment, causes incorrect alignment of the file offset for the
>      start of the segment which results in the output of an invalid ELF.
>
>      SHT_PROGBITS was the default output section type in the past.
>
>      Differential Revision: https://reviews.llvm.org/D60131
>
>      llvm-svn: 358981
>
>
> commit 5929553868ddfd3f53672253782260c2a0a52c79
> Author: Fangrui Song <maskray at google.com>
> Date:   Wed Apr 24 14:44:07 2019 +0000
>
>      [ELF] Delete a redundant SHT_NOBITS -> SHT_PROGBITS after D60131
>
>      Differential Revision: https://reviews.llvm.org/D61006
>
>      llvm-svn: 359099
>
>
> What was the intention behind "Andrew Ng"'s commit? was it an oversight
> to set PROGBITS attribute unconditionally for sections that are
> allocation only?
>
>
> regards
>
> Kasun
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200330/92e36d2f/attachment-0001.html>


More information about the llvm-dev mailing list