1
0
mirror of https://github.com/golang/go synced 2024-11-23 22:20:02 -07:00

[dev.link] cmd/link: set HeadType early

So we can use it to set per-OS flags.

Also set flagnewDoData after archinit, where IsELF is set.

This should correct the logic of setting flagnewDoData.

Change-Id: I18c7252f141aa35119005c252becc9d7cb74f2f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/229867
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-04-24 12:13:11 -04:00
parent f790533d9f
commit f2d8da1a35

View File

@ -155,13 +155,8 @@ func Main(arch *sys.Arch, theArch Arch) {
usage()
}
}
if *flagnewDoData {
// New dodata() is currently only implemented for selected targets.
if !(ctxt.IsElf() &&
(ctxt.IsAMD64() || ctxt.Is386())) {
*flagnewDoData = false
}
if ctxt.HeadType == objabi.Hunknown {
ctxt.HeadType.Set(objabi.GOOS)
}
checkStrictDups = *FlagStrictDups
@ -199,16 +194,19 @@ func Main(arch *sys.Arch, theArch Arch) {
bench.Start("libinit")
libinit(ctxt) // creates outfile
if ctxt.HeadType == objabi.Hunknown {
ctxt.HeadType.Set(objabi.GOOS)
}
bench.Start("computeTLSOffset")
ctxt.computeTLSOffset()
bench.Start("Archinit")
thearch.Archinit(ctxt)
if *flagnewDoData {
// New dodata() is currently only implemented for selected targets.
if !(ctxt.IsElf() &&
(ctxt.IsAMD64() || ctxt.Is386())) {
*flagnewDoData = false
}
}
if ctxt.linkShared && !ctxt.IsELF {
Exitf("-linkshared can only be used on elf systems")
}