1
0
mirror of https://github.com/golang/go synced 2024-11-19 13:04:45 -07:00

cmd/link: fix TestRuntimeTypeAttr on ppc64,solaris

For ppc64, skip -linkmode=external per
https://go-review.googlesource.com/c/go/+/106775#message-f95b9bd716e3d9ebb3f47a50492cde9f2972e859

For Solaris, apparently type.* isn't the same as runtime.types. I don't
know why, but runtime.types is what goes into moduledata, and so it's
definitely the more correct thing to use.

Fixes: #24983

Change-Id: I6b465ac7b8f91ce55a63acbd7fe76e4a2dbb6f22
Reviewed-on: https://go-review.googlesource.com/108955
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Heschi Kreinick 2018-04-23 17:07:12 -04:00
parent 3d6647d6f8
commit 5d4267e480

View File

@ -17,6 +17,7 @@ import (
"reflect"
"runtime"
"strconv"
"strings"
"testing"
)
@ -813,10 +814,6 @@ func TestAbstractOriginSanityWithLocationLists(t *testing.T) {
func TestRuntimeTypeAttr(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "solaris" || runtime.GOARCH == "ppc64" {
t.Skip("TODO(heschi): fix or make skip permanent (golang.org/issue/24983)")
}
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
@ -824,6 +821,10 @@ func TestRuntimeTypeAttr(t *testing.T) {
// Explicitly test external linking, for dsymutil compatility on Darwin.
for _, flags := range []string{"-ldflags=linkmode=internal", "-ldflags=-linkmode=external"} {
t.Run("flags="+flags, func(t *testing.T) {
if runtime.GOARCH == "ppc64" && strings.Contains(flags, "external") {
t.Skip("-linkmode=external not supported on ppc64")
}
testRuntimeTypeAttr(t, flags)
})
}
@ -863,15 +864,15 @@ func main() {
if err != nil {
t.Fatalf("error reading symbols: %v", err)
}
var typeStar *objfilepkg.Sym
var types *objfilepkg.Sym
for _, sym := range symbols {
if sym.Name == "type.*" {
typeStar = &sym
if sym.Name == "runtime.types" {
types = &sym
break
}
}
if typeStar == nil {
t.Fatal("couldn't find types.* in symbols")
if types == nil {
t.Fatal("couldn't find runtime.types in symbols")
}
d, err := f.DWARF()
@ -893,7 +894,7 @@ func main() {
t.Fatalf("*main.X DIE had no runtime type attr. DIE: %v", dies[0])
}
if rtAttr.(uint64)+typeStar.Addr != addr {
t.Errorf("DWARF type offset was %#x+%#x, but test program said %#x", rtAttr.(uint64), typeStar.Addr, addr)
if rtAttr.(uint64)+types.Addr != addr {
t.Errorf("DWARF type offset was %#x+%#x, but test program said %#x", rtAttr.(uint64), types.Addr, addr)
}
}