]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: keep types together when dynamic linking
authorDavid Crawshaw <crawshaw@golang.org>
Fri, 1 Apr 2016 14:55:21 +0000 (10:55 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Mon, 4 Apr 2016 15:30:40 +0000 (15:30 +0000)
To refer to types and names by offsets, we want to keep the symbols in
the same sections. Do this by making all types .relro for now.

Once name offsets are further along, name data can move out of relro.

Change-Id: I1cbd2e914bd180cdf25c4aeb13d9c1c734febe69
Reviewed-on: https://go-review.googlesource.com/21394
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/symtab.go

index b658cc4f5c716a5ebae0484186702844067c7665..fe74cc9208ae456e4028814685592bb2710f9e17 100644 (file)
@@ -1271,7 +1271,7 @@ func dodata() {
                // when building a shared library. We do this by boosting objects of
                // type SXXX with relocations to type SXXXRELRO.
                for s := datap; s != nil; s = s.Next {
-                       if (s.Type >= obj.STYPE && s.Type <= obj.SFUNCTAB && len(s.R) > 0) || s.Type == obj.SGOSTRINGHDR {
+                       if (s.Type >= obj.STYPE && s.Type <= obj.SFUNCTAB && len(s.R) > 0) || s.Type == obj.STYPE || s.Type == obj.SGOSTRINGHDR {
                                s.Type += (obj.STYPERELRO - obj.STYPE)
                                if s.Outer != nil {
                                        s.Outer.Type = s.Type
index 2a3f4298f5dd14abd117983a149586bb23030057..5616700445d8c883c78a26d09e1941204ff503ab 100644 (file)
@@ -186,7 +186,7 @@ func UseRelro() bool {
        case BuildmodeCShared, BuildmodeShared, BuildmodePIE:
                return Iself
        default:
-               return false
+               return Linkshared
        }
 }
 
index 3f8784f996474b8e1cf78e89fe001dea571e558e..3258bc1ff9d625ee46ca97712f1adc083234c0da 100644 (file)
@@ -451,8 +451,10 @@ func symtab() {
                        continue
                }
 
-               if strings.HasPrefix(s.Name, "type.") && !DynlinkingGo() {
-                       s.Attr |= AttrHidden
+               if strings.HasPrefix(s.Name, "type.") {
+                       if !DynlinkingGo() {
+                               s.Attr |= AttrHidden
+                       }
                        if UseRelro() && len(s.R) > 0 {
                                s.Type = obj.STYPERELRO
                                s.Outer = symtyperel