This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: objcopy -j -O binary can't extract debug sections

On Fri, Nov 22, 2013 at 10:40 AM, Corinna Vinschen <> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]