cmd/go, misc/cgo: skip test if no .edata

Clang does not produce binaries with an .edata section, even when it
exports symbols properly, so just skip this binutils-specific test for
that case. Later we can rewrite these tests entirely to do something
more robust.

Updates #46719.

Change-Id: I864b3c2d91e66800c55454ae11d4ab1623693d14
Reviewed-on: https://go-review.googlesource.com/c/go/+/327549
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Jason A. Donenfeld 2021-06-12 12:34:40 +02:00
parent 67b1b6a2e3
commit 24cff0f044
2 changed files with 2 additions and 10 deletions

View file

@ -400,7 +400,7 @@ func main() {
defer f.Close()
section := f.Section(".edata")
if section == nil {
t.Fatalf(".edata section is not present")
t.Skip(".edata section is not present")
}
// TODO: deduplicate this struct from cmd/link/internal/ld/pe.go

View file

@ -72,7 +72,6 @@ func tooSlow(t *testing.T) {
// (temp) directory.
var testGOROOT string
var testCC string
var testGOCACHE string
var testGo string
@ -179,13 +178,6 @@ func TestMain(m *testing.M) {
os.Exit(2)
}
out, err = exec.Command(gotool, "env", "CC").CombinedOutput()
if err != nil {
fmt.Fprintf(os.Stderr, "could not find testing CC: %v\n%s", err, out)
os.Exit(2)
}
testCC = strings.TrimSpace(string(out))
cmd := exec.Command(testGo, "env", "CGO_ENABLED")
cmd.Stderr = new(strings.Builder)
if out, err := cmd.Output(); err != nil {
@ -2185,7 +2177,7 @@ func testBuildmodePIE(t *testing.T, useCgo, setBuildmodeToPIE bool) {
// See https://sourceware.org/bugzilla/show_bug.cgi?id=19011
section := f.Section(".edata")
if section == nil {
t.Fatalf(".edata section is not present")
t.Skip(".edata section is not present")
}
// TODO: deduplicate this struct from cmd/link/internal/ld/pe.go
type IMAGE_EXPORT_DIRECTORY struct {