[PATCH fyi 1/1] dwarf_loader: Add missing cus__add(cus, cu) to cus__merge_and_process_cu()

Arnaldo Carvalho de Melo
2024-06-18T14:30:11Z

Just FYI, I added this on top of the previous one initializing cu->node.

Tested with that cast_common.ko and the vmlinux you made available.

- Arnaldo

---

In cus__finalize() if cu__finalize() returns LSK__DELETE, i.e. if the
tool processing the cu is done with it, we will assume that it is in the
cus list of cu instances, remove it and then delete it.

This was not being done by cus__merge_and_process_cu(), used when
merging all DWARF CUs into a single 'struct cu', such as when processing
binaries generated by clang using LTO. Add the missing cus__add() to
keep cus->nr_entries consistent.

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 b832c93cc2194eaf..3caf32457f42ec2e 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -3452,6 +3452,7 @@ static int cus__merge_and_process_cu(struct cus *cus, struct conf_load *conf,
cu->priv = dcu;
cu->dfops = &dwarf__ops;
cu->language = attr_numeric(cu_die, DW_AT_language);
+ cus__add(cus, cu);
}

Dwarf_Die child;
--
2.45.0