]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
libctf: dedup: improve hiding of conflicting types in the same dict
authorNick Alcock <nick.alcock@oracle.com>
Fri, 30 May 2025 14:26:26 +0000 (15:26 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 26 Jun 2025 14:50:47 +0000 (15:50 +0100)
commit41d279b52a526f8a010186bcb8afc7650f688350
treed55d9442d52f4545f66f83a80cf026bd492a8096
parent831b9940194324660845806a0cfd0dca46afda38
libctf: dedup: improve hiding of conflicting types in the same dict

If types are conflicting, they are usually moved into separate child dicts
-- but not always.  If they are added to the same dict by the cu-mapping
mechanism (as used e.g. for multi-TU kernel modules), we can easily end
up adding multiple conflicting types with the same name to the same dict.

The mechanism used for turning on the non-root-visible flag in order to do
this had a kludge attached which always hid types with the same name,
whether or not they were conflicting.  This is unnecessary and can hide
types that should not be hidden, as well as hiding bugs.  Remove it, and
replace it with two different approaches:

 - for everything but cu-mapped links (the in-memory first phase of a link
   with ctf_link_add_cu_mapping in force), check for duplicate names if
   types are conflicting, and mark them as hidden if the names are found.
   This will never happen in normal links (in an upcoming commit we will
   suppress doing even this much in such cases).

 - for cu-mapped links, the only case that merges multiple distinct target
   dicts into one, we apply a big hammer and simply hide everything!  The
   non-root flag will be ignored in the next link phase anyway (which dedups
   the cu-mapped pieces against each other), and this way we can be sure
   that merging multiple types cannot incur name clashes at this stage.

The result seems to work: the only annoyance is that when enums with
conflicting enumerators are found in a single cu-mapped child (so, really
multiple merged children), you may end up with every instance of that enum
being hidden for reasons of conflictingness.  I don't see a real way to
avoid that.

libctf/
PR libctf/33047
* ctf-dedup.c (ctf_dedup_emit_type): Only consider non
conflicting types.  Improve type hiding in the presence of clashing
enumerators.  Hide everything when doing a cu-mapped link: they will
be unhidden by the next link pass if nonconflicting.
libctf/ctf-dedup.c