summaryrefslogtreecommitdiffstats
path: root/src/cmd/link/testdata
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/link/testdata')
-rw-r--r--src/cmd/link/testdata/testBuildFortvOS/lib.go8
-rw-r--r--src/cmd/link/testdata/testBuildFortvOS/main.m5
-rw-r--r--src/cmd/link/testdata/testHashedSyms/p.go33
-rw-r--r--src/cmd/link/testdata/testIndexMismatch/a.go8
-rw-r--r--src/cmd/link/testdata/testIndexMismatch/b.go8
-rw-r--r--src/cmd/link/testdata/testIndexMismatch/main.go9
-rw-r--r--src/cmd/link/testdata/testPErsrc-complex/main.go43
-rw-r--r--src/cmd/link/testdata/testPErsrc-complex/rsrc.sysobin0 -> 352 bytes
-rw-r--r--src/cmd/link/testdata/testPErsrc/main.go19
-rw-r--r--src/cmd/link/testdata/testPErsrc/rsrc.sysobin0 -> 228 bytes
-rw-r--r--src/cmd/link/testdata/testRO/x.go22
11 files changed, 155 insertions, 0 deletions
diff --git a/src/cmd/link/testdata/testBuildFortvOS/lib.go b/src/cmd/link/testdata/testBuildFortvOS/lib.go
new file mode 100644
index 0000000..bc6c699
--- /dev/null
+++ b/src/cmd/link/testdata/testBuildFortvOS/lib.go
@@ -0,0 +1,8 @@
+package main
+
+import "C"
+
+//export GoFunc
+func GoFunc() {}
+
+func main() {}
diff --git a/src/cmd/link/testdata/testBuildFortvOS/main.m b/src/cmd/link/testdata/testBuildFortvOS/main.m
new file mode 100644
index 0000000..1c8175f
--- /dev/null
+++ b/src/cmd/link/testdata/testBuildFortvOS/main.m
@@ -0,0 +1,5 @@
+extern void GoFunc();
+
+int main(int argc, char **argv) {
+ GoFunc();
+}
diff --git a/src/cmd/link/testdata/testHashedSyms/p.go b/src/cmd/link/testdata/testHashedSyms/p.go
new file mode 100644
index 0000000..87dddcf
--- /dev/null
+++ b/src/cmd/link/testdata/testHashedSyms/p.go
@@ -0,0 +1,33 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This test case contains two static temps (the array literals)
+// with same contents but different sizes. The linker should not
+// report a hash collision. The linker can (and actually does)
+// dedup the two symbols, by keeping the larger symbol. The dedup
+// is not a requirement for correctness and not checked in this test.
+// We do check the emitted symbol contents are correct, though.
+
+package main
+
+func main() {
+ F([10]int{1, 2, 3, 4, 5, 6}, [20]int{1, 2, 3, 4, 5, 6})
+}
+
+//go:noinline
+func F(x, y interface{}) {
+ x1 := x.([10]int)
+ y1 := y.([20]int)
+ for i := range y1 {
+ if i < 6 {
+ if x1[i] != i+1 || y1[i] != i+1 {
+ panic("FAIL")
+ }
+ } else {
+ if (i < len(x1) && x1[i] != 0) || y1[i] != 0 {
+ panic("FAIL")
+ }
+ }
+ }
+}
diff --git a/src/cmd/link/testdata/testIndexMismatch/a.go b/src/cmd/link/testdata/testIndexMismatch/a.go
new file mode 100644
index 0000000..1f3b2c5
--- /dev/null
+++ b/src/cmd/link/testdata/testIndexMismatch/a.go
@@ -0,0 +1,8 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+//go:noinline
+func A() { println("A") }
diff --git a/src/cmd/link/testdata/testIndexMismatch/b.go b/src/cmd/link/testdata/testIndexMismatch/b.go
new file mode 100644
index 0000000..9b55dbf
--- /dev/null
+++ b/src/cmd/link/testdata/testIndexMismatch/b.go
@@ -0,0 +1,8 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+//go:noinline
+func B() { println("B") }
diff --git a/src/cmd/link/testdata/testIndexMismatch/main.go b/src/cmd/link/testdata/testIndexMismatch/main.go
new file mode 100644
index 0000000..bc15236
--- /dev/null
+++ b/src/cmd/link/testdata/testIndexMismatch/main.go
@@ -0,0 +1,9 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "a"
+
+func main() { a.A() }
diff --git a/src/cmd/link/testdata/testPErsrc-complex/main.go b/src/cmd/link/testdata/testPErsrc-complex/main.go
new file mode 100644
index 0000000..affd6ea
--- /dev/null
+++ b/src/cmd/link/testdata/testPErsrc-complex/main.go
@@ -0,0 +1,43 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that a PE rsrc section is handled correctly, when the object files
+// have been created by llvm-rc or msvc's rc.exe, which means there's the
+// @feat.00 symbol as well as split .rsrc$00 and .rsrc$01 section to deal with.
+//
+// rsrc.syso is created with:
+// windres -i a.rc -o rsrc.syso -O coff
+// where this windres calls into llvm-rc and llvm-cvtres. The source file,
+// a.rc, simply contains a reference to its own bytes:
+//
+// resname RCDATA a.rc
+//
+// Object dumping the resultant rsrc.syso, we can see the split sections and
+// the @feat.00 SEH symbol:
+//
+// rsrc.syso: file format coff-x86-64
+//
+// architecture: x86_64
+// start address: 0x0000000000000000
+//
+// Export Table:
+// Sections:
+// Idx Name Size VMA Type
+// 0 .rsrc$01 00000068 0000000000000000 DATA
+// 1 .rsrc$02 00000018 0000000000000000 DATA
+//
+// SYMBOL TABLE:
+// [ 0](sec -1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000011 @feat.00
+// [ 1](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .rsrc$01
+// AUX scnlen 0x68 nreloc 1 nlnno 0 checksum 0x0 assoc 0 comdat 0
+// [ 3](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .rsrc$02
+// AUX scnlen 0x18 nreloc 0 nlnno 0 checksum 0x0 assoc 0 comdat 0
+// [ 5](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 $R000000
+// RELOCATION RECORDS FOR [.rsrc$01]:
+// OFFSET TYPE VALUE
+// 0000000000000048 IMAGE_REL_AMD64_ADDR32NB $R000000
+
+package main
+
+func main() {}
diff --git a/src/cmd/link/testdata/testPErsrc-complex/rsrc.syso b/src/cmd/link/testdata/testPErsrc-complex/rsrc.syso
new file mode 100644
index 0000000..eff630b
--- /dev/null
+++ b/src/cmd/link/testdata/testPErsrc-complex/rsrc.syso
Binary files differ
diff --git a/src/cmd/link/testdata/testPErsrc/main.go b/src/cmd/link/testdata/testPErsrc/main.go
new file mode 100644
index 0000000..5eb66fb
--- /dev/null
+++ b/src/cmd/link/testdata/testPErsrc/main.go
@@ -0,0 +1,19 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that a PE rsrc section is handled correctly (issue 39658).
+//
+// rsrc.syso is created with:
+// windres -i a.rc -o rsrc.syso -O coff
+// on windows-amd64-2016 builder, where a.rc is a text file with
+// the following content:
+//
+// resname RCDATA {
+// "Hello Gophers!\0",
+// "This is a test.\0",
+// }
+
+package main
+
+func main() {}
diff --git a/src/cmd/link/testdata/testPErsrc/rsrc.syso b/src/cmd/link/testdata/testPErsrc/rsrc.syso
new file mode 100644
index 0000000..0d9699d
--- /dev/null
+++ b/src/cmd/link/testdata/testPErsrc/rsrc.syso
Binary files differ
diff --git a/src/cmd/link/testdata/testRO/x.go b/src/cmd/link/testdata/testRO/x.go
new file mode 100644
index 0000000..d77db6d
--- /dev/null
+++ b/src/cmd/link/testdata/testRO/x.go
@@ -0,0 +1,22 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that read-only data is indeed read-only. This
+// program attempts to modify read-only data, and it
+// should fail.
+
+package main
+
+import "unsafe"
+
+var s = "hello"
+
+func main() {
+ println(s)
+ *(*struct {
+ p *byte
+ l int
+ })(unsafe.Pointer(&s)).p = 'H'
+ println(s)
+}