From patchwork Tue Jun 28 14:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 55494 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B448D39BBDA3 for ; Tue, 28 Jun 2022 14:42:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B448D39BBDA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1656427323; bh=y2wyoRz954MsbC7krbukPfAyp4HpkBTngGDsefIcFdw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=DUX03uIbPBrKZwKT1rUDphoJiDkmCtdo4DX7ZNTkqDf+8+mfG1IMIW+IeUVUDP+7z G0PRGahu5yPIRwJrLAZiDF8ZJm5wmHvujGH2b5c9i3mN9RNUpkSu3MN7KZxn1+3JCV /f8gD4rhyXCIFxyp6FA1yaPwdwXWE9/c8DsuEcs8= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 57FDB38D79AF for ; Tue, 28 Jun 2022 14:41:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 57FDB38D79AF Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-421-YQw2skm6PPmsSyzKt7gxcw-1; Tue, 28 Jun 2022 10:41:25 -0400 X-MC-Unique: YQw2skm6PPmsSyzKt7gxcw-1 Received: by mail-qv1-f71.google.com with SMTP id g7-20020a0ce747000000b0047079ec462dso12571419qvn.20 for ; Tue, 28 Jun 2022 07:41:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:organization:date:message-id :user-agent:mime-version; bh=y2wyoRz954MsbC7krbukPfAyp4HpkBTngGDsefIcFdw=; b=cMxwcikOXuu1S3t5xxEjICvpJwZDGAxloZ+8AVORW4s96fQWYQ/zBAQPHFkvIdK+UT LhQN16aevhw9ipvaU+B5nMbRZr9YNFkT/9BkR3KARH7Q1Ax29Vbhe9TaNRWBVse+squI upVGWk7C1o3gB005+GFLpleUtyXpYH74Klj8UA3aiGfBuxI91tWkp99dnPQ8K0vg6I4l KG5yvBA9T8OGBzEB3Smullxq6tALLSd7Q4rNKe3kCLqXJFE2FpV8DsuDTQANuk68/ljt 1mxNDjk+fpbNQ9i6l+sQB3kcxOzmDAJ39vucFCXCkZZE51RrNvne2AKFe29OoCIk/4rK X0NA== X-Gm-Message-State: AJIora/gUAXGFUrA+zh2JGRZGMPycTYcfjI9wcLBFvIfZAUp1KEEoP4y sriUbdkz1UfOoxu0ukFldXkSO1+A3u9JAwJbT/I46MhEgJ/ZAsXagBzLbF2rqLCoDN6LiuQPgHY tHqV/dW4uA5AxRU3AqIl5 X-Received: by 2002:a0c:c783:0:b0:46b:b44c:8e63 with SMTP id k3-20020a0cc783000000b0046bb44c8e63mr2796631qvj.101.1656427285160; Tue, 28 Jun 2022 07:41:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sD42hwCIj+sb5BdYOgciB2ThEzc+86WMfhuTR5imFNrHCpcwUP2k8miP2Bwv9F9cHbXI+Wmg== X-Received: by 2002:a0c:c783:0:b0:46b:b44c:8e63 with SMTP id k3-20020a0cc783000000b0046bb44c8e63mr2796609qvj.101.1656427284909; Tue, 28 Jun 2022 07:41:24 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id j17-20020ac84c91000000b002f39b99f6a4sm4191821qtv.62.2022.06.28.07.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 07:41:24 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 34EA9581C3B; Tue, 28 Jun 2022 16:41:22 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH] dwarf-reader: Don't consider top-level types as private Organization: Red Hat / France X-Operating-System: Fedora 37 X-URL: http://www.redhat.com Date: Tue, 28 Jun 2022 16:41:22 +0200 Message-ID: <87o7ycetpp.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Hello, [This fixes an issue that was reported to me by Ben Woodard] By default, the DWARF reader (wrongly) considers that any top-level decl/type (inside a namespace) that doesn't have the DW_AT_external attribute is a private decl/type. It thus considers that function/variable decls that have that attribute are public decls, and thus, the types they use are also public. Which is what we want. But then, it also considers that top-level types (which never have a DW_AT_external) are not public. And that causes unwanted side effects like dropping some classes on the floor. As a result, some functions that have those classes as parameter type would end-up being considered as having no parameter of that type. Oops. This patch fixes that by considering that only function and variable DIEs ought to have the DW_AT_external flag to be considered as public decls. Non-anonymous namespace are also considered as public decls. This should fix the output of the command: tools/fedabipkgdiff --debug --abipkgdiff build/tools/abipkgdiff --self-compare -a --from fc36 libabigail * src/abg-dwarf-reader.cc (die_is_public_decl): Only function and variable decls having the DW_AT_external, as well as non-anonymous namespaces are considered public decls. The rest is considered private. (build_namespace_decl_and_add_to_ir): If the current namespace is private (anonymous), then its content is also private. Otherwise, use die_is_public_decl to know if its content is public or not. Signed-off-by: Dodji Seketeli --- src/abg-dwarf-reader.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 66bfbc3e..7c8ec012 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -6758,8 +6758,23 @@ die_access_specifier(Dwarf_Die * die, access_specifier& access) static bool die_is_public_decl(const Dwarf_Die* die) { + if (!die) + return false; bool is_public = false; - die_flag_attribute(die, DW_AT_external, is_public); + + // If this is a DW_TAG_subprogram DIE, look for the + // DW_AT_external attribute on it. Otherwise, if it's a non-anonymous namespace, + // then it's public. In all other cases, this should return false. + + int tag = dwarf_tag(const_cast(die)); + if (tag == DW_TAG_subprogram || tag == DW_TAG_variable) + die_flag_attribute(die, DW_AT_external, is_public); + else if (tag == DW_TAG_namespace) + { + string name = die_name(die); + is_public = !name.empty(); + } + return is_public; } @@ -12131,7 +12146,12 @@ build_namespace_decl_and_add_to_ir(read_context& ctxt, ctxt.scope_stack().push(result.get()); do build_ir_node_from_die(ctxt, &child, - /*called_from_public_decl=*/false, + // If this namespace DIE is private + // (anonymous) then all its content is + // considered private. Otherwise, its + // public decls are considered public. + /*called_from_public_decl=*/ + die_is_public_decl(die) && die_is_public_decl(&child), where_offset); while (dwarf_siblingof(&child, &child) == 0); ctxt.scope_stack().pop();