]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: avoid pointers in go.string.* symbols
authorDavid Crawshaw <crawshaw@golang.org>
Fri, 25 Mar 2016 02:32:38 +0000 (22:32 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Fri, 25 Mar 2016 16:38:46 +0000 (16:38 +0000)
When creating binaries for dynamic linking, the linker moves
read-only data symbols that contain pointers into relro sections.
It is not setup for handling a go.string symbol moving to relro.

Instead of teaching it how (because go.string symbols with pointers
are unusual anyhow), put the data in a type.. section.

Fixes the android builder.

Change-Id: Ica4722d32241643c060923517b90276ff8ac6b07
Reviewed-on: https://go-review.googlesource.com/21110
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/reflect.go

index a91948fb8eaf9fd0147b8c74aa1e97f09b752bf0..d02bf66d3f739d4d1525f99b7e21f4973f4b94d2 100644 (file)
@@ -533,7 +533,11 @@ func dname(s *Sym, ot int, name, tag string, pkg *Pkg, exported bool) int {
        if pkg == nil {
                _, bsym = stringsym(string(b))
        } else {
-               bsymname := fmt.Sprintf(`go.string."".methodname.%d`, dnameCount)
+               // Write out data as "type.." to signal two things to the
+               // linker, first that when dynamically linking, the symbol
+               // should be moved to a relro section, and second that the
+               // contents should not be decoded as a type.
+               bsymname := fmt.Sprintf(`type..methodname."".%d`, dnameCount)
                dnameCount++
                bsym = obj.Linklookup(Ctxt, bsymname, 0)
                bsym.P = b