From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 0A0C9385703C for ; Wed, 3 Mar 2021 07:15:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0A0C9385703C Received: by mail-pl1-x62b.google.com with SMTP id d8so3108654plg.10 for ; Tue, 02 Mar 2021 23:15:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=qlrkfsNuKThvj4sznx3HMTwPBNZ1Zd1ZDhVCVhNRMqk=; b=NwnSnIHZBB8oLNUBnWEDbUzIUpAmiyOlHfU1XqwNcQvKnS5737SYnLtJ753BOLbZnd Tw4fr83Wgc6yKPm7AxKD17MPq7S51VoPY6XdvSVDri1KeP7+jFv0mTtFkhrzmI2oAVwe 3pD1D1hmcRPtayRxUQyPoBgcLtTCHLeiypago5js5lULjckoonvjkJLfDywDY+PgC3DS fh0jbs7tdDiqYsdVDvxvgtb18LhnKwcl4W9AB5Fn+tn7XUJenRYHKND5jmsVdQ6SEO7S h2g86Ed6UPsPrZNKmfphjm3ckU+xxCoMIC70X/Oz66IsdZnU8RWtISgX3AAUIWgzKp+a k2DQ== X-Gm-Message-State: AOAM531HQvdXjpeLk66r/l/XVZ9MZshW2gxDM3j5Kj2loF1+QIprZVzO oYW1LumKN3wR1qZgkpdrthx8InrRA/4rTA== X-Google-Smtp-Source: ABdhPJznvTwTL4DV73M6xgM/05217TriF76Cv35JnXviPs1K8nzucz6Jse5wCkKMTU2t4w+uYqJLkw== X-Received: by 2002:a17:90a:bb95:: with SMTP id v21mr8089641pjr.30.1614755718963; Tue, 02 Mar 2021 23:15:18 -0800 (PST) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id na8sm4960417pjb.2.2021.03.02.23.15.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 23:15:18 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id E4F8B40A79; Wed, 3 Mar 2021 17:45:14 +1030 (ACDT) Date: Wed, 3 Mar 2021 17:45:14 +1030 From: Alan Modra To: binutils@sourceware.org Subject: PR27493, objcopy --weaken-symbol does not weaken undefined symbols Message-ID: <20210303071514.GN6042@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-3040.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 03 Mar 2021 07:15:21 -0000 PR 27493 * objcopy.c (filter_symbols): Apply --weaken to undefined symbols. * NEWS: Mention feature. diff --git a/binutils/NEWS b/binutils/NEWS index d66944e95e..2e93100a38 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -1,5 +1,8 @@ -*- text -*- +* objcopy --weaken, --weaken-symbol and --weaken-symbols now make undefined + symbols weak on targets that support weak symbols. + * Readelf and objdump can now display and use the contents of .debug_sup sections. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 041aceaeef..99e6cad72e 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1673,7 +1673,8 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, if (keep) { - if ((flags & BSF_GLOBAL) != 0 + if (((flags & BSF_GLOBAL) != 0 + || undefined) && (weaken || is_specified_symbol (name, weaken_specific_htab))) { sym->flags &= ~ BSF_GLOBAL; -- Alan Modra Australia Development Lab, IBM