https://bugs.llvm.org/show_bug.cgi?id=42277

            Bug ID: 42277
           Summary: llvm-objcopy does not rip off .bss section
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: llvm-objcopy/strip
          Assignee: unassignedb...@nondot.org
          Reporter: masahi...@kernel.org
                CC: alexander.v.shaposhni...@gmail.com,
                    jake.h.ehrl...@gmail.com,
                    jh7370.2...@my.bristol.ac.uk,
                    llvm-bugs@lists.llvm.org, ruppre...@google.com

objcopy is often used to convert an ELF file into a raw binary.

In my workflow, I build my firmware, covert it into raw binary by the following
command, then burn it into my embedded board. 

$ llvm-objcopy -O binary -R .comment --strip-all my-input.elf my-output.bin

This worked fine until LLVM 8,
and in the same way as GNU toolchain objcopy.

If I use the llvm-objcopy from the latest trunk,
it does not work any more.

The first bad commit is:

commit 2b68379b89263178917e3bd37eaf9154078c2965 (HEAD)
Author: Peter Collingbourne <pe...@pcc.me.uk>
Date:   Fri May 24 00:21:46 2019 +0000

    llvm-objcopy: Change sectionWithinSegment() to use virtual addresses
instead of file offsets for SHT_NOBITS sections.

    Without this, sectionWithinSegment() will return the wrong answer for bss
    sections. This doesn't seem to matter now (for non-broken ELF files), but
    it will matter with a change that I'm working on.

    Differential Revision: https://reviews.llvm.org/D58426

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361578
91177308-0d34-0410-b5e6-96231b3b80d8


Since this commit, llvm-objcopy does not drop .bss section.

So, the produced raw binary is bigger than it should be
since it contains the .bss section.


I patched my build script by adding '-R .bss' explcitly.

$ llvm-objcopy -O binary -R .comment --strip-all -R .bss my-input.elf
my-output.bin

However, I do not think this is the right thing to do.

There is no need to load .bss section, nor should it be included in the image.

Moreover, now llvm-objcopy works differently from GNU toolchain objcopy.

Please take a look.

Thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to