From 93b753f525b62a2a860fc2ba2d4ea3f788c275f9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 22 Aug 2016 21:49:32 -0700 Subject: [PATCH] cmd/link: fix handling of cgo_dynamic_interpreter CL 27473 accidentally changed `!Debug['I']` to `*flagInterpreter != ""`. Since the old `Debug['I']` was set when the new *flagInterpreter was set, this inverted the sense of the condition. The effect was to always ignore the cgo_dynamic_interpreter setting from runtime/cgo. This worked OK when the default interpreter was the correct one, but failed when it was not, as is currently the case on, at least, PPC64 and ARM. This CL restores the old behavior by using a separate variable to track whether the -I flag was used, just as we used to. Change-Id: Icf9b65fa41349ed2e4de477fec0a557ef1eb8189 Reviewed-on: https://go-review.googlesource.com/27562 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/cmd/link/internal/ld/go.go | 4 ++-- src/cmd/link/internal/ld/main.go | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/cmd/link/internal/ld/go.go b/src/cmd/link/internal/ld/go.go index 4f7db2696c..b89843779b 100644 --- a/src/cmd/link/internal/ld/go.go +++ b/src/cmd/link/internal/ld/go.go @@ -267,8 +267,8 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) { goto err } - if *flagInterpreter != "" { - if *flagInterpreter != f[1] { + if !flagInterpreterSet { + if *flagInterpreter != "" && *flagInterpreter != f[1] { fmt.Fprintf(os.Stderr, "%s: conflict dynlinker: %s and %s\n", os.Args[0], *flagInterpreter, f[1]) nerrors++ return diff --git a/src/cmd/link/internal/ld/main.go b/src/cmd/link/internal/ld/main.go index 6a70b3eec9..280648a06f 100644 --- a/src/cmd/link/internal/ld/main.go +++ b/src/cmd/link/internal/ld/main.go @@ -73,18 +73,20 @@ var ( flagExtldflags = flag.String("extldflags", "", "pass `flags` to external linker") flagExtar = flag.String("extar", "", "archive program for buildmode=c-archive") - flagA = flag.Bool("a", false, "disassemble output") - FlagC = flag.Bool("c", false, "dump call graph") - FlagD = flag.Bool("d", false, "disable dynamic executable") - flagF = flag.Bool("f", false, "ignore version mismatch") - flagG = flag.Bool("g", false, "disable go package data checks") - flagH = flag.Bool("h", false, "halt on error") - flagN = flag.Bool("n", false, "dump symbol table") - FlagS = flag.Bool("s", false, "disable symbol table") - flagU = flag.Bool("u", false, "reject unsafe packages") - FlagW = flag.Bool("w", false, "disable DWARF generation") - Flag8 bool // use 64-bit addresses in symbol table - flagInterpreter = flag.String("I", "", "use `linker` as ELF dynamic linker") + flagA = flag.Bool("a", false, "disassemble output") + FlagC = flag.Bool("c", false, "dump call graph") + FlagD = flag.Bool("d", false, "disable dynamic executable") + flagF = flag.Bool("f", false, "ignore version mismatch") + flagG = flag.Bool("g", false, "disable go package data checks") + flagH = flag.Bool("h", false, "halt on error") + flagN = flag.Bool("n", false, "dump symbol table") + FlagS = flag.Bool("s", false, "disable symbol table") + flagU = flag.Bool("u", false, "reject unsafe packages") + FlagW = flag.Bool("w", false, "disable DWARF generation") + Flag8 bool // use 64-bit addresses in symbol table + + flagInterpreter = flag.String("I", "", "use `linker` as ELF dynamic linker") + flagInterpreterSet bool FlagRound = flag.Int("R", -1, "set address rounding `quantum`") FlagTextAddr = flag.Int64("T", -1, "set text segment `address`") @@ -131,6 +133,7 @@ func Main() { } obj.Flagparse(usage) + flagInterpreterSet = *flagInterpreter != "" startProfile() ctxt.Bso = ctxt.Bso -- 2.48.1