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

Message ID 878r3pz87p.fsf@redhat.com
State New
Headers
Series [applying,to,mainline] dwarf-reader: Avoid duplicating union members |

Commit Message

Dodji Seketeli Feb. 12, 2024, 9:24 p.m. UTC
  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(+)
  

Patch

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);