]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: fix the size of typerel.* with c-archive buildmode
authorClément Chigot <chigot.c@gmail.com>
Tue, 5 Nov 2019 15:31:05 +0000 (16:31 +0100)
committerIan Lance Taylor <iant@golang.org>
Wed, 6 Nov 2019 13:55:04 +0000 (13:55 +0000)
With buildmode=c-archive, "runtime.types" type isn't STYPE but
STYPERELRO.
On AIX, this symbol is present in the symbol table and not under
typerel.* outersymbol. Therefore, the size of typerel.* must be adapted.

Fixes #35342

Change-Id: Ib982c6557d9b41bc3d8775e4825650897f9e0ee6
Reviewed-on: https://go-review.googlesource.com/c/go/+/205338
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/xcoff.go

index fe35578225a79e84c6574722a4e2113e4f6a2198..8814bad4ae8dfc7eb56b860fb54e9f9b6b5c4c92 100644 (file)
@@ -578,13 +578,14 @@ func xcoffUpdateOuterSize(ctxt *Link, size int64, stype sym.SymKind) {
                // Nothing to do
        case sym.STYPERELRO:
                if ctxt.UseRelro() && (ctxt.BuildMode == BuildModeCArchive || ctxt.BuildMode == BuildModeCShared || ctxt.BuildMode == BuildModePIE) {
-                       outerSymSize["typerel.*"] = size
+                       // runtime.types size must be removed, as it's a real symbol.
+                       outerSymSize["typerel.*"] = size - ctxt.Syms.ROLookup("runtime.types", 0).Size
                        return
                }
                fallthrough
        case sym.STYPE:
                if !ctxt.DynlinkingGo() {
-                       // runtime.types size must be removed.
+                       // runtime.types size must be removed, as it's a real symbol.
                        outerSymSize["type.*"] = size - ctxt.Syms.ROLookup("runtime.types", 0).Size
                }
        case sym.SGOSTRING: