From patchwork Mon Jun 26 15:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Matz X-Patchwork-Id: 113014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7568681vqr; Mon, 26 Jun 2023 08:35:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eI0jVgJiaHwEML5M0+e2BJuQGzZHtikEt2RTByP96aNDPM6emK3aoLFhaZsNk7+/cFvEf X-Received: by 2002:a2e:2e07:0:b0:2b6:a5a4:188c with SMTP id u7-20020a2e2e07000000b002b6a5a4188cmr1197567lju.45.1687793724323; Mon, 26 Jun 2023 08:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687793724; cv=none; d=google.com; s=arc-20160816; b=V7aou249nNX6vDB2musd7yG+S2m8XW1mOIs0WttKmTzHcu/ycUBHS3YC6jZcOyvV88 aAmuAqsJisrzfUKnH9Bqyf/LtLTfsBzrcE89TSJY6/AtD+CtCOy3+N0/gYcXREgBZPBE dEyGs64416Pp6rYEjf4EYXDOBfFwP3YjDzrBzc00pSTmiyNreN1PsUoltlPvLWyshnzr Mwn5xPtLUK3Qk+mywQCfd4PPLUiv3jHb9pBkuAHGkusyY4/mZNEP1omYEjSTl73NInvo lVxmcw8k6N+EoNdiPe0iWhxJFlOtK9VloLykIW3csfWGoP0nmvtPOyUBlA7EmaaT41sS BnSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=hWs/Ve0zaddZX7i9X/e4i7rgw1NrO82n7fI2AfZa4hM=; fh=NLxAvL/bDfPg4AGOtxqvQlND8vazkZrNzKLY8+LAbBY=; b=fuqyeOw+9LpHiMuOUWQrefoXw7uWzEMOYNOaaVx1lEB/V4J84f0zvSf//uB7/vB7ww 3AUFdnpV7WFSUBaDh7yoktO3JKpmvOgSZNaPnZkm2V0JG+4aqfEc57xbS0TBA2ZO1zMd ZNjLG7hH/X+bP+zp5MahVT3kqz2Tq+3d5HMA02fuHSO0fCG9/RTbwwUUZLM9jFNngVsZ v+RICBX3F9XFaXFQG3uudbM5eqm3ksFUT+N6wpGRX8t+K+QJb/Es1+4wYvRb1pMFjlTR tqcQG7Zf02Wz4pT4Pg3Xa0vcWH6KhV7y26AbHxSw0WqeUlodBku9q8B4z6sL8uHdKo38 OH3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lip1XnsP; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i17-20020a1709064ed100b009745bad4249si3014255ejv.869.2023.06.26.08.35.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 08:35:24 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lip1XnsP; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3DEDC3858418 for ; Mon, 26 Jun 2023 15:35:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DEDC3858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687793718; bh=hWs/Ve0zaddZX7i9X/e4i7rgw1NrO82n7fI2AfZa4hM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lip1XnsPlVTdDxAeGU4G3fbMeAxWNp5Uat8nnZ0xBcMcULSeOq38LmMw9wToQ/lrF bNtTGktjcSLc5fRVQZI8EP8FklSOR47TB5P+NWIPYF+Q48wzDH4tmbLbVVSqPrBwkU yOpjki/lhlVlSk2DndpIV1skXeqm6caJjI+z+v+g= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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) 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) 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 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Michael Matz via Binutils From: Michael Matz Reply-To: Michael Matz Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769779991967486934?= X-GMAIL-MSGID: =?utf-8?q?1769779991967486934?= 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; }