]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/ld: set moduledatasize correctly when -linkshared
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Tue, 7 Apr 2015 02:51:29 +0000 (14:51 +1200)
committerIan Lance Taylor <iant@golang.org>
Mon, 20 Apr 2015 23:21:38 +0000 (23:21 +0000)
Change-Id: I1ea4175466c9113c1f41b012ba8266ee2b06e3a3
Reviewed-on: https://go-review.googlesource.com/8522
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/internal/ld/symtab.go

index 055184a19ba2eff26fcafb247c8a00019c418d81..4d57d87c49ac38b3789d188b2c5731de8a4a0fd4 100644 (file)
@@ -425,7 +425,6 @@ func symtab() {
        // This code uses several global variables that are set by pcln.go:pclntab.
        moduledata := Linklookup(Ctxt, "runtime.firstmoduledata", 0)
        moduledata.Type = obj.SNOPTRDATA
-       moduledatasize := moduledata.Size
        moduledata.Size = 0 // truncate symbol back to 0 bytes to reinitialize
        moduledata.Reachable = true
        moduledata.Local = true
@@ -465,8 +464,12 @@ func symtab() {
        adduint(Ctxt, moduledata, uint64(ntypelinks))
        adduint(Ctxt, moduledata, uint64(ntypelinks))
        // The rest of moduledata is zero initialized.
-       moduledata.Size = moduledatasize
-       Symgrow(Ctxt, moduledata, moduledatasize)
+       // When linking an object that does not contain the runtime we are
+       // creating the moduledata from scratch and it does not have a
+       // compiler-provided size, so read it from the type data.
+       moduledatatype := Linkrlookup(Ctxt, "type.runtime.moduledata", 0)
+       moduledata.Size = decodetype_size(moduledatatype)
+       Symgrow(Ctxt, moduledata, moduledata.Size)
 
        lastmoduledatap := Linklookup(Ctxt, "runtime.lastmoduledatap", 0)
        if lastmoduledatap.Type != obj.SDYNIMPORT {