cmd/link: add DT_NEEDED for all 64-bit ELF dynimplib

Also change the relevant test to be tested on the linux-arm64 platform
as well.

Fixes #49789

Change-Id: Id2eac7a45279f037957442862f8ed63838b8e929
Reviewed-on: https://go-review.googlesource.com/c/go/+/366855
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Byoungchan Lee 2021-11-25 20:40:21 +09:00 committed by Than McIntosh
parent 86c8075675
commit a8f019e956
4 changed files with 4 additions and 2 deletions

View File

@ -570,6 +570,7 @@ Hootsuite Inc.
Hsin-Ho Yeh <yhh92u@gmail.com>
Hu Keping <hukeping@huawei.com>
Hugues Bruant <hugues.bruant@gmail.com>
HyperConnect Inc.
Ian Gudger <ian@loosescre.ws>
Ian Kent <iankent85@gmail.com>
IBM

View File

@ -451,6 +451,7 @@ Bryan Ford <brynosaurus@gmail.com>
Bryan Heden <b.heden@gmail.com>
Bulat Gaifullin <gaifullinbf@gmail.com>
Burak Guven <bguven@gmail.com>
Byoungchan Lee <daniel.l@hpcnt.com>
Caine Tighe <arctanofyourface@gmail.com>
Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Caleb Martinez <accounts@calebmartinez.com>

View File

@ -2258,7 +2258,7 @@ func elfadddynsym(ldr *loader.Loader, target *Target, syms *ArchSyms, s loader.S
dil := ldr.SymDynimplib(s)
if target.Arch.Family == sys.AMD64 && !cgoeDynamic && dil != "" && !seenlib[dil] {
if !cgoeDynamic && dil != "" && !seenlib[dil] {
du := ldr.MakeSymbolUpdater(syms.Dynamic)
Elfwritedynent(target.Arch, du, elf.DT_NEEDED, uint64(dstru.Addstring(dil)))
seenlib[dil] = true

View File

@ -86,7 +86,7 @@ func TestNoDuplicateNeededEntries(t *testing.T) {
// across the board given the nature of the test).
pair := runtime.GOOS + "-" + runtime.GOARCH
switch pair {
case "linux-amd64", "freebsd-amd64", "openbsd-amd64":
case "linux-amd64", "linux-arm64", "freebsd-amd64", "openbsd-amd64":
default:
t.Skip("no need for test on " + pair)
}