From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by sourceware.org (Postfix) with ESMTPS id 611CE3858D39 for ; Tue, 1 Mar 2022 21:56:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 611CE3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f41.google.com with SMTP id g7-20020a17090a708700b001bb78857ccdso3054346pjk.1 for ; Tue, 01 Mar 2022 13:56:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iLvUB5sI+jyS5dcD0Yujp9YsU1RNcls0qBpw6UUhrfo=; b=BLTVP1O1qmmXn94RZbd5KnnMSqe8eVea5Nh7PlMs/NptWxzGw6J1fHiJgH/zhICp7e 6RHBkwCNvdRTaXw22scE+3r+c1TlqOzVVK0drgoPZy224FFHukXV8Tkz8Qw1S7QbjemD EkRhRuzBERH8m+J4bcxxUGcuGsKNuBwEa5HSHaOG6vQNfedZz6r/N3wraUYwGruvXJXV BsWYgQ87pK3qGIwubkvvtadAxUye2SgKtxDzV2Ayj101dTg10FLURMAbWncUkJNGAZye Mt4tYHp3/CfKIM2/Vxg+TCy/dfcwmVUHxU8xvAb2DNJzTIswKQSF04dv/1NJiJulb+VB pmJg== X-Gm-Message-State: AOAM533EiPb8n5u6p3nMJtsPfML9If1KgxuW74/oLvVPNc8eEBT7q22F WIqoXnmFxWX/KFvHTJ8B4nI= X-Google-Smtp-Source: ABdhPJxBCAHyiT1H//VjBd5B0aJXm/N7hNY+quL8OEm1LGbCAGn2o2Jp5yTYOXvdL3p2bXZ0NQ8zDg== X-Received: by 2002:a17:90a:dd45:b0:1bc:9466:9b64 with SMTP id u5-20020a17090add4500b001bc94669b64mr23885883pjv.23.1646171786403; Tue, 01 Mar 2022 13:56:26 -0800 (PST) Received: from localhost ([2601:647:6300:b760:bba1:8dfd:8ba3:ad0]) by smtp.gmail.com with ESMTPSA id k17-20020aa788d1000000b004f359a0a896sm17935246pff.169.2022.03.01.13.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 13:56:26 -0800 (PST) Date: Tue, 1 Mar 2022 13:56:25 -0800 From: Fangrui Song To: Fangrui Song Cc: binutils@sourceware.org, Alan Modra , Nick Clifton Subject: Re: [PATCH] objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols Message-ID: <20220301215625.m2pgudasqwzm4ipx@gmail.com> References: <20220301213606.259903-1-maskray@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20220301213606.259903-1-maskray@google.com> X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Tue, 01 Mar 2022 21:56:30 -0000 On 2022-03-01, Fangrui Song via Binutils wrote: > PR binutils/28926 > * objcopy.c (filter_symbols): Apply weaken to STB_GNU_UNIQUE symbols > * NEWS: Mention feature. > * testsuite/binutils-all/objcopy.exp (objcopy_test_symbol_manipulation): New test. > * testsuite/binutils-all/weaken-gnu-unique.s: New. typo: weaken-gnu-unique.s -> weaken-gnu-unique.d >--- > binutils/NEWS | 3 +++ > binutils/objcopy.c | 4 ++-- > binutils/testsuite/binutils-all/objcopy.exp | 4 ++++ > binutils/testsuite/binutils-all/weaken-gnu-unique.d | 8 ++++++++ > 4 files changed, 17 insertions(+), 2 deletions(-) > create mode 100644 binutils/testsuite/binutils-all/weaken-gnu-unique.d > >diff --git a/binutils/NEWS b/binutils/NEWS >index c188b469a77..06f34c9a992 100644 >--- a/binutils/NEWS >+++ b/binutils/NEWS >@@ -1,5 +1,8 @@ > -*- text -*- > >+* objcopy --weaken, --weaken-symbol, and --weaken-symbols now make ELF >+ STB_GNU_UNIQUE symbols weak. >+ > Changes in 2.38: > > * elfedit: Add --output-abiversion option to update ABIVERSION. >diff --git a/binutils/objcopy.c b/binutils/objcopy.c >index d53aa5c6000..aaa5aa9b2af 100644 >--- a/binutils/objcopy.c >+++ b/binutils/objcopy.c >@@ -1681,11 +1681,11 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, > > if (keep) > { >- if (((flags & BSF_GLOBAL) != 0 >+ if (((flags & (BSF_GLOBAL | BSF_GNU_UNIQUE)) > || undefined) > && (weaken || is_specified_symbol (name, weaken_specific_htab))) > { >- sym->flags &= ~ BSF_GLOBAL; >+ sym->flags &= ~ (BSF_GLOBAL | BSF_GNU_UNIQUE); > sym->flags |= BSF_WEAK; > } > >diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp >index 32c76a11f3b..9a5dad5384e 100644 >--- a/binutils/testsuite/binutils-all/objcopy.exp >+++ b/binutils/testsuite/binutils-all/objcopy.exp >@@ -1144,6 +1144,10 @@ proc objcopy_test_symbol_manipulation {} { > verbose [file rootname $t] > run_dump_test [file rootname $t] > } >+ >+ if { [supports_gnu_unique] } { >+ run_dump_test "weaken-gnu-unique" >+ } > } > > proc objcopy_test_elf_common_symbols {} { >diff --git a/binutils/testsuite/binutils-all/weaken-gnu-unique.d b/binutils/testsuite/binutils-all/weaken-gnu-unique.d >new file mode 100644 >index 00000000000..b0e60c4ff80 >--- /dev/null >+++ b/binutils/testsuite/binutils-all/weaken-gnu-unique.d >@@ -0,0 +1,8 @@ >+#name: weaken STB_GNU_UNIQUE symbols >+#PROG: objcopy >+#objcopy: -W foo >+#source: unique.s >+#readelf: -s >+ >+#... >+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +OBJECT +WEAK +DEFAULT +[1-9] foo >-- >2.35.1.574.g5d30c73bfb-goog >