From patchwork Mon Jun 30 17:59:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 115334 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 C66A6386075E for ; Mon, 30 Jun 2025 17:59:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C66A6386075E 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=Fl8mVXtX 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 ESMTP id 27DE43858294 for ; Mon, 30 Jun 2025 17:59:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27DE43858294 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 27DE43858294 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1751306381; cv=none; b=OHT8LIBpd5iQUp7NhgF+XMrSKTDeY/AxObVGoJjc46TnbOMVjTdR9DuTuuMvn8vKYh99IPUlyEHUh5PkbjU0LgJ9oTD3Ucp6S2K22sjpEL517Y4XT3coIxuLsNWHBdVvYeNaFGxN7tXlBurrLEnYNctGA9xcafNZbdRlkH4bXzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1751306381; c=relaxed/simple; bh=fPLGBvKjsmA/b4j/H8gtg1TYgNi7Wz6B+6is/eB5GN8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IrI8dHTcpbP8OzA22PtEWa7RRNiXPNuObusZxvxYkDgPTYwNcLh1iZoMBGRcdKA0AM9MmBt7zbdO1/RgiJahqPA0lookHtux1YsnYi1kjXWgvdbMjO70qfS2VwRtSKMT0eFU/5jJCUyKrK2QsqZG6gHao/wTGydC6Jfw6M2/QMY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27DE43858294 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751306380; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=0TQbV5cM2TVJCWmxcudy89DwHQUfrGVEbc3zUPK8NBU=; b=Fl8mVXtXzZ49WgKv7UB+BBv/X08cRBdkZssHyNsTzlv8HMdu+WYSWyRJZkg06a2bHu6cnq Ojo9qrTwb4D89Vs5SOUYQjTCsrjI2Irj2jE64JhmW/r1pIL/j9z6TE5fadUzu2fb3hBH+L hZta/BSNG5a/Z0g6mO9cTg/EdaqbsSY= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-2lZNBPcXN1qSvdp1XzZ8gQ-1; Mon, 30 Jun 2025 13:59:39 -0400 X-MC-Unique: 2lZNBPcXN1qSvdp1XzZ8gQ-1 X-Mimecast-MFC-AGG-ID: 2lZNBPcXN1qSvdp1XzZ8gQ_1751306378 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3EBB919373D7 for ; Mon, 30 Jun 2025 17:59:38 +0000 (UTC) Received: from localhost (unknown [10.44.22.5]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4D492195E74A for ; Mon, 30 Jun 2025 17:59:37 +0000 (UTC) Received: by localhost (Postfix, from userid 1000) id 8D88A504EC40; Mon, 30 Jun 2025 19:59:34 +0200 (CEST) From: Dodji Seketeli To: libabigail@sourceware.org Subject: [PATCH, applied] elf-reader,symtab-reader: Fix suppression of aliased symbols Organization: Red Hat / France X-Operating-System: AlmaLinux 9.6 X-URL: http://www.redhat.com Date: Mon, 30 Jun 2025 19:59:34 +0200 Message-ID: <87a55prtyx.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YPPWFW7ZvuDWvWIRlB21f_rHKj2767bUYXYLgbbIVQs_1751306378 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 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_HOSTKARMA_W, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, 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-Post: List-Help: List-Subscribe: , Errors-To: libabigail-bounces~patchwork=sourceware.org@sourceware.org Hello, An aliased ELF symbol should be suppressed only if all of its aliases are suppressed. Otherwise, it's not suppressed. Also, the test-read-dwarf.cc ignores the suppression specification provided in the test entry. Fixed thus. * src/abg-elf-reader.cc (reader::symtab): Rewrite the closure that determines if a symbol is suppressed. Make it so that all aliases of a symbol has to be suppressed for the symbol to be suppressed. * src/abg-symtab-reader.cc (symtab::load_): Wait until all symbols aliases are constructed before determining if they are suppressed. This is because aliases are now necessary to determine if a symbol is suppressed. * tests/test-read-common.h (test_task::set_in_suppr_spec_path): Empty suppression specification shouldn't trigger us. * tests/test-read-dwarf.cc (test_task_dwarf::perform): Take the suppression specifications into account on the command line. * tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Adjust. * tests/data/test-read-dwarf/test-suppressed-alias.o.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-1.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-4.so.hash.abi: Likewise. Signed-off-by: Dodji Seketeli Applied to the mainline. --- src/abg-elf-reader.cc | 19 +- src/abg-symtab-reader.cc | 28 +- .../test-read-dwarf/libtest24-drop-fns.so.abi | 367 ++++++++---------- .../test-suppressed-alias.o.abi | 8 - .../test-read-dwarf/test3-alias-1.so.hash.abi | 2 - .../test-read-dwarf/test3-alias-2.so.hash.abi | 9 +- .../test-read-dwarf/test3-alias-3.so.hash.abi | 11 - .../test-read-dwarf/test3-alias-4.so.hash.abi | 11 - tests/test-read-common.h | 3 +- tests/test-read-dwarf.cc | 6 +- 10 files changed, 213 insertions(+), 251 deletions(-) diff --git a/src/abg-elf-reader.cc b/src/abg-elf-reader.cc index 8642f701..5d30c602 100644 --- a/src/abg-elf-reader.cc +++ b/src/abg-elf-reader.cc @@ -645,7 +645,24 @@ reader::symtab() const priv_->symt = symtab_reader::symtab::load (elf_handle(), options().env, [&](const elf_symbol_sptr& symbol) - {return suppr::is_elf_symbol_suppressed(*this, symbol);}); + { + // This closure determines if a given symbol is suppressed by + // taking into accont symbol aliases. Basically, a symbol is + // suppressed if all its aliases are suppressed. + if (!symbol) + return false; + if (!suppr::is_elf_symbol_suppressed(*this, symbol)) + return false; + for (elf_symbol_sptr a = symbol->get_next_alias(); + a && a.get() != symbol->get_main_symbol().get(); + a = a->get_next_alias()) + { + if (!suppr::is_elf_symbol_suppressed(*this, a)) + return false; + } + return true; + } + ); if (!priv_->symt) std::cerr << "Symbol table of '" << corpus_path() diff --git a/src/abg-symtab-reader.cc b/src/abg-symtab-reader.cc index 8cbc7865..eb6c33a6 100644 --- a/src/abg-symtab-reader.cc +++ b/src/abg-symtab-reader.cc @@ -551,15 +551,6 @@ symtab::load_(Elf* elf_handle, elf_helpers::stv_to_elf_symbol_visibility (GELF_ST_VISIBILITY(sym->st_other))); - // We do not take suppressed symbols into our symbol vector to avoid - // accidental leakage. But we ensure supressed symbols are otherwise set - // up for lookup. - if (!(is_suppressed && is_suppressed(symbol_sptr))) - // add to the symbol vector - symbols_.push_back(symbol_sptr); - else - symbol_sptr->set_is_suppressed(true); - // add to the name->symbol lookup name_symbol_map_[name].push_back(symbol_sptr); @@ -583,6 +574,25 @@ symtab::load_(Elf* elf_handle, setup_symbol_lookup_tables(elf_handle, sym, symbol_sptr); } + // Now that symbols aliases have been constructed, let's determine + // what symbol has been suppressed or not. Suppression takes into + // account + for (auto& elem : name_symbol_map_) + { + auto& symbols = elem.second; + for (auto& symbol : symbols) + { + // We do not take suppressed symbols into our symbol vector + // to avoid accidental leakage. But we ensure supressed + // symbols are otherwise set up for lookup. + if (!(is_suppressed && is_suppressed(symbol))) + // add to the symbol vector + symbols_.push_back(symbol); + else + symbol->set_is_suppressed(true); + } + } + add_alternative_address_lookups(elf_handle); is_kernel_binary_ = elf_helpers::is_linux_kernel(elf_handle); diff --git a/tests/data/test-read-dwarf/libtest24-drop-fns.so.abi b/tests/data/test-read-dwarf/libtest24-drop-fns.so.abi index 250a34d4..683ed185 100644 --- a/tests/data/test-read-dwarf/libtest24-drop-fns.so.abi +++ b/tests/data/test-read-dwarf/libtest24-drop-fns.so.abi @@ -12,385 +12,356 @@ - - - - + + + - - - - - - - - - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - + + + + + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - + + + + diff --git a/tests/data/test-read-dwarf/test-suppressed-alias.o.abi b/tests/data/test-read-dwarf/test-suppressed-alias.o.abi index ff154e87..dfc00e03 100644 --- a/tests/data/test-read-dwarf/test-suppressed-alias.o.abi +++ b/tests/data/test-read-dwarf/test-suppressed-alias.o.abi @@ -7,12 +7,4 @@ - - - - - - - - diff --git a/tests/data/test-read-dwarf/test3-alias-1.so.hash.abi b/tests/data/test-read-dwarf/test3-alias-1.so.hash.abi index 63423970..e4e4e46a 100644 --- a/tests/data/test-read-dwarf/test3-alias-1.so.hash.abi +++ b/tests/data/test-read-dwarf/test3-alias-1.so.hash.abi @@ -5,8 +5,6 @@ - - diff --git a/tests/data/test-read-dwarf/test3-alias-2.so.hash.abi b/tests/data/test-read-dwarf/test3-alias-2.so.hash.abi index 63423970..dbf2387c 100644 --- a/tests/data/test-read-dwarf/test3-alias-2.so.hash.abi +++ b/tests/data/test-read-dwarf/test3-alias-2.so.hash.abi @@ -3,17 +3,10 @@ - - + - - - - - - diff --git a/tests/data/test-read-dwarf/test3-alias-3.so.hash.abi b/tests/data/test-read-dwarf/test3-alias-3.so.hash.abi index 63423970..446397f3 100644 --- a/tests/data/test-read-dwarf/test3-alias-3.so.hash.abi +++ b/tests/data/test-read-dwarf/test3-alias-3.so.hash.abi @@ -3,17 +3,6 @@ - - - - - - - - - - - diff --git a/tests/data/test-read-dwarf/test3-alias-4.so.hash.abi b/tests/data/test-read-dwarf/test3-alias-4.so.hash.abi index 63423970..fccf3abc 100644 --- a/tests/data/test-read-dwarf/test3-alias-4.so.hash.abi +++ b/tests/data/test-read-dwarf/test3-alias-4.so.hash.abi @@ -3,17 +3,6 @@ - - - - - - - - - - - diff --git a/tests/test-read-common.h b/tests/test-read-common.h index f00205b9..3b2884a0 100644 --- a/tests/test-read-common.h +++ b/tests/test-read-common.h @@ -10,6 +10,7 @@ #ifndef __TEST_READ_COMMON_H__ #define __TEST_READ_COMMON_H__ +#include #include #include "abg-ir.h" #include "abg-corpus.h" @@ -77,7 +78,7 @@ struct test_task : public abigail::workers::task void set_in_suppr_spec_path() { - if (spec.in_suppr_spec_path) + if (spec.in_suppr_spec_path && strcmp(spec.in_suppr_spec_path, "")) in_suppr_spec_path = in_elf_base + spec.in_suppr_spec_path; else in_suppr_spec_path.clear(); diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc index 3d3d3932..194b3f88 100644 --- a/tests/test-read-dwarf.cc +++ b/tests/test-read-dwarf.cc @@ -661,10 +661,12 @@ test_task_dwarf::perform() return; string abidw = string(get_build_dir()) + "/tools/abidw"; - string drop_private_types; + string drop_private_types, suppr_specs; if (!in_public_headers_path.empty()) drop_private_types += "--headers-dir " + in_public_headers_path + " --drop-private-types"; + if (!in_suppr_spec_path.empty()) + suppr_specs = " --suppr " + in_suppr_spec_path + " "; string type_id_style = "sequence"; if (spec.type_id_style == HASH_TYPE_ID_STYLE) type_id_style = "hash"; @@ -672,7 +674,7 @@ test_task_dwarf::perform() string cmd = abidw + " --no-parameter-names --no-architecture --no-load-undefined-interfaces" + " --type-id-style " + type_id_style + " --no-corpus-path " - + drop_private_types + " " + in_elf_path + + drop_private_types + suppr_specs + " " + in_elf_path +" > " + out_abi_path; if (system(cmd.c_str()))