aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Hudson-Doyle <michael.hudson@canonical.com>2015-09-03 09:05:25 +1200
committerIan Lance Taylor <iant@golang.org>2015-09-04 02:20:47 +0000
commit06da8fd84afc4694d4dbab9316ae701bd4dfaa8d (patch)
tree62584b246218cac4db860f386345d5e97aeea661 /src
parentdac87e9ed3544c803f7573227240b7f23b315019 (diff)
downloadgo-06da8fd84afc4694d4dbab9316ae701bd4dfaa8d.tar.xz
cmd/link: only embed runtime.goarm in the module that contains the runtime package
And do it properly so freebsd and nacl still work. Change-Id: I6f9f30e93ceae6dee59215ed608c6a158bdbdbb0 Reviewed-on: https://go-review.googlesource.com/14280 Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/link/internal/arm/obj.go6
-rw-r--r--src/cmd/link/internal/ld/lib.go32
2 files changed, 22 insertions, 16 deletions
diff --git a/src/cmd/link/internal/arm/obj.go b/src/cmd/link/internal/arm/obj.go
index 14fe7a64eb..c4678209ce 100644
--- a/src/cmd/link/internal/arm/obj.go
+++ b/src/cmd/link/internal/arm/obj.go
@@ -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))
}
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 66f0a514a4..89f805d483 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -558,19 +558,31 @@ 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
+ s.Size = 0
+ 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