objcopy -j -O binary can't extract debug sections
Ian Lance Taylor
iant@google.com
Fri Nov 22 20:26:00 GMT 2013
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
More information about the Binutils
mailing list