]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: only embed runtime.goarm in the module that contains the runtime package
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Wed, 2 Sep 2015 21:05:25 +0000 (09:05 +1200)
committerDavid Crawshaw <crawshaw@golang.org>
Thu, 3 Sep 2015 16:22:21 +0000 (16:22 +0000)
Change-Id: Ia18984343ca4ced3671d967ff9a5b0e32874430c
Reviewed-on: https://go-review.googlesource.com/14220
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/arm/obj.go
src/cmd/link/internal/ld/lib.go

index 14fe7a64eb286edf698d0219c9c2b6c2419c2676..c4678209cee478727052600dea398484de209591 100644 (file)
@@ -169,10 +169,4 @@ func archinit() {
        if ld.INITDAT != 0 && ld.INITRND != 0 {
                fmt.Printf("warning: -D0x%x is ignored because of -R0x%x\n", uint64(ld.INITDAT), uint32(ld.INITRND))
        }
-
-       // embed goarm to runtime.goarm
-       s := ld.Linklookup(ld.Ctxt, "runtime.goarm", 0)
-
-       s.Type = obj.SRODATA
-       ld.Adduint8(ld.Ctxt, s, uint8(ld.Ctxt.Goarm))
 }
index 66f0a514a4e18e76bf711d4fa643730e244c7814..ae56a653dd3c81c78a3d357da8fba109c8c74e34 100644 (file)
@@ -558,19 +558,30 @@ func loadlib() {
        Ctxt.Tlsg = tlsg
 
        moduledata := Linklookup(Ctxt, "runtime.firstmoduledata", 0)
-       if moduledata.Type == 0 || moduledata.Type == obj.SDYNIMPORT {
-               // If the module we are linking does not define the
-               // runtime.firstmoduledata symbol, create a local symbol for
-               // the moduledata.
+       if moduledata.Type != 0 && moduledata.Type != obj.SDYNIMPORT {
+               // If the module (toolchain-speak for "executable or shared
+               // library") we are linking contains the runtime package, it
+               // will define the runtime.firstmoduledata symbol and we
+               // truncate it back to 0 bytes so we can define its entire
+               // contents in symtab.go:symtab().
+               moduledata.Size = 0
+
+               // In addition, on ARM, the runtime depends on the linker
+               // recording the value of GOARM.
+               if Thearch.Thechar == '5' {
+                       s := Linklookup(Ctxt, "runtime.goarm", 0)
+
+                       s.Type = obj.SRODATA
+                       Adduint8(Ctxt, s, uint8(Ctxt.Goarm))
+               }
+       } else {
+               // If OTOH the module does not contain the runtime package,
+               // create a local symbol for the moduledata.
                moduledata = Linklookup(Ctxt, "local.moduledata", 0)
                moduledata.Local = true
-       } else {
-               // If OTOH the module does define the symbol, we truncate the
-               // symbol back to 0 bytes so we can define its entire
-               // contents.
-               moduledata.Size = 0
        }
-       // Either way we mark it as noptrdata to hide it from the GC.
+       // In all cases way we mark the moduledata as noptrdata to hide it from
+       // the GC.
        moduledata.Type = obj.SNOPTRDATA
        moduledata.Reachable = true
        Ctxt.Moduledata = moduledata