]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: set HeadType early
authorCherry Zhang <cherryyz@google.com>
Fri, 24 Apr 2020 16:13:11 +0000 (12:13 -0400)
committerCherry Zhang <cherryyz@google.com>
Fri, 24 Apr 2020 16:58:37 +0000 (16:58 +0000)
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>
src/cmd/link/internal/ld/main.go

index 8b6b9b84a6be1d16ffbb8d3c9d639539207d6e3a..d8b4c8a94ded86d97fe820c484e474d9bf29920c 100644 (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")
        }