From patchwork Fri Feb 3 11:47:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 64244 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 EAF1F3858426 for ; Fri, 3 Feb 2023 11:47:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAF1F3858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675424853; bh=3J/Q+AErrXCJKKUs/NY6tlZtnqdBW0HhHNB9W0evc0M=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=HBryLu2Mmj3ERHx6a2gpAhWJTYRxB9HNO8X39L0iLVoSTBJBt5HP6UPSnuYcmPfdJ BICWD3PgTKNYX3S9W+lhvUSzrF4TehT1HuD7LrGQrollQS7nyaHh6vg3wwQCHwWUbO KCpG76xg+KPCNktNbLpar+zugWD4+rNuw+TAma68= 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 41B173858C52 for ; Fri, 3 Feb 2023 11:47:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 41B173858C52 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_128_GCM_SHA256) id us-mta-481-oSEVWOhxMtOZv3zfLMiEiA-1; Fri, 03 Feb 2023 06:47:25 -0500 X-MC-Unique: oSEVWOhxMtOZv3zfLMiEiA-1 Received: by mail-wm1-f69.google.com with SMTP id h18-20020a05600c351200b003dc25fc1849so2532167wmq.6 for ; Fri, 03 Feb 2023 03:47:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3J/Q+AErrXCJKKUs/NY6tlZtnqdBW0HhHNB9W0evc0M=; b=THDUiAHPuifPKN29XPwtiebTp478AWDXts5QkEn814Q5yS+j//JMY+fWy0oUYvO906 89j5BwzZuqyhpgJDWYoYm0gzdmB0+oxmWY2ARl093PNDgmtvcqpyCGQaz3GPA+yEbSNw 4/pPu9YAS1snJric2bZmaR86M3grUg9H3ZAi4mlqBqdVA1HCpH6cdnNRisfxg7fMF+7N UGhqmKOAePkdIBlTy+Dpj01y7Xs9LDJ1abUP27xHHtbZXUi2C79V7EM0nYBVTb+QUVVE MYl4tiK/JhJbKPWYC+Yi/lBboLApS70bHrpzolkk7cexpUG0OuIeA1XXveeFpUvHJk3N 30HQ== X-Gm-Message-State: AO0yUKVTXzBPIzhO2ozZ6S4WgGwzKuAm/w9RAJcSAMQ6KGvZr/GH/WGW BVeg8pBUKEucktL+jd+QNUl8N+m7pxWCvMNSEs+gv9vB9OC87kkmnXswOjRjq2jUhshx27ZBN94 XlfIc0DLRhxTebgzxAJr/ X-Received: by 2002:adf:c754:0:b0:2bf:e533:3158 with SMTP id b20-20020adfc754000000b002bfe5333158mr9279891wrh.20.1675424844484; Fri, 03 Feb 2023 03:47:24 -0800 (PST) X-Google-Smtp-Source: AK7set9dJyjLDHV3Rlu5VE4Ex3KoGIJaoBjsliEpuj7zjoW7nB3mU+1fdftQISWLue1zK9PNPNdD7g== X-Received: by 2002:adf:c754:0:b0:2bf:e533:3158 with SMTP id b20-20020adfc754000000b002bfe5333158mr9279882wrh.20.1675424844326; Fri, 03 Feb 2023 03:47:24 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id w7-20020adff9c7000000b002be546f947asm1803724wrr.61.2023.02.03.03.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 03:47:23 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 284F318F6A6; Fri, 3 Feb 2023 12:47:23 +0100 (CET) To: libabigail@sourceware.org Cc: gprocida@google.com, Dodji Seketeli Subject: [PATCH 1/4] fe-iface: Add missing virtual destructor Organization: Red Hat / France References: <878rhh8xwb.fsf@redhat.com> <87mt5vt3op.fsf@seketeli.org> X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Fri, 03 Feb 2023 12:47:23 +0100 In-Reply-To: <87mt5vt3op.fsf@seketeli.org> (Dodji Seketeli's message of "Fri, 03 Feb 2023 11:59:34 +0100") Message-ID: <87fsbnt1h0.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=-11.6 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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, * include/abg-fe-iface.cc (fe_iface::~fe_iface): Make this virtual. Signed-off-by: Dodji Seketeli --- include/abg-fe-iface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/abg-fe-iface.h b/include/abg-fe-iface.h index d83a1391..12b8b2bd 100644 --- a/include/abg-fe-iface.h +++ b/include/abg-fe-iface.h @@ -72,7 +72,7 @@ protected: fe_iface(const std::string& corpus_path, environment& e); - ~fe_iface(); + virtual ~fe_iface(); void reset(const std::string& corpus_path, environment& e); From patchwork Fri Feb 3 11:47:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 64245 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 C36F83858C33 for ; Fri, 3 Feb 2023 11:47:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C36F83858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675424879; bh=yVvRQg7Sfv3lqOLHrFziUu4ItZaXtsth3qE9eLaiHKk=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=dAiyMgDL6JzN1eEQT43C7+SSNtKhueq256fxLoaB/Aq89JugL9TZ0mbJLbMASzZ6b JQk8ojW25cqi0uX/jLNWEZeqFkclYtTh7wb5AOyJiNQzrXtZIPCi77hoVdFcXJnc/4 hgUrJmgBVcYUf2zITzw/81Nr7UZe+MPr7wPTLAOg= 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 EEAD23858D20 for ; Fri, 3 Feb 2023 11:47:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EEAD23858D20 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-19-rzZPf5cIPZGoGMKw0fMafw-1; Fri, 03 Feb 2023 06:47:53 -0500 X-MC-Unique: rzZPf5cIPZGoGMKw0fMafw-1 Received: by mail-wm1-f70.google.com with SMTP id l38-20020a05600c1d2600b003ddff4b9a40so2473431wms.9 for ; Fri, 03 Feb 2023 03:47:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yVvRQg7Sfv3lqOLHrFziUu4ItZaXtsth3qE9eLaiHKk=; b=QmZhG5zQ4JJuT1rfDfDzZEnkYwOrZ1rDSBw/0ddKJkAaqAKjWk9DkIVJmEGWSvNDGB eObb9Vx2gSL28l9Qjhwiwlq+SOiUXvJDahHD+cQutQsnD667Out+58HX6Jk4cmFNAPw3 URZqHPxG5cUod7fIgTku7HLRTOoxP4PsnpN7CANvjZvLVKv8DGrOfhAkik5FhILaHWt7 NRcJGGiIMmbatoNej6TMaGgLW8i3RG/QcoIIlsGfFm4WnZiZiOXtqmbm46qDXz5VVQBS AXE0zMOpeQY6WuOUYzq7Kpr6RRTptleGqlPr502ya8qfKrwiWTAlQn6pFk6I3YKHa8lt EH4A== X-Gm-Message-State: AO0yUKV7xoL0oVXM/UqIRJrsSAPLLTa/+NO0HRJOzgfohfBLZOCN0HLm ktrxpYh71hmo8KGtCmcatUohA84wN511+yI8gTmzuzJWzua/SQZ9Fr4bECbmZ3KlSkejiFA7MoV 77eKZsvRXNPHzUSQg3qfl X-Received: by 2002:a05:600c:3489:b0:3d2:2d2a:d581 with SMTP id a9-20020a05600c348900b003d22d2ad581mr9530897wmq.30.1675424872092; Fri, 03 Feb 2023 03:47:52 -0800 (PST) X-Google-Smtp-Source: AK7set8XvGN9Zc1tS0DvIDeiulUJEVQH7RCTaXQAUUKnYvqKedtinrFeUvoLzLdKKPbjEKeDxZxnuA== X-Received: by 2002:a05:600c:3489:b0:3d2:2d2a:d581 with SMTP id a9-20020a05600c348900b003d22d2ad581mr9530886wmq.30.1675424871920; Fri, 03 Feb 2023 03:47:51 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id r16-20020a05600c459000b003da28dfdedcsm2814166wmo.5.2023.02.03.03.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 03:47:51 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id E81C018F6A6; Fri, 3 Feb 2023 12:47:50 +0100 (CET) To: libabigail@sourceware.org Cc: gprocida@google.com, Dodji Seketeli Subject: [PATCH 2/4] dwarf-reader: Remove unused code Organization: Red Hat / France References: <878rhh8xwb.fsf@redhat.com> <87mt5vt3op.fsf@seketeli.org> X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Fri, 03 Feb 2023 12:47:50 +0100 In-Reply-To: <87mt5vt3op.fsf@seketeli.org> (Dodji Seketeli's message of "Fri, 03 Feb 2023 11:59:34 +0100") Message-ID: <87bkmbt1g9.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=-11.7 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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, * src/abg-dwarf-reader.cc (reader::{find_symbol_table_section, lookup_native_elf_symbol_from_index}): Remove these dead functions. Signed-off-by: Dodji Seketeli --- src/abg-dwarf-reader.cc | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index ce6b52d4..566c9db1 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -4815,47 +4815,6 @@ public: var_decls_to_re_add_to_tree() {return var_decls_to_add_;} - /// The section containing the symbol table from the current ELF - /// file. - /// - /// Note that after it's first invocation, this function caches the - /// symbol table that it found. Subsequent invocations just return - /// the cached symbol table section. - /// - /// @return the symbol table section if found - Elf_Scn* - find_symbol_table_section() const - {return find_symbol_table_section();} - - /// Lookup an elf symbol, referred to by its index, from the .symtab - /// section. - /// - /// The resulting symbol returned is an instance of a GElf_Sym, from - /// the libelf library. - /// - /// @param symbol_index the index of the symbol to look up. - /// - /// @param elf_sym out parameter. This is set to the resulting ELF - /// symbol iff the function returns TRUE, meaning the symbol was - /// found. - /// - /// @return TRUE iff the symbol was found. - bool - lookup_native_elf_symbol_from_index(size_t symbol_index, GElf_Sym &elf_sym) - { - Elf_Scn* symtab_section = find_symbol_table_section(); - if (!symtab_section) - return false; - - Elf_Data* symtab = elf_getdata(symtab_section, 0); - ABG_ASSERT(symtab); - - if (!gelf_getsym(symtab, symbol_index, &elf_sym)) - return false; - - return true; - } - /// Test if a DIE represents a decl (function or variable) that has /// a symbol that is exported, whatever that means. This is /// supposed to work for Linux Kernel binaries as well. From patchwork Fri Feb 3 11:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 64246 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 D48F63858407 for ; Fri, 3 Feb 2023 11:48:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D48F63858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675424916; bh=7axMsGcsmb/TBCwI2wAtucGRVe5/UjpuodYIDmes6p4=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=QRIzCFyAaB57ME1Tn5Ke4kIXP7MuJqVprSNGfGfrkpTeTg4djojO1mfs8P5PWMuGS TF5h5C32G5m7KaJq7tGeRZVc1QW0V6ljXvnB/A7kFCfdcyzawUhapQVUbDYuLfUieM Lj+HTDdawPI1bgooQh5z40QRA8WEZORh4ckJD8WQ= 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 8B7573858D20 for ; Fri, 3 Feb 2023 11:48:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B7573858D20 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-189-Q_Y9wVYUOL-TxwCRtJIHTg-1; Fri, 03 Feb 2023 06:48:30 -0500 X-MC-Unique: Q_Y9wVYUOL-TxwCRtJIHTg-1 Received: by mail-wm1-f70.google.com with SMTP id o5-20020a05600c4fc500b003db0b3230efso4454578wmq.9 for ; Fri, 03 Feb 2023 03:48:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7axMsGcsmb/TBCwI2wAtucGRVe5/UjpuodYIDmes6p4=; b=DcvsJ3kB/hjnPNx0guLDJrIHgqsxZ6vYxzvgXpDu8wVq2AR1Btz/xy1RVGDEJJcNt4 wcYwGyIJVHwYVXLAYdwa6j1oNybswGgdY8aII6M7AxBexCgsw7W4G/7Gx3TWiqvkvv08 q1VtwRM1gktUDWAtRWyJEwKu/XkLgn+jiXpz4YQe+TG0Wv79qV/Z7waiZvrHhP8jSaGU b1YBg6Yl+saBwjwI+47pa6akCGHaCghGFRfDVx4V7983wAF43H60jtbvvHZCQA2HwnwR Op06RDXfWYbc/BVGw4y2VxjTKBYo1/ETQbQwzORX6pQoVoul6QK87M7IDz8PjO/rd8nB ncXQ== X-Gm-Message-State: AO0yUKU1G+8JZImCF8WqwZBENzPrxwnvpVE1p4Cl4Q64n/8K5DCJEiGd 53aYUYhurrWXJ5lk/d4fjkHF+WfZHbq7GzQ34CgzboPS0DxoSZt2bAJ0JX6Gc6jsL6tv4//k5IF 705lvxQKD3c1In/nhmEqu X-Received: by 2002:a5d:508d:0:b0:2c3:da8a:192 with SMTP id a13-20020a5d508d000000b002c3da8a0192mr592311wrt.15.1675424908772; Fri, 03 Feb 2023 03:48:28 -0800 (PST) X-Google-Smtp-Source: AK7set9Z1lvvHtvFRgihoH298nhXcPeG6W1j6iptPGpQntzlEOyBY/ofQoQepncZy8dDDRXXPOxv3A== X-Received: by 2002:a5d:508d:0:b0:2c3:da8a:192 with SMTP id a13-20020a5d508d000000b002c3da8a0192mr592303wrt.15.1675424908579; Fri, 03 Feb 2023 03:48:28 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id f6-20020a5d5686000000b002c3daaef051sm463081wrv.82.2023.02.03.03.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 03:48:28 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 8CB9D18F6A6; Fri, 3 Feb 2023 12:48:27 +0100 (CET) To: libabigail@sourceware.org Cc: gprocida@google.com, Dodji Seketeli Subject: [PATCH 3/4] corpus: Handle empty symbol table cases Organization: Red Hat / France References: <878rhh8xwb.fsf@redhat.com> <87mt5vt3op.fsf@seketeli.org> X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Fri, 03 Feb 2023 12:48:27 +0100 In-Reply-To: <87mt5vt3op.fsf@seketeli.org> (Dodji Seketeli's message of "Fri, 03 Feb 2023 11:59:34 +0100") Message-ID: <877cwzt1f8.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=-11.7 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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, There can be cases where the symbol table associated with a given corpus is empty. This patch handles those cases to avoid crashes. * src/abg-corpus.cc (corpus::priv::{get_sorted_fun_symbols, get_sorted_undefined_fun_symbols, get_sorted_var_symbols, get_sorted_undefined_var_symbols}): If the symbol is null, then return an empty vector of symbols. Signed-off-by: Dodji Seketeli --- src/abg-corpus.cc | 58 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index b6f760bb..4f20a888 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -313,9 +313,15 @@ corpus::priv::get_sorted_fun_symbols() const { if (!sorted_fun_symbols) { - auto filter = symtab_->make_filter(); - filter.set_functions(); - sorted_fun_symbols = elf_symbols(symtab_->begin(filter), symtab_->end()); + if (symtab_) + { + auto filter = symtab_->make_filter(); + filter.set_functions(); + sorted_fun_symbols = elf_symbols(symtab_->begin(filter), + symtab_->end()); + } + else + sorted_fun_symbols = elf_symbols(); } return *sorted_fun_symbols; } @@ -349,13 +355,18 @@ corpus::priv::get_sorted_undefined_fun_symbols() const { if (!sorted_undefined_fun_symbols) { - auto filter = symtab_->make_filter(); - filter.set_functions(); - filter.set_undefined_symbols(); - filter.set_public_symbols(false); + if (symtab_) + { + auto filter = symtab_->make_filter(); + filter.set_functions(); + filter.set_undefined_symbols(); + filter.set_public_symbols(false); - sorted_undefined_fun_symbols = - elf_symbols(symtab_->begin(filter), symtab_->end()); + sorted_undefined_fun_symbols = + elf_symbols(symtab_->begin(filter), symtab_->end()); + } + else + sorted_undefined_fun_symbols = elf_symbols(); } return *sorted_undefined_fun_symbols; } @@ -446,10 +457,16 @@ corpus::priv::get_sorted_var_symbols() const { if (!sorted_var_symbols) { - auto filter = symtab_->make_filter(); - filter.set_variables(); + if (symtab_) + { + auto filter = symtab_->make_filter(); + filter.set_variables(); - sorted_var_symbols = elf_symbols(symtab_->begin(filter), symtab_->end()); + sorted_var_symbols = elf_symbols(symtab_->begin(filter), + symtab_->end()); + } + else + sorted_var_symbols = elf_symbols(); } return *sorted_var_symbols; } @@ -483,13 +500,18 @@ corpus::priv::get_sorted_undefined_var_symbols() const { if (!sorted_undefined_var_symbols) { - auto filter = symtab_->make_filter(); - filter.set_variables(); - filter.set_undefined_symbols(); - filter.set_public_symbols(false); + if (symtab_) + { + auto filter = symtab_->make_filter(); + filter.set_variables(); + filter.set_undefined_symbols(); + filter.set_public_symbols(false); - sorted_undefined_var_symbols = - elf_symbols(symtab_->begin(filter), symtab_->end()); + sorted_undefined_var_symbols = + elf_symbols(symtab_->begin(filter), symtab_->end()); + } + else + sorted_undefined_var_symbols = elf_symbols(); } return *sorted_undefined_var_symbols; } From patchwork Fri Feb 3 11:49:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 64247 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 760D53858C33 for ; Fri, 3 Feb 2023 11:49:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 760D53858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675424961; bh=d6Jbfnx3CQajkDySOpRHASacrYRdZG+bvt+2Z78/D2U=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=A5YoXpvOkgH97Ix/kB6YWAzEWEY3fDlTN0f4BqwNGiE1NsOl3f6lHINtejbwMK06w AJR5hNXxgnKlNHXPe3MUmMGv7PpnQmhPXAQiJafkMG16cSOZg+MIrnbUzyn59KICFu a1AGUB9pZmJCwRMW+nKa5FWx95XscsmDuB+O/UL4= 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 108B73858D20 for ; Fri, 3 Feb 2023 11:49:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 108B73858D20 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-633-HHxJDaXsOB2jNde5WLT-8g-1; Fri, 03 Feb 2023 06:49:13 -0500 X-MC-Unique: HHxJDaXsOB2jNde5WLT-8g-1 Received: by mail-wm1-f72.google.com with SMTP id e38-20020a05600c4ba600b003dc434dabbdso4464983wmp.6 for ; Fri, 03 Feb 2023 03:49:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d6Jbfnx3CQajkDySOpRHASacrYRdZG+bvt+2Z78/D2U=; b=fMZlTxJiFtMdmRLJOtb9Vp7N4MK4o+sjCmQccTwiSJ7dziYDmqOEZEtWMtlw9bijM4 CVDOyXqSSBvXdR1TUlzpWeGs8ctOvvfNrpq8cLnMyBBog/3R9NBPrHFilC+voshvIvvY cUnX3px3PXle7Y1sDoqPd1dzJEmH/ZitbV/5QWO1xFgMfpfWFIOq8oWvQSCH4lwvoxun Q+5OCV78lVvNPB01ySPza9ucq8l+nkPtweSGrjFM3JGcj+yCwaxFhFRe2z5WBcQatbDT lx5P4Vy9HZJ2D6btqjq+bbJlCEdCOgjdEiJWoILp+nz62J6bNkyGoqNqEs7pwD8hY7fH 22xw== X-Gm-Message-State: AO0yUKVur2FpxkBl2xlrApzVgqqs9VPjf0wikBFoxmWO6BfbQqrW5k9m 47g8Ymg5DS6rt7+fo+RkHipCrqLE5j7l8MjeBQryPx3le3CKFbVwe8hmCP+gNU2Ua75L3v+26cw 2naOJjUaRUpGLfVArpwJt X-Received: by 2002:a05:6000:1449:b0:2bf:d2d8:d604 with SMTP id v9-20020a056000144900b002bfd2d8d604mr11608015wrx.46.1675424951564; Fri, 03 Feb 2023 03:49:11 -0800 (PST) X-Google-Smtp-Source: AK7set8VfXFB96e6+VImYmgh7I0OARzYOZK6jYe5Ag3dhwROMVfPFer05ZdeHBGU6WT2BsfkChfgBA== X-Received: by 2002:a05:6000:1449:b0:2bf:d2d8:d604 with SMTP id v9-20020a056000144900b002bfd2d8d604mr11607997wrx.46.1675424951387; Fri, 03 Feb 2023 03:49:11 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id e23-20020a5d5957000000b002366e3f1497sm1844820wri.6.2023.02.03.03.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 03:49:10 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 6D91618F6A6; Fri, 3 Feb 2023 12:49:10 +0100 (CET) To: libabigail@sourceware.org Cc: gprocida@google.com, Dodji Seketeli Subject: [PATCH 4/4] {dwarf,elf_based}-reader,writer: Avoid duplicating corpora in corpus_group Organization: Red Hat / France References: <878rhh8xwb.fsf@redhat.com> <87mt5vt3op.fsf@seketeli.org> X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Fri, 03 Feb 2023 12:49:10 +0100 In-Reply-To: <87mt5vt3op.fsf@seketeli.org> (Dodji Seketeli's message of "Fri, 03 Feb 2023 11:59:34 +0100") Message-ID: <87357nt1e1.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=-11.7 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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, It's been brought to my attention on IRC that running abidw --linux-tree would result in a corpus group that duplicates every single corpus in the resulting abixml. Oops. This is because both dwarf::reader::read_corpus() and elf_based_reader::read_and_add_corpus_to_group() add the corpus to the corpus_group, and yet, the later function calls the former. So the corpus is added to the corpus_group twice. This patch ensures that elf_based_reader::read_and_add_corpus_to_group() is the only one to add the corpus to the group. It also ensures that this happens before the corpus is constructed from the debug info because that is useful for sharing types among the various corpora. Otherwise, those types are potentially duplicated in the IR of each corpus. The patch also ensures that the abixml writer enforces the fact that each corpus is emitted only once. * src/abg-dwarf-reader.cc (reader::read_debug_info_into_corpus): Do not add the corpus to the group here ... * src/abg-elf-based-reader.cc (elf_based_reader::read_and_add_corpus_to_group): ... because it's already added here. But then, let's add it here /before/ reading type & symbols information into the corpus. * src/abg-writer.cc (write_context::m_emitted_corpora_set): Add new data member. (write_context::{corpus_is_emitted, record_corpus_as_emitted}): Define new member functions. (write_corpus): Invoke the new write_context::record_corpus_as_emitted here. (write_corpus_group): Ensure that each corpus is emitted only once. Signed-off-by: Dodji Seketeli --- src/abg-dwarf-reader.cc | 3 --- src/abg-elf-based-reader.cc | 4 +--- src/abg-writer.cc | 45 +++++++++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 566c9db1..92ce6c6a 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2121,9 +2121,6 @@ public: corpus()->set_soname(dt_soname()); corpus()->set_needed(dt_needed()); corpus()->set_architecture_name(elf_architecture()); - if (corpus_group_sptr group = corpus_group()) - group->add_corpus(corpus()); - // Set symbols information to the corpus. corpus()->set_symtab(symtab()); diff --git a/src/abg-elf-based-reader.cc b/src/abg-elf-based-reader.cc index cd7b59b6..d1d9a2df 100644 --- a/src/abg-elf-based-reader.cc +++ b/src/abg-elf-based-reader.cc @@ -92,10 +92,8 @@ ir::corpus_sptr elf_based_reader::read_and_add_corpus_to_group(ir::corpus_group& group, fe_iface::status& status) { + group.add_corpus(corpus()); ir::corpus_sptr corp = read_corpus(status); - - if (status & fe_iface::STATUS_OK) - group.add_corpus(corp); return corp; } diff --git a/src/abg-writer.cc b/src/abg-writer.cc index 1fb067b8..9fe3dec7 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -230,7 +230,8 @@ class write_context class_tmpl_shared_ptr_map m_class_tmpl_id_map; string_elf_symbol_sptr_map_type m_fun_symbol_map; string_elf_symbol_sptr_map_type m_var_symbol_map; - unordered_set m_emitted_decls_set; + unordered_set m_emitted_decls_set; + unordered_set m_emitted_corpora_set; write_context(); @@ -818,6 +819,42 @@ public: m_emitted_decls_set.insert(irepr); } + /// Test if a corpus has already been emitted. + /// + /// A corpus is emitted if it's been recorded as having been emitted + /// by the function record_corpus_as_emitted(). + /// + /// @param corp the corpus to consider. + /// + /// @return true iff the corpus @p corp has been emitted. + bool + corpus_is_emitted(const corpus_sptr& corp) + { + if (!corp) + return false; + + if (m_emitted_corpora_set.find(corp->get_path()) + == m_emitted_corpora_set.end()) + return false; + + return true; + } + + /// Record the corpus has having been emitted. + /// + /// @param corp the corpus to consider. + void + record_corpus_as_emitted(const corpus_sptr& corp) + { + if (!corp) + return; + + const string& path = corp->get_path(); + ABG_ASSERT(!path.empty()); + + m_emitted_corpora_set.insert(path); + } + /// Get the set of types that have been emitted. /// /// @return the set of types that have been emitted. @@ -4588,6 +4625,7 @@ write_corpus(write_context& ctxt, out << "\n"; ctxt.clear_referenced_types(); + ctxt.record_corpus_as_emitted(corpus); return true; } @@ -4639,7 +4677,10 @@ std::ostream& out = ctxt.get_ostream(); group->get_corpora().begin(); c != group->get_corpora().end(); ++c) - write_corpus(ctxt, *c, get_indent_to_level(ctxt, indent, 1), true); + { + ABG_ASSERT(!ctxt.corpus_is_emitted(*c)); + write_corpus(ctxt, *c, get_indent_to_level(ctxt, indent, 1), true); + } do_indent_to_level(ctxt, indent, 0); out << "\n";