public inbox for dwarves@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Matthias Schwarzott <zzam@gentoo.org>
Cc: dwarves@vger.kernel.org
Subject: [PATCH 1/1] dwarf_loader: Hash DW_TAG_enumerator entries
Date: Tue, 16 Jul 2024 15:43:57 -0300	[thread overview]
Message-ID: <Zpa_bfGXfR1rFV2e@x1> (raw)

As they are referenced by DW_TAG_imported_declaration, as we can see
from these warnings:

  ⬢[acme@toolbox zzam@gentoo.org]$ pdwtags popup.cpp.o > /dev/null
  die__process_class: tag not supported 0x2f (template_type_parameter)!
  die__process_class: tag not supported 0x30 (template_value_parameter)!
  die__process_class: tag not supported 0x4107 (GNU_template_parameter_pack)!
  die__process_function: tag not supported 0x4108 (GNU_formal_parameter_pack)!
  tag__recode_dwarf_type: couldn't find 0x5706e type for 0xedb9 (imported_declaration)!
  tag__recode_dwarf_type: couldn't find 0x57074 type for 0xedc1 (imported_declaration)!
  tag__recode_dwarf_type: couldn't find 0x5707a type for 0xedc9 (imported_declaration)!
  namespace__recode_dwarf_types: couldn't find 0x5706e type for 0xedb9 (imported_declaration)!
  namespace__recode_dwarf_types: couldn't find 0x57074 type for 0xedc1 (imported_declaration)!
  namespace__recode_dwarf_types: couldn't find 0x5707a type for 0xedc9 (imported_declaration)!
  ⬢[acme@toolbox zzam@gentoo.org]$

Looking at the DWARF info for one of those types not found:

  ⬢[acme@toolbox zzam@gentoo.org]$ readelf -wi popup.cpp.o | grep -w edb9 -A5
   <2><edb9>: Abbrev Number: 14 (DW_TAG_imported_declaration)
      <edba>   DW_AT_decl_file   : 64
      <edbb>   DW_AT_decl_line   : 100
      <edbc>   DW_AT_decl_column : 20
      <edbd>   DW_AT_import      : <0x5706e>	[Abbrev Number: 51 (DW_TAG_enumerator)]
   <2><edc1>: Abbrev Number: 14 (DW_TAG_imported_declaration)
  ⬢[acme@toolbox zzam@gentoo.org]$

And then:

  ⬢[acme@toolbox zzam@gentoo.org]$ readelf -wi popup.cpp.o | grep -w 5706e -A3
   <3><5706e>: Abbrev Number: 51 (DW_TAG_enumerator)
      <5706f>   DW_AT_name        : (indirect string, offset: 0xaec05): _S_single
      <57073>   DW_AT_const_value : 0
   <3><57074>: Abbrev Number: 51 (DW_TAG_enumerator)
  ⬢[acme@toolbox zzam@gentoo.org]$

So we need to hash those DW_TAG_enumerator and not just the
DW_TAG_enumerator_type containing them.

This way tag__recode_dwarf_type() and namespace__recode_dwarf_types()
will find them when looking them up using dwarf_cu__find_type_by_ref().

This was found first on the stratagus codebase (C++) at
https://github.com/Wargus/stratagus.git.

This didn't generate any difference in output from pahole, not
influenced BTF generation as tested using tests/reproducible_build.sh.

Reported-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 dwarf_loader.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/dwarf_loader.c b/dwarf_loader.c
index 2d49960120b56f78..d914b91c1f375f7f 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -1776,6 +1776,7 @@ static struct tag *die__create_new_enumeration(Dwarf_Die *die, struct cu *cu, st
 			goto out_delete;
 
 		enumeration__add(enumeration, enumerator);
+		cu__hash(cu, &enumerator->tag);
 	} while (dwarf_siblingof(die, die) == 0);
 out:
 	return &enumeration->namespace.tag;
-- 
2.45.0


                 reply	other threads:[~2024-07-16 18:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zpa_bfGXfR1rFV2e@x1 \
    --to=arnaldo.melo@gmail.com \
    --cc=dwarves@vger.kernel.org \
    --cc=zzam@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox