mirror of
https://github.com/golang/go
synced 2024-11-11 19:51:37 -07:00
cmd/go, cmd/asm: pass -linkshared to assembler for shared linkage builds
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>
This commit is contained in:
parent
b110733327
commit
56b783ad94
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user