aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2022-10-10 09:42:30 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-10-10 17:03:11 -0300
commitcffe5e1f75e1612e1ffd8da5fab30e0230fbcdd4 (patch)
tree047947eb3f3fe78738b3e1f218847c27f720a5a8
parent75e0fe28bb02036dd404eec53dc3b71b55684ed1 (diff)
downloadpahole-cffe5e1f75e1612e1ffd8da5fab30e0230fbcdd4.tar.gz
core: Record if a CU has a DW_TAG_unspecified_type
So that the BTF encoder can turn such functions into returning void instead, as BTF doesn't have a representation for such tags. First noticed with Linux circa v6.1 built with GNU AS 2.39.50, git HEAD at the time building a .S file where the entry_ibpb assembly "function" was encoded as DWARF with DW_TAG_unspecified_type as its return type. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--dwarf_loader.c7
-rw-r--r--dwarves.h8
2 files changed, 14 insertions, 1 deletions
diff --git a/dwarf_loader.c b/dwarf_loader.c
index 28a912ec..03ac8718 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -2006,10 +2006,12 @@ static struct tag *__die__process_tag(Dwarf_Die *die, struct cu *cu,
case DW_TAG_imported_module:
case DW_TAG_reference_type:
case DW_TAG_restrict_type:
- case DW_TAG_unspecified_type:
case DW_TAG_volatile_type:
case DW_TAG_atomic_type:
tag = die__create_new_tag(die, cu); break;
+ case DW_TAG_unspecified_type:
+ cu->unspecified_type.tag =
+ tag = die__create_new_tag(die, cu); break;
case DW_TAG_pointer_type:
tag = die__create_new_pointer_tag(die, cu, conf); break;
case DW_TAG_ptr_to_member_type:
@@ -2077,6 +2079,8 @@ static int die__process_unit(Dwarf_Die *die, struct cu *cu, struct conf_load *co
cu__hash(cu, tag);
struct dwarf_tag *dtag = tag->priv;
dtag->small_id = id;
+ if (tag->tag == DW_TAG_unspecified_type)
+ cu->unspecified_type.type = id;
} while (dwarf_siblingof(die, die) == 0);
return 0;
@@ -2512,6 +2516,7 @@ static int cu__recode_dwarf_types_table(struct cu *cu,
if (tag__recode_dwarf_type(tag, cu))
return -1;
}
+
return 0;
}
diff --git a/dwarves.h b/dwarves.h
index 9aaf87f2..f8b15002 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -230,6 +230,10 @@ struct debug_fmt_ops {
bool has_alignment_info;
};
+/*
+ * unspecified_type: If this CU has a DW_TAG_unspecified_type, as BTF doesn't have a representation for this
+ * and thus we need to check functions returning this to convert it to void.
+ */
struct cu {
struct list_head node;
struct list_head tags;
@@ -238,6 +242,10 @@ struct cu {
struct ptr_table functions_table;
struct ptr_table tags_table;
struct rb_root functions;
+ struct {
+ struct tag *tag;
+ uint32_t type;
+ } unspecified_type;
char *name;
char *filename;
void *priv;