[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug default/21540] New: Selectively resolve struct/union declaration to their definition


            Bug ID: 21540
           Summary: Selectively resolve struct/union declaration to their
           Product: libabigail
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: default
          Assignee: dodji at redhat dot com
          Reporter: dodji at redhat dot com
                CC: libabigail at sourceware dot org
  Target Milestone: ---

When analysing the debug information of a C binary, it can happen that the
forward declaration of a "struct foo" can possibly resolve to several
*different* definitions of struct foo.  Here are the cases we can care about:

1/ a struct foo declaration is followed by a struct foo definition, in the same
compilation unit.

2/ a struct foo is declared in compilation unit CU1, but has no definition in
that cu.  There is another compilation unit CU2 that has another struct foo
declared.  And there is a third CU3 which has a definition of struct foo.  In
the entire binary, there is just one *definition* of struct foo.

3/ CU1 and CU2 have declarations of struct foo and no definition.  CU3 and CU4
have two definitions of struct foo that are different.

Here are how we need to handle the resolution of the declarations of struct

* for 1/
If a definition is found for a declaration in the same CU, then the declaration
resolves to that definition.

* for 2/
If there is just one definition matching a given (or several) declaration, in
the entire binary, then the declaration(s) resolve(s) to that definition.  That
is, even if the definition is not in the same CU as the declarations.

* for 3/
If a declaration has no definition in the same CU, but if there are more than
one definition in other CUs that match this declaration, then the declaration
is left unresolved.

It follows that a declaration-only struct foo must compare different to a
definition of struct foo, at the comparison engine level.

Then at the "diff internal representation" level, we can filter out change
reports about a declaration-only becoming a definition.

Note that at the moment, a declaration resolves to the last matching definition
that was analysed. This makes the declaration resolution be somewhat random. 
This needs to be fixed by following what I just outlined above.

You are receiving this mail because:
You are on the CC list for the bug.