Bug 26520 - "objdump: DWARF error: could not find variable specification at offset ..." when generating assembly listing of .elf file containing symbols from libstdc++.a
Summary: "objdump: DWARF error: could not find variable specification at offset ..." w...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: ---
Assignee: Nick Clifton
URL:
Keywords:
: 26914 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-08-21 17:30 UTC by Freddie Chopin
Modified: 2020-11-20 11:24 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-08-28 00:00:00


Attachments
Problematic .elf file (2.13 MB, application/x-xz)
2020-08-21 17:30 UTC, Freddie Chopin
Details
Problematic libstdc++.a file (4.58 MB, application/x-xz)
2020-08-21 17:34 UTC, Freddie Chopin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Freddie Chopin 2020-08-21 17:30:41 UTC
Created attachment 12787 [details]
Problematic .elf file

I have multiple embedded C++ projects that - as part of the compilation process - produce also assembly listing with command similar to this one:

$ arm-none-eabi-objdump -S --demangle distortosTest.elf > distortosTest.lss

This worked flawlessly up to (and including) previous release of binutils. In 2.35 something changed. The assembly listing is still generated and it seems to be correct (I did not check it very thoroughly), the command ends with no fatal errors (it returns "0" to the shell), however I see multiple errors like these:

arm-none-eabi-objdump: DWARF error: could not find variable specification at offset 2f9
arm-none-eabi-objdump: DWARF error: could not find variable specification at offset 305
arm-none-eabi-objdump: DWARF error: could not find variable specification at offset 311
...

If I take the .elf file produced by the "new" toolchain (it also includes GCC 10.2) and do the command above but with objdump from the "old" toolchain (binutils 2.34), then there is no error. In a reversed scenario (.elf produced by "old" toolchain, passed to "new" objdump) I see 10x more errors like the ones above.

I attach the problematic .elf file for ARM Cortex-M4 which produces such errors.

After further inspection it turns out that none of "my" .o object files or .a archives produce such error. When examining toolchain libraries, such errors are produced by only ONE library there - libstdc++.a.

arm-none-eabi-objdump -S --demangle libstdc++.a > libstdc++.lss
arm-none-eabi-objdump: DWARF error: could not find variable specification at offset 76c
arm-none-eabi-objdump: DWARF error: could not find variable specification at offset 1733
arm-none-eabi-objdump: DWARF error: could not find variable specification at offset 1740
...
(a lot...)

No other toolchain libraries or toolchain object files produce such error, only libstdc++.a.

At this moment I cannot confirm whether or not this is arm-none-eabi specific or not, as Arch Linux still has binutils 2.34 in the repos.
Comment 1 Freddie Chopin 2020-08-21 17:34:59 UTC
Created attachment 12788 [details]
Problematic libstdc++.a file

I also attach the .a archive which generates such errors (to be specific: arm-none-eabi/lib/thumb/v7e-m/nofp/libstdc++.a, however every libstdc++.a variant from the toolchain produces these errors).
Comment 2 xantares09 2020-08-24 14:18:21 UTC
the message looks similar to https://sourceware.org/bugzilla/show_bug.cgi?id=26518
Comment 3 Nick Clifton 2020-08-28 16:24:31 UTC
I think that this is a bug in the DWARF parser in the BFD library.
Testing a local patch now...
Comment 4 cvs-commit@gcc.gnu.org 2020-08-29 07:03:56 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e6f04d55f681149a69102a73937d0987719c3f16

commit e6f04d55f681149a69102a73937d0987719c3f16
Author: Nick Clifton <nickc@redhat.com>
Date:   Sat Aug 29 08:03:15 2020 +0100

    Include members in the variable table used when resolving DW_AT_specification tags.
    
            PR 26520
            * dwarf2.c (scan_unit_for_symbols): Add member entries to the
            variable table.
Comment 5 Nick Clifton 2020-08-29 07:05:02 UTC
Hi Freddie,

  I have applied a patch which should fix this problem.  Please can
  you give it a go and let me know if it works for you ?

Cheers
  Nick
Comment 6 Frank Mehnert 2020-09-02 16:09:38 UTC
I had the same problem and I can confirm that this change fixes my problem. Thanks!
Comment 7 Nick Clifton 2020-09-03 14:42:38 UTC
The patch has resolved the problem.
Comment 8 Freddie Chopin 2020-09-07 21:31:33 UTC
The issue is fixed for me too - thanks!
Comment 9 Frank Mehnert 2020-09-23 17:08:48 UTC
Please consider backporting this fix to the 2.35 branch.

Thank you!
Comment 10 cvs-commit@gcc.gnu.org 2020-09-24 12:42:52 UTC
The binutils-2_35-branch branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=269d40a2ef3b020b5beb3f3de5b8e909c43ab53b

commit 269d40a2ef3b020b5beb3f3de5b8e909c43ab53b
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Sep 24 13:42:04 2020 +0100

    Import patch from mainline to fix decoding DWARF information in the BFD library.
    
            PR 26520
            * dwarf2.c (scan_unit_for_symbols): Add member entries to the
            variable table.
Comment 11 Nick Clifton 2020-09-24 12:43:23 UTC
(In reply to Frank Mehnert from comment #9)
> Please consider backporting this fix to the 2.35 branch.

Done.
Comment 12 Frank Mehnert 2020-09-24 13:03:33 UTC
Greatly appreciated. Thanks!
Comment 13 Nick Clifton 2020-11-20 11:24:48 UTC
*** Bug 26914 has been marked as a duplicate of this bug. ***