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) { ...@@ -2205,29 +2205,29 @@ func Asmbelf(ctxt *Link, symo int64) {
sh.type_ = SHT_PROGBITS sh.type_ = SHT_PROGBITS
sh.flags = SHF_ALLOC sh.flags = SHF_ALLOC
sh.addralign = 1 sh.addralign = 1
if *flagInterpreter == "" { if interpreter == "" {
switch HEADTYPE { switch HEADTYPE {
case obj.Hlinux: case obj.Hlinux:
*flagInterpreter = Thearch.Linuxdynld interpreter = Thearch.Linuxdynld
case obj.Hfreebsd: case obj.Hfreebsd:
*flagInterpreter = Thearch.Freebsddynld interpreter = Thearch.Freebsddynld
case obj.Hnetbsd: case obj.Hnetbsd:
*flagInterpreter = Thearch.Netbsddynld interpreter = Thearch.Netbsddynld
case obj.Hopenbsd: case obj.Hopenbsd:
*flagInterpreter = Thearch.Openbsddynld interpreter = Thearch.Openbsddynld
case obj.Hdragonfly: case obj.Hdragonfly:
*flagInterpreter = Thearch.Dragonflydynld interpreter = Thearch.Dragonflydynld
case obj.Hsolaris: 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 := newElfPhdr(ctxt)
ph.type_ = PT_INTERP ph.type_ = PT_INTERP
......
...@@ -267,14 +267,14 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) { ...@@ -267,14 +267,14 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
goto err goto err
} }
if !flagInterpreterSet { if *flagInterpreter == "" {
if *flagInterpreter != "" && *flagInterpreter != f[1] { if interpreter != "" && interpreter != f[1] {
fmt.Fprintf(os.Stderr, "%s: conflict dynlinker: %s and %s\n", os.Args[0], *flagInterpreter, f[1]) fmt.Fprintf(os.Stderr, "%s: conflict dynlinker: %s and %s\n", os.Args[0], interpreter, f[1])
nerrors++ nerrors++
return return
} }
*flagInterpreter = f[1] interpreter = f[1]
} }
continue continue
......
...@@ -179,6 +179,7 @@ var ( ...@@ -179,6 +179,7 @@ var (
Funcalign int Funcalign int
iscgo bool iscgo bool
elfglobalsymndx int elfglobalsymndx int
interpreter string
debug_s bool // backup old value of debug['s'] debug_s bool // backup old value of debug['s']
HEADR int32 HEADR int32
......
...@@ -84,9 +84,7 @@ var ( ...@@ -84,9 +84,7 @@ var (
flagU = flag.Bool("u", false, "reject unsafe packages") flagU = flag.Bool("u", false, "reject unsafe packages")
FlagW = flag.Bool("w", false, "disable DWARF generation") FlagW = flag.Bool("w", false, "disable DWARF generation")
Flag8 bool // use 64-bit addresses in symbol table Flag8 bool // use 64-bit addresses in symbol table
flagInterpreter = flag.String("I", "", "use `linker` as ELF dynamic linker") flagInterpreter = flag.String("I", "", "use `linker` as ELF dynamic linker")
flagInterpreterSet bool
FlagRound = flag.Int("R", -1, "set address rounding `quantum`") FlagRound = flag.Int("R", -1, "set address rounding `quantum`")
FlagTextAddr = flag.Int64("T", -1, "set text segment `address`") FlagTextAddr = flag.Int64("T", -1, "set text segment `address`")
...@@ -133,7 +131,6 @@ func Main() { ...@@ -133,7 +131,6 @@ func Main() {
} }
obj.Flagparse(usage) obj.Flagparse(usage)
flagInterpreterSet = *flagInterpreter != ""
startProfile() startProfile()
ctxt.Bso = ctxt.Bso ctxt.Bso = ctxt.Bso
...@@ -159,6 +156,8 @@ func Main() { ...@@ -159,6 +156,8 @@ func Main() {
} }
} }
interpreter = *flagInterpreter
libinit(ctxt) // creates outfile libinit(ctxt) // creates outfile
if HEADTYPE == -1 { 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