google / bloaty

Bloaty: a size profiler for binaries
Apache License 2.0
4.66k stars 337 forks source link

Fix non-standard implementation of DWARF 5 DW_FORM_line_strp (7.5.5) #357

Closed zadewg closed 12 months ago

zadewg commented 1 year ago

The current implementation of DW_FORM_line_strp reads into .debug_str. This form was added in DWARF 5, and the standard specifies that the string is included in the .debug_line_str section instead.

This PR fixes #348.

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

haberman commented 1 year ago

Thanks very much for the fix. Would you be able to add a yaml2obj unit test for this in https://github.com/google/bloaty/tree/main/tests/dwarf/debug_info?

zadewg commented 1 year ago

Done. Interestingly, yaml2obj (at least Ubuntu LLVM version 15.0.7) is not happy with:

DWARF:
  debug_str:
    - fizz
  debug_line_str:        # <---- yaml2obj-15 "unknown key" error.
    - foo.c
  debug_abbrev:

I have not tried a trunk build. The alternative way of adding the section is borrowed from LLVM's own tests for DW_FORM_line_strp.

haberman commented 12 months ago

As of https://github.com/google/bloaty/pull/354 we are now using a much newer yaml2obj. Want to give it another try?

zadewg commented 12 months ago

Sure, just did - yaml2obj from llvmorg-17.0.0-rc3 still fails to recognize debug_line_str as a valid key, the test should remain as is.