Commit d9504d46 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/link: don't record interpreter in flagInterpreter

Keep flagInterpreter unchanged after flag parsing. This lets us replace
flagInterpreterSet with flagInterpreter != "".

Change-Id: Ifd2edbb2ce0011e97276ca18281b8ffbabde1c50
Reviewed-on: https://go-review.googlesource.com/27563
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent e3cecfdc
......@@ -2205,29 +2205,29 @@ func Asmbelf(ctxt *Link, symo int64) {
sh.type_ = SHT_PROGBITS
sh.flags = SHF_ALLOC
sh.addralign = 1
if *flagInterpreter == "" {
if interpreter == "" {
switch HEADTYPE {
case obj.Hlinux:
*flagInterpreter = Thearch.Linuxdynld
interpreter = Thearch.Linuxdynld
case obj.Hfreebsd:
*flagInterpreter = Thearch.Freebsddynld
interpreter = Thearch.Freebsddynld
case obj.Hnetbsd:
*flagInterpreter = Thearch.Netbsddynld
interpreter = Thearch.Netbsddynld
case obj.Hopenbsd:
*flagInterpreter = Thearch.Openbsddynld
interpreter = Thearch.Openbsddynld
case obj.Hdragonfly:
*flagInterpreter = Thearch.Dragonflydynld
interpreter = Thearch.Dragonflydynld
case obj.Hsolaris:
*flagInterpreter = Thearch.Solarisdynld
interpreter = Thearch.Solarisdynld
}
}
resoff -= int64(elfinterp(sh, uint64(startva), uint64(resoff), *flagInterpreter))
resoff -= int64(elfinterp(sh, uint64(startva), uint64(resoff), interpreter))
ph := newElfPhdr(ctxt)
ph.type_ = PT_INTERP
......
......@@ -267,14 +267,14 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
goto err
}
if !flagInterpreterSet {
if *flagInterpreter != "" && *flagInterpreter != f[1] {
fmt.Fprintf(os.Stderr, "%s: conflict dynlinker: %s and %s\n", os.Args[0], *flagInterpreter, f[1])
if *flagInterpreter == "" {
if interpreter != "" && interpreter != f[1] {
fmt.Fprintf(os.Stderr, "%s: conflict dynlinker: %s and %s\n", os.Args[0], interpreter, f[1])
nerrors++
return
}
*flagInterpreter = f[1]
interpreter = f[1]
}
continue
......
......@@ -179,6 +179,7 @@ var (
Funcalign int
iscgo bool
elfglobalsymndx int
interpreter string
debug_s bool // backup old value of debug['s']
HEADR int32
......
......@@ -73,20 +73,18 @@ 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")
flagInterpreterSet bool
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")
FlagRound = flag.Int("R", -1, "set address rounding `quantum`")
FlagTextAddr = flag.Int64("T", -1, "set text segment `address`")
......@@ -133,7 +131,6 @@ func Main() {
}
obj.Flagparse(usage)
flagInterpreterSet = *flagInterpreter != ""
startProfile()
ctxt.Bso = ctxt.Bso
......@@ -159,6 +156,8 @@ func Main() {
}
}
interpreter = *flagInterpreter
libinit(ctxt) // creates outfile
if HEADTYPE == -1 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment