From patchwork Thu Sep 7 13:41:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 75450 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 C2CD8393BA7D for ; Thu, 7 Sep 2023 13:41:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2CD8393BA7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694094076; bh=iKTPU30GEAOLnntjj8KpqSRBxbJd3br2KLjPH8XHgNA=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=g8YfiqBZoDNvQNyJaiBpL8GNaZFFvw6xoCyYCGPSuGkodeOBYCgEXYr6BWp6v6mVL QXoSa1YAkn65zqO8kwwtvQ8zvnbsEPRpJLAD/82rn6pgudlYkvpmuaaqR4c9NLT0ra vf+I55Cwr7wFAm6j2bFwlFrrdAUNfTdL1BHy+evc= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 4279A3882077 for ; Thu, 7 Sep 2023 13:41:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4279A3882077 Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-230-HEgNMELDNPWIkRcAM7BknQ-1; Thu, 07 Sep 2023 09:41:06 -0400 X-MC-Unique: HEgNMELDNPWIkRcAM7BknQ-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-6bb31a92b44so1073968a34.0 for ; Thu, 07 Sep 2023 06:41:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694094066; x=1694698866; 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=iKTPU30GEAOLnntjj8KpqSRBxbJd3br2KLjPH8XHgNA=; b=BGF7/DWoX8x6yTDFH17ZGZXr2ZCnGOKafHGUl8be+4HJFSrhFAxnwTElgZtQHPO0lv 77tQ1WEKp9sRcvrT8Q+y5/X6IB3prrHgoanSoNp1MNziPB2N+AFAJELeOlDUZLfp6Od1 n9ftMpJn8JPZ8MJAIp3lVTTXH4PiQh4xfoutUOBkj0why9i3YmGvEbjSYReF3rd2iNDP cs3Q0sucoz+IkNMZK3BM/vw3Bq42Vi/BVNcq6Yo84WvlKioqQ9y5ysHgEIq7hgOJ3MMY 7U+XtSxllgM/N5lU5Urkf9O3S8Zx75xdj9YHsWrbMHMB5XWtKvp8AC3QhdLW88UL6rNV f3cQ== X-Gm-Message-State: AOJu0Ywecz4oJTIPoXzxx4pESYiCOD5qPZtECW3D2ZwCBsXYnvG+DfH+ ZGdUNvPyDEs7gqyCmAdJp04tDCcr8zzPh0+qCGV64zgBkux0Bkcksjoo+z9zARQ9luacTEXEGf+ TgHgnYW3fErX8jit68RbpeL9srFmx X-Received: by 2002:a9d:7d94:0:b0:6b9:68fb:5b73 with SMTP id j20-20020a9d7d94000000b006b968fb5b73mr19456805otn.1.1694094065905; Thu, 07 Sep 2023 06:41:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXvwrCcsiLaeL+vwxJ1h1vkD3hz6FMX+nGeVVqX7f0pQMg7fCe1MNx4uh4VU+zdA8lKWJmtw== X-Received: by 2002:a9d:7d94:0:b0:6b9:68fb:5b73 with SMTP id j20-20020a9d7d94000000b006b968fb5b73mr19456796otn.1.1694094065652; Thu, 07 Sep 2023 06:41:05 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id e23-20020a0caa57000000b0064f4e0b2089sm6426380qvb.33.2023.09.07.06.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 06:41:05 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id A06CEB4FD2; Thu, 7 Sep 2023 15:41:03 +0200 (CEST) To: Dodji Seketeli Cc: libabigail@sourceware.org Subject: [PATCH 07/16] {dwarf,elf}reader: Don't consider no symbol table as an error Organization: Red Hat / France References: <87il8mglc1.fsf@redhat.com> X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Thu, 07 Sep 2023 15:41:03 +0200 In-Reply-To: <87il8mglc1.fsf@redhat.com> (Dodji Seketeli's message of "Thu, 07 Sep 2023 15:32:46 +0200") Message-ID: <87msxyf6ds.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 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_H3, RCVD_IN_MSPIKE_WL, 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.30 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, Some binaries don't have any symbol table. Libabigail's ELF and DWARF readers error out on those binaries, making fedabipkgdiff emitting an error when performing the self-comparison of the package containing those binaries. This patch handles a binary having no symbol table almost as a binary that has an empty symbol table, making abipkgdiff and fedabipkgdiff not error out on those binaries anymore. This makes the command below succeed: $ fedabipkgdiff --self-compare -a --from fc34 glibc * src/abg-dwarf-reader.cc (reader::read_corpus): Return an empty corpus if no symbol was found. Do not crash when no symbol table is found. * src/abg-elf-reader.cc (reader::read_corpus): Consider a corpus with no symbol table as being OK. * src/abg-reader.cc (build_elf_symbol_from_reference): Do not crash when no symbol table is present. Signed-off-by: Dodji Seketeli Applied to master. --- src/abg-dwarf-reader.cc | 11 ++++++----- src/abg-elf-reader.cc | 8 ++++---- src/abg-reader.cc | 13 ++++++++----- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 6e472d3a..2416c7f3 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2072,12 +2072,12 @@ public: // Load the generic ELF parts of the corpus. elf::reader::read_corpus(status); - if ((status & STATUS_NO_SYMBOLS_FOUND) - || !(status & STATUS_OK)) - // Either we couldn't find ELF symbols or something went badly - // wrong. There is nothing we can do with this ELF file. Bail - // out. + if (!(status & STATUS_OK)) + { + // Something went badly wrong. There is nothing we can do + // with this ELF file. Bail out. return corpus_sptr(); + } // If we couldn't find debug info from the elf path, then say it. if (dwarf_debug_info() == nullptr) @@ -2143,6 +2143,7 @@ public: // Get out now if no debug info is found or if the symbol table is // empty. if (!dwarf_debug_info() + || !corpus()->get_symtab() || !corpus()->get_symtab()->has_symbols()) return corpus(); diff --git a/src/abg-elf-reader.cc b/src/abg-elf-reader.cc index 7884c672..f4dae766 100644 --- a/src/abg-elf-reader.cc +++ b/src/abg-elf-reader.cc @@ -978,12 +978,12 @@ reader::read_corpus(status& status) // See if we could find symbol tables. if (!symtab()) { - status |= STATUS_NO_SYMBOLS_FOUND; + status |= STATUS_NO_SYMBOLS_FOUND | STATUS_OK; // We found no ELF symbol, so we can't handle the binary. Note // that we could have found a symbol table with no defined & - // exported ELF symbols in it. That case is handled as an empty - // corpus, which is different from this case. - return corpus_sptr(); + // exported ELF symbols in it. Both cases are handled as an + // empty corpus. + return corpus(); } // Set symbols information to the corpus. diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 520d158a..2b902096 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -3272,12 +3272,15 @@ build_elf_symbol_from_reference(reader& rdr, const xmlNodePtr node) if (name.empty()) return nil; - const elf_symbols& symbols = - rdr.corpus()->get_symtab()->lookup_symbol(name); + if (rdr.corpus()->get_symtab()) + { + const elf_symbols& symbols = + rdr.corpus()->get_symtab()->lookup_symbol(name); - for (const auto& symbol : symbols) - if (symbol->get_id_string() == sym_id) - return symbol; + for (const auto& symbol : symbols) + if (symbol->get_id_string() == sym_id) + return symbol; + } } return nil;