From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kZ7zCoOtHWkpAxMAWB0awg (envelope-from ) for ; Wed, 19 Nov 2025 06:44:03 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R40YzeVu; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2265D1E0B6; Wed, 19 Nov 2025 06:44:03 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 677571E08D for ; Wed, 19 Nov 2025 06:44:02 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0019A384D14B for ; Wed, 19 Nov 2025 11:44:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0019A384D14B Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R40YzeVu Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id F194C3858C41 for ; Wed, 19 Nov 2025 11:43:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F194C3858C41 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F194C3858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763552605; cv=none; b=uI5gzeZPTZg3CbQ4vJXO66BKDYVCYwUECM3J+SgIEWp7N2y4YxKjYlLaBSuYMR1uKL1928AS5ME5o1pj2eqDKcXo4EfCn06nkFod4od1ceWjr99t0tB5Yiq1Kfq2GgD47TQmktrycC8FyEIbrr1qFB9UChM65lLMLfrdQP0MXP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763552605; c=relaxed/simple; bh=8B2tDdql5/GkSOcf4Dln43nph7yBd11g+mqZHLUe8v0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WtJZf571XmFNE95F8XMYkjnEO2v60wAe3yEbzK7/TicPq9LnnwoXZDs1aMdNs0CUXzFvo1PnKYc37ZUt2rxHhoxWBX7eR5dukEDHGJKzqCP5qY7A3jizlhoC4cztc5CeRXPBehVhRM1k61vhkKALkC9bs4w7lCBTbJtRAWgx3Ns= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F194C3858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763552604; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=h3mPOqD0pmAHm/y8IQLqVRJWY6V8g5O4K/rKrUPvpIo=; b=R40YzeVugIaSdbhUuxZ1UJXI6ClSK3xxlsCkzp2yHzEvnJfI8rX+djPMrotrRxmN+6wlBb OvuW5fqgxOEGVUU2NQA12Wy3MxMIj5ai7k7PESiMw8gc9/sPqqAzUR9EklTdm5z9hySbCM y72nmoYhojfve+X33xvaqsf8/xauryU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-6O5MXLvBMfGGGuvSTZzThg-1; Wed, 19 Nov 2025 06:43:23 -0500 X-MC-Unique: 6O5MXLvBMfGGGuvSTZzThg-1 X-Mimecast-MFC-AGG-ID: 6O5MXLvBMfGGGuvSTZzThg_1763552602 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4779981523fso33925895e9.2 for ; Wed, 19 Nov 2025 03:43:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763552602; x=1764157402; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=h3mPOqD0pmAHm/y8IQLqVRJWY6V8g5O4K/rKrUPvpIo=; b=TZB63zhseDnf8XPgIk8FTmN/KhjXSA3mNanOqV3+87378DYK66kcet0Kzcvs62VsBi DM1erfiju1xqSjiDUnQH5uBb/ezBt7wDmPUgto2gmpGaGuW3/dvEpqolP33kQwmsik0W KXziRLZ9In5JfLjoJho3Y5xU2bfJCMR/wBxBgv17QRhSvCuZ4ADA8sAMSi3VkAoGKJSI 2dB2Ru+FG4YYpLfxuwTBY7F1KU70wxjp5rk9UTtfTuAfa7yNYVRhMRNdu0Pw/LkDEn4+ YvU0TH1JsE+5od242yLU5zAh38Gg1vdnuPuUKsFHpXDtKQz6V8ATsxtwFC9KejKPIlkf iIbQ== X-Forwarded-Encrypted: i=1; AJvYcCUj4iL43cbrcUylRIeyxUyHG0rJ6I6uCbv2ssLywVPqOt7wdnS2XqUPlk9/zEoJzkk6kAuaPF3uRhu3JA==@sourceware.org X-Gm-Message-State: AOJu0YyAE0n+VaHIKV4lS8Y5DCj9a856lzvueLx9RlLcRwWNh9DwwSNB kNPMlmDRT3lMRTTGE3+zWAoZapO7akbpT3tsRQrS7WK5bpnsc2wRPju3DbmVcBEZkS1IH9rIK7n zANF+q/5jp67GoqYHKaW6CKwIgA+vNIJSRc0+T5rUX+8RkvDfzhqpRMS55K6fmF8= X-Gm-Gg: ASbGnctkncCiQ1D1X5qNHSaEgO9nRSFK7OhnQGaXA/zcvPSoPplYH8S+QdFOYAQ2Rv5 idsW+3JPoRQ/ubPAzOaigH5z2zWhD02K06iMFAjazE5oHMSHK3Y6RmwR6FfNt0nzedKyZe+lWMG hELYgc7Lyzk8mISguLU2PDnz2f1Ld8rj65zgodIk4ZYe6UWwOmDKeaQOp2WegVoOFJU1i+qOMqx is5YPXkgE6z62o6OGqgwgTHUz1UweB3j+74VACigxMmke3f1hn73KVgeYqNwCbk44GTUDQnvGMs gcId1Jmh/SwjOFkgQTrHBKxONUTdvPDWGwCY/hFxKP/Viyvf4Tnl2zGB3Pqn+AChSL37hlFaki6 OI0nZ X-Received: by 2002:a05:600c:524b:b0:477:af07:dd21 with SMTP id 5b1f17b1804b1-477af07dec3mr44240385e9.25.1763552602396; Wed, 19 Nov 2025 03:43:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVQxOCSztBh8aH/MvuYgtEIuoclAZSbQX7PniDehOVSTWGhw7CQbkhrtC8rwYAJPJObWKhcA== X-Received: by 2002:a05:600c:524b:b0:477:af07:dd21 with SMTP id 5b1f17b1804b1-477af07dec3mr44240155e9.25.1763552601894; Wed, 19 Nov 2025 03:43:21 -0800 (PST) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9723a6esm41755525e9.1.2025.11.19.03.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 03:43:21 -0800 (PST) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 3/6] gdb/testsuite/dwarf: emit type unit sections as COMDAT In-Reply-To: <20251107211041.520697-4-simon.marchi@efficios.com> References: <20251107211041.520697-1-simon.marchi@efficios.com> <20251107211041.520697-4-simon.marchi@efficios.com> Date: Wed, 19 Nov 2025 11:43:20 +0000 Message-ID: <87ms4itfhj.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 8TlwONf-Xh2OKl6Yt-1PkAdy_nPfQHeBgZUaPj1gbJI_1763552602 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Simon Marchi writes: > From: Simon Marchi > > In an effort to generate ELF files and DWARF info as close as possible > as an actual compiler would generate, change how we emit type unit > sections to emit each type unit in its own section, in COMDAT section > groups. > > We currently emit all type units in a single, standard section (either > .debug_info or .debug_types, depending on the DWARF version). Compilers > emit each type unit in its own .debug_types section. Each section is > placed in a COMDAT section group with a signature based on the type > unit's signature. This lets the linker deduplicate identical type units > by discarding section groups with identical signatures (keeping only one > group with a given signature). > > Looking at a .s file generated by gcc, we can see that this is how it > specifies the section for a type unit: > > .section .debug_info,"G",@progbits,wi.006fd2152a3054a6,comdat > > The "G" flag tells the assembler to place the section in a section > group with signature "wi.006fd2152a3054a6". That string was generated > from the type unit, signature. Finally, the comdat linkage field > indicates that the section group should have the COMDAT flag. > > Update the tu proc to emit a section with these properties. In this > case, it's mandatory to specify the type of the section (progbits). > > Update the _section proc to accept the new options "group_signature" and > "linkage". > > As a result, if you look at the .debug_types section in a .o file from > gcc: > > $ readelf -g main.o > COMDAT group section [ 1] `.group' [wt.006fd2152a3054a6] contains 2 sections: > [Index] Name > [ 11] .debug_types > [ 12] .rela.debug_types > > COMDAT group section [ 2] `.group' [wt.c621aa8e3c23e450] contains 2 sections: > [Index] Name > [ 13] .debug_types > [ 14] .rela.debug_types > > And a .o file created by our DWARF assembler: > > $ readelf -g testsuite/outputs/gdb.dwarf2/struct-with-sig/struct-with-sig1.o > COMDAT group section [ 1] `.group' [sig.0x0000000000000001] contains 2 sections: > [Index] Name > [ 10] .debug_types > [ 11] .rela.debug_types > > COMDAT group section [ 2] `.group' [sig.0x0000000000000002] contains 2 sections: > [Index] Name > [ 12] .debug_types > [ 13] .rela.debug_types > > In both cases, in the fully linked files, there is a single .debug_types section > containing the two type units, as expected. > > Before this patch, when I run gdb.dwarf2/fission-with-type-unit.exp, the > resulting .dwo file has a single .debug_info.dwo. After this patch it > has two: one with the type unit and one with the compile unit (the test > uses DWARF 5). Based on what I see gcc generate when using "-gdwarf-5 > -gsplit-dwarf -fdebug-types-section", this is what we expect. I think I followed all of this. Approved-By: Andrew Burgess Thanks, Andrew > > Change-Id: Ie1954dc697fe100b5dbe664d148c71fa02888d96 > --- > gdb/testsuite/lib/dwarf.exp | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp > index 5536b7656b8c..c3c35d43607d 100644 > --- a/gdb/testsuite/lib/dwarf.exp > +++ b/gdb/testsuite/lib/dwarf.exp > @@ -1075,6 +1075,8 @@ namespace eval Dwarf { > parse_options { > { flags "" } > { type "" } > + { group_signature "" } > + { linkage "" } > } > > set directive ".section $name" > @@ -1097,6 +1099,14 @@ namespace eval Dwarf { > append directive ", %$type" > } > > + if { $group_signature != "" } { > + append directive ", $group_signature" > + } > + > + if { $linkage != "" } { > + append directive ", $linkage" > + } > + > _emit " $directive" > } > > @@ -1717,7 +1727,13 @@ namespace eval Dwarf { > set _abbrev_section "$_abbrev_section.dwo" > } > > - _section $section > + # The specific format of the signature is arbitrary. > + _section $section { > + flags G > + type progbits > + group_signature sig.$signature > + linkage comdat > + } > > set cu_num [incr _cu_count] > > -- > 2.51.2