diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index b658cc4f5c7..fe74cc9208a 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -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 diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 2a3f4298f5d..5616700445d 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -186,7 +186,7 @@ func UseRelro() bool { case BuildmodeCShared, BuildmodeShared, BuildmodePIE: return Iself default: - return false + return Linkshared } } diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index 3f8784f9964..3258bc1ff9d 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -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