From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id EF9073858418 for ; Mon, 26 Jun 2023 15:35:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF9073858418 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2C6A121855 for ; Mon, 26 Jun 2023 15:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687793709; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=hWs/Ve0zaddZX7i9X/e4i7rgw1NrO82n7fI2AfZa4hM=; b=IYghKHYSZYq5e0SUhUFXFZoGrc8WEQtKA8VJAHXH1CWGZxOdQp3DLl9zddYtSyOzIChygu 989ne5aU3Br8eGOk6wq2Q+GzbELKskFMph44XP+smrleSceBIMgbRXo4DDB9tuXiXpjmiF 9oJAYygzCOXGSldemkBzlICHsDi/5/k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687793709; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=hWs/Ve0zaddZX7i9X/e4i7rgw1NrO82n7fI2AfZa4hM=; b=cKNpizqe/8MZUZPVeJDn6NPhiXwsdzJc95cM+sqO0f4cC1sBeksbVcoM7N5/nqaBmYspYC 64ouhfI/opyNMkCQ== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 216112C141 for ; Mon, 26 Jun 2023 15:35:09 +0000 (UTC) Received: by wotan.suse.de (Postfix, from userid 10510) id 1849367ED; Mon, 26 Jun 2023 15:35:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by wotan.suse.de (Postfix) with ESMTP id 175F065E2 for ; Mon, 26 Jun 2023 15:35:09 +0000 (UTC) Date: Mon, 26 Jun 2023 15:35:09 +0000 (UTC) From: Michael Matz To: binutils@sourceware.org Subject: [PATCH] section-match: Check parent archive name as well Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,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 List-Id: rewriting the section matching routines lost a special case of matching: section statements of the form NAME(section-glob) normally match against NAME being an object file, but like in the exclude list we happened to accept archive names as NAME (undocumented). The documented way to specify (all) archive members is by using e.g. lib.a:(section-glob) (that does work also with the prefix tree matcher). But I intended to not actually change behaviour with the prefix tree implementation. So, let's also implement checking against archive names with a similar FIXME comment we already have in walk_wild_file_in_exclude_list. --- Regtesting on Alans targets in progress, on x86_64-linux it finished already successfully. Okay for master? --- ld/ldlang.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ld/ldlang.c b/ld/ldlang.c index 78716f17729..e359a89fcc0 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -445,8 +445,19 @@ walk_wild_section_match (lang_wild_statement_type *ptr, about unset local_sym_name (in which case lookup_name simply adds the input file again). */ const char *filename = file->local_sym_name; - if (filename == NULL - || filename_cmp (filename, file_spec) != 0) + lang_input_statement_type *arch_is; + if (filename && filename_cmp (filename, file_spec) == 0) + ; + /* FIXME: see also walk_wild_file_in_exclude_list for why we + also check parents BFD (local_sym_)name to match input statements + with unadorned archive names. */ + else if (file->the_bfd + && file->the_bfd->my_archive + && (arch_is = bfd_usrdata (file->the_bfd->my_archive)) + && arch_is->local_sym_name + && filename_cmp (arch_is->local_sym_name, file_spec) == 0) + ; + else return; } -- 2.39.1