diff options
| author | Than McIntosh <thanm@google.com> | 2023-02-09 11:37:13 -0500 |
|---|---|---|
| committer | Than McIntosh <thanm@google.com> | 2023-02-10 14:49:35 +0000 |
| commit | c3d3be10665f1037360600a79c0354f6580e6290 (patch) | |
| tree | 10c7aa5fd336fa64d7d34b0fbc5f5aa0e197e258 | |
| parent | 48f4728211c1c4299728b6b3a04a6ddf997d9ec6 (diff) | |
| download | go-c3d3be10665f1037360600a79c0354f6580e6290.tar.xz | |
cmd/link: try libssp_nonshared.a when looking for "__stack_chk_fail_local"
Update the code that tries to satisfy unresolved references to
"__stack_chk_fail_local" to look for "libssp_nonshared.a" in addition
to "libc_nonshared.a" (the former archive is the correct place on
Alpine).
Updates #52919.
Updates #54313.
Updates #57261.
Fixes #58385.
Change-Id: Id6cd3ebb4d5388df50a838e6efa5e5b683545b01
Reviewed-on: https://go-review.googlesource.com/c/go/+/466936
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
| -rw-r--r-- | src/cmd/link/internal/ld/lib.go | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 3772b8ba90..baca7cd65f 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -630,24 +630,30 @@ func (ctxt *Link) loadlib() { } if *flagLibGCC != "none" { hostArchive(ctxt, *flagLibGCC) - // For glibc systems, the linker setup used by GCC - // looks like - // - // GROUP ( /lib/x86_64-linux-gnu/libc.so.6 - // /usr/lib/x86_64-linux-gnu/libc_nonshared.a - // AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) ) - // - // where libc_nonshared.a contains a small set of - // symbols including "__stack_chk_fail_local" and a - // few others. Thus if we are doing internal linking - // and "__stack_chk_fail_local" is unresolved (most - // likely due to the use of -fstack-protector), try - // loading libc_nonshared.a to resolve it. - isunresolved := symbolsAreUnresolved(ctxt, []string{"__stack_chk_fail_local"}) - if isunresolved[0] { - if p := ctxt.findLibPath("libc_nonshared.a"); p != "none" { - hostArchive(ctxt, p) - } + } + // For glibc systems, the linker setup used by GCC + // looks like + // + // GROUP ( /lib/x86_64-linux-gnu/libc.so.6 + // /usr/lib/x86_64-linux-gnu/libc_nonshared.a + // AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) ) + // + // where libc_nonshared.a contains a small set of + // symbols including "__stack_chk_fail_local" and a + // few others. Thus if we are doing internal linking + // and "__stack_chk_fail_local" is unresolved (most + // likely due to the use of -fstack-protector), try + // loading libc_nonshared.a to resolve it. + // + // On Alpine Linux (musl-based), the library providing + // this symbol is called libssp_nonshared.a. + isunresolved := symbolsAreUnresolved(ctxt, []string{"__stack_chk_fail_local"}) + if isunresolved[0] { + if p := ctxt.findLibPath("libc_nonshared.a"); p != "none" { + hostArchive(ctxt, p) + } + if p := ctxt.findLibPath("libssp_nonshared.a"); p != "none" { + hostArchive(ctxt, p) } } } |
