From 273b657b4e970f510afb258aa73dc2e264a701e3 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Sun, 1 Oct 2017 20:28:53 -0400 Subject: cmd/link: support -X values for main.* in plugins Fixes #19418 Change-Id: I98205f40c1915cd68a5d20438469ba06f1efb160 Reviewed-on: https://go-review.googlesource.com/67432 Run-TryBot: David Crawshaw TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/cmd/link/internal/ld/data.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index c4ffa20a57..36b97a3dea 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -1045,7 +1045,11 @@ func addstrdata1(ctxt *Link, arg string) { if eq < 0 || dot < 0 { Exitf("-X flag requires argument of the form importpath.name=value") } - addstrdata(ctxt, objabi.PathToPrefix(arg[:dot])+arg[dot:eq], arg[eq+1:]) + pkg := objabi.PathToPrefix(arg[:dot]) + if Buildmode == BuildmodePlugin && pkg == "main" { + pkg = *flagPluginPath + } + addstrdata(ctxt, pkg+arg[dot:eq], arg[eq+1:]) } func addstrdata(ctxt *Link, name string, value string) { -- cgit v1.3-5-g9baa