blob: 4f85b241a96d586ffe646e9bd53d4a3bc4213e80 [file] [log] [blame]
Brent Austinba3052e2015-04-21 16:08:23 -07001// skip
2
Dan Willemsen38f2dba2016-07-08 14:54:35 -07003// Copyright 2012 The Go Authors. All rights reserved.
Brent Austinba3052e2015-04-21 16:08:23 -07004// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// Test the -X facility of the gc linker (6l etc.).
8// This test is run by linkx_run.go.
9
10package main
11
Dan Willemsen09eb3b12015-09-16 14:34:17 -070012import "fmt"
13
Brent Austinba3052e2015-04-21 16:08:23 -070014var tbd string
15var overwrite string = "dibs"
16
Patrice Arruda748609c2020-06-25 12:12:21 -070017var tbdcopy = tbd
18var overwritecopy = overwrite
19var arraycopy = [2]string{tbd, overwrite}
20
Dan Willemsen09eb3b12015-09-16 14:34:17 -070021var b bool
22var x int
23
Brent Austinba3052e2015-04-21 16:08:23 -070024func main() {
Dan Willemsen09eb3b12015-09-16 14:34:17 -070025 fmt.Println(tbd)
Patrice Arruda748609c2020-06-25 12:12:21 -070026 fmt.Println(tbdcopy)
27 fmt.Println(arraycopy[0])
28
Dan Willemsen09eb3b12015-09-16 14:34:17 -070029 fmt.Println(overwrite)
Patrice Arruda748609c2020-06-25 12:12:21 -070030 fmt.Println(overwritecopy)
31 fmt.Println(arraycopy[1])
32
33 // Check non-string symbols are not overwritten.
34 // This also make them used.
35 if b || x != 0 {
36 panic("b or x overwritten")
37 }
Brent Austinba3052e2015-04-21 16:08:23 -070038}