]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: link: improve BTF child dict naming
authorNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 20:06:46 +0000 (21:06 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Tue, 9 Dec 2025 13:02:28 +0000 (13:02 +0000)
BTF dicts don't have a cuname, which means that when the deduplicator runs
over them any child dicts that result from conflicted types found in those
CUs end up with no name either.  Detect such unnamed dicts and propagate
in the name the linker gave them at input time instead.  (There is always
*some* such name, even if it's something totally useless like "#1"; usually
it's much more useful.)

libctf/ctf-link.c

index 65fd75fc80abf3c46b6ebf8a1c93daa183e91ff0..cd97e123ed1b1c8f30a123e85ebf6bf71358efc8 100644 (file)
@@ -552,6 +552,15 @@ ctf_link_deduplicating_count_inputs (ctf_dict_t *fp, ctf_dynhash_t *cu_names,
          return -1;                            /* errno is set for us.  */
        }
 
+      /* If this is an unnamed, zero-archive dict, propagate the input name into the
+        dict itself, for the sake of deduplicator child dict naming.  */
+
+      if (one_input->clin_arc
+         && ctf_archive_count (one_input->clin_arc) == 1
+         && one_input->clin_arc->ctfi_dict != NULL &&
+         ctf_cuname (one_input->clin_arc->ctfi_dict) == NULL)
+       ctf_cuname_set (one_input->clin_arc->ctfi_dict, name);
+
       count += one_count;
       narcs++;
     }