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

Kasun Fernando via llvm-dev llvm-dev at lists.llvm.org
Sun Mar 29 14:50:12 PDT 2020


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




More information about the llvm-dev mailing list