This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: objcopy -j -O binary can't extract debug sections
- From: Ian Lance Taylor <iant at google dot com>
- To: Corinna Vinschen <vinschen at redhat dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 22 Nov 2013 11:45:30 -0800
- Subject: Re: objcopy -j -O binary can't extract debug sections
- Authentication-results: sourceware.org; auth=none
- References: <20131122184033 dot GF28310 at calimero dot vinschen dot de>
On Fri, Nov 22, 2013 at 10:40 AM, Corinna Vinschen <vinschen@redhat.com> wrote:
>
> Here's the start of the script:
>
> EXE=$1
> LONGSECTIONS=".gnu_debuglink \
> .debug_aranges \
> .debug_info \
> .debug_abbrev \
> .debug_line \
> .debug_frame \
> .debug_str \
> .debug_loc \
> .debug_ranges"
>
> for section in ${LONGSECTIONS}
> do
> objcopy -j "${section}" -O binary "${EXE}" "${EXE}${section}"
> objcopy -R "${section}" "${EXE}"
> done
> [...]
>
> So I'm just storing the binary content of the debug sections in separate
> files and then strip the section from the executable.
>
> The problem is, it doesn't work. The only section which I can export
> successfully this way is the .gnu_debuglink section. All the files
> supposed to contain the Dwarf2 debug sections will have a length of 0.
> No errors, no warnings, just a size of 0.
It's because the .debug_XXX sections are marked with SEC_DEBUG in BFD,
and the BFD "binary" format discards SEC_DEBUG sections.
Try adding
--set-section-flags=".debug*=alloc,load"
Ian