[Bug debug/68229] New: .debug_pubnames length field is too large

todd.allen at ccur dot com gcc-bugzilla@gcc.gnu.org
Thu Nov 5 23:20:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68229

            Bug ID: 68229
           Summary: .debug_pubnames length field is too large
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: todd.allen at ccur dot com
  Target Milestone: ---

Created attachment 36659
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36659&action=edit
Example program

For C programs that use system header files (those rarities :) the length field
of .debug_pubnames is too large.  Obviously, this requires -gpubnames.

The problem occurs if there are enum types in the system header files that are
not marked for emission in the object file.  size_of_pubnames() still counts
them, but output_pubnames() does not emit them.  So the size ends up being too
large.

This is a big problem for dwarf readers because, when reading a linked
executable, they will use the length field for the contribution from one object
file to determine the location of the contribution for the next object file. 
If it's wrong, they can skip whole contributions and possibly (likely) end up
at a random byte in the middle of some subsequent contribution.

I'll include an example.  This example is small enough that the result is that
the contribution from the second object file is skipped entirely and it
overruns the end of the section.  It would require a few more object files
before there was enough material for it to end up in the middle of a subsequent
contribution.


More information about the Gcc-bugs mailing list