]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go, cmd/asm: pass -linkshared to assembler for shared linkage builds
authorThan McIntosh <thanm@google.com>
Thu, 10 Dec 2020 13:44:44 +0000 (08:44 -0500)
committerThan McIntosh <thanm@google.com>
Thu, 10 Dec 2020 16:38:15 +0000 (16:38 +0000)
When the -linkshared build mode is in effect, the Go command passes
the "-linkshared" command line option to the compiler so as to insure
special handling for things like builtin functions (which may appear
in a shared library and not the main executable). This patch extends
this behavior to the assembler, since the assembler may also wind up
referencing builtins when emitting a stack-split prolog.

Fixes #43107.

Change-Id: I56eaded79789b083f3c3d800fb140353dee33ba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/276932
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/asm/internal/flags/flags.go
src/cmd/asm/main.go
src/cmd/go/internal/work/init.go

index 426e0156aa5bd43d9bbf6dac97fdee5095c5a65a..1335860315a839ffc2d48580eda32d87790876ed 100644 (file)
@@ -20,6 +20,7 @@ var (
        TrimPath         = flag.String("trimpath", "", "remove prefix from recorded source file paths")
        Shared           = flag.Bool("shared", false, "generate code that can be linked into a shared library")
        Dynlink          = flag.Bool("dynlink", false, "support references to Go symbols defined in other shared libraries")
+       Linkshared       = flag.Bool("linkshared", false, "generate code that will be linked against Go shared libraries")
        AllErrors        = flag.Bool("e", false, "no limit on number of errors reported")
        SymABIs          = flag.Bool("gensymabis", false, "write symbol ABI information to output file, don't assemble")
        Importpath       = flag.String("p", "", "set expected package import to path")
index 149925d23f184f7f0832ba89b831977c46cd0a88..31636e30458974920aa6d5a4ced11513a48cecdc 100644 (file)
@@ -37,6 +37,7 @@ func main() {
        ctxt := obj.Linknew(architecture.LinkArch)
        ctxt.Debugasm = flags.PrintOut
        ctxt.Flag_dynlink = *flags.Dynlink
+       ctxt.Flag_linkshared = *flags.Linkshared
        ctxt.Flag_shared = *flags.Shared || *flags.Dynlink
        ctxt.IsAsm = true
        ctxt.Pkgpath = *flags.Importpath
index 102def48383d07042b52e7bd9e7ae426d32bc519..ba7c7c2fbb18d95b456e6e0973006ec3d48ab411 100644 (file)
@@ -241,7 +241,8 @@ func buildModeInit() {
                if gccgo {
                        codegenArg = "-fPIC"
                } else {
-                       forcedAsmflags = append(forcedAsmflags, "-D=GOBUILDMODE_shared=1")
+                       forcedAsmflags = append(forcedAsmflags, "-D=GOBUILDMODE_shared=1",
+                               "-linkshared")
                        codegenArg = "-dynlink"
                        forcedGcflags = append(forcedGcflags, "-linkshared")
                        // TODO(mwhudson): remove -w when that gets fixed in linker.