[PATCH, applying to mainline] dwarf-reader: Avoid duplicating union members

Dodji Seketeli dodji@redhat.com
Mon Feb 12 21:24:58 GMT 2024


Hello,

The DWARF from some C++ binaries represents unions in a "piece wise"
fashion.  When dealing with those unions, we need to avoid adding the
same member twice, just like what we do for classes.

	* src/abg-dwarf-reader.cc (add_or_update_union_type): Do not add
	an union member that already exists in the union.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applying to the master branch.
---
 src/abg-dwarf-reader.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 735f0342..8c624d48 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -13582,6 +13582,9 @@ add_or_update_union_type(reader&	 rdr,
 	      if (n.empty() && result->find_data_member(dm))
 		continue;
 
+	      if (!n.empty() && lookup_var_decl_in_scope(n, result))
+		continue;
+
 	      result->add_data_member(dm, access, /*is_laid_out=*/true,
 				      /*is_static=*/false,
 				      offset_in_bits);
-- 
2.39.3


-- 
		Dodji



More information about the Libabigail mailing list