diff options
| author | Russ Cox <rsc@golang.org> | 2014-01-13 23:07:57 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-01-13 23:07:57 -0500 |
| commit | 7cecac3cbbd16baf80c9d15b92fc55444bf2870e (patch) | |
| tree | b989cb6afd905b2389ebec48c7a89a39321b1555 /src/cmd/link/testdata | |
| parent | 9c1aa658bfb73018805fde0c6224a289aced0d03 (diff) | |
| download | go-7cecac3cbbd16baf80c9d15b92fc55444bf2870e.tar.xz | |
cmd/link: implement and test automatic symbols
Related changes included in this CL:
- Add explicit start symbol to Prog.
- Add omitRuntime bool to Prog.
- Introduce p.Packages[""] to hold automatic symbols
- Add SymOrder to Prog to preserve symbol order.
- Add layout test (and fix bug that was putting everything in text section).
R=iant
CC=golang-codereviews
https://golang.org/cl/51260045
Diffstat (limited to 'src/cmd/link/testdata')
| -rw-r--r-- | src/cmd/link/testdata/autosection.6 | bin | 0 -> 909 bytes | |||
| -rw-r--r-- | src/cmd/link/testdata/autosection.s | 60 | ||||
| -rw-r--r-- | src/cmd/link/testdata/autoweak.6 | bin | 0 -> 428 bytes | |||
| -rw-r--r-- | src/cmd/link/testdata/autoweak.s | 30 | ||||
| -rw-r--r-- | src/cmd/link/testdata/layout.6 | bin | 0 -> 431 bytes | |||
| -rw-r--r-- | src/cmd/link/testdata/layout.s | 29 |
6 files changed, 119 insertions, 0 deletions
diff --git a/src/cmd/link/testdata/autosection.6 b/src/cmd/link/testdata/autosection.6 Binary files differnew file mode 100644 index 0000000000..62619a7ea3 --- /dev/null +++ b/src/cmd/link/testdata/autosection.6 diff --git a/src/cmd/link/testdata/autosection.s b/src/cmd/link/testdata/autosection.s new file mode 100644 index 0000000000..8a579b7027 --- /dev/null +++ b/src/cmd/link/testdata/autosection.s @@ -0,0 +1,60 @@ +// Copyright 2014 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 of section-named symbols. + +#include "../../ld/textflag.h" + +TEXT start(SB),7,$0 + MOVQ $autotab(SB),AX + MOVQ $autoptr(SB),AX + RET + +GLOBL zero(SB), $8 + +GLOBL zeronoptr(SB), NOPTR, $16 + +// text +DATA autotab+0x00(SB)/8, $text(SB) +DATA autotab+0x08(SB)/8, $start(SB) +DATA autotab+0x10(SB)/8, $etext(SB) +DATA autotab+0x18(SB)/8, $start+16(SB) + +// data +DATA autotab+0x20(SB)/8, $data(SB) +DATA autotab+0x28(SB)/8, $autotab(SB) +DATA autotab+0x30(SB)/8, $edata(SB) +DATA autotab+0x38(SB)/8, $nonzero+4(SB) + +// bss +DATA autotab+0x40(SB)/8, $bss(SB) +DATA autotab+0x48(SB)/8, $zero(SB) +DATA autotab+0x50(SB)/8, $ebss(SB) +DATA autotab+0x58(SB)/8, $zero+8(SB) + +// noptrdata +DATA autotab+0x60(SB)/8, $noptrdata(SB) +DATA autotab+0x68(SB)/8, $nonzeronoptr(SB) +DATA autotab+0x70(SB)/8, $enoptrdata(SB) +DATA autotab+0x78(SB)/8, $nonzeronoptr+8(SB) + +// noptrbss +DATA autotab+0x80(SB)/8, $noptrbss(SB) +DATA autotab+0x88(SB)/8, $zeronoptr(SB) +DATA autotab+0x90(SB)/8, $enoptrbss(SB) +DATA autotab+0x98(SB)/8, $zeronoptr+16(SB) + +// end +DATA autotab+0xa0(SB)/8, $end(SB) +DATA autotab+0xa8(SB)/8, $zeronoptr+16(SB) + +GLOBL autotab(SB), $0xb0 + +DATA nonzero(SB)/4, $1 +GLOBL nonzero(SB), $4 + +DATA nonzeronoptr(SB)/8, $2 +GLOBL nonzeronoptr(SB), NOPTR, $8 + +GLOBL autoptr(SB), $0 diff --git a/src/cmd/link/testdata/autoweak.6 b/src/cmd/link/testdata/autoweak.6 Binary files differnew file mode 100644 index 0000000000..f7e9e69713 --- /dev/null +++ b/src/cmd/link/testdata/autoweak.6 diff --git a/src/cmd/link/testdata/autoweak.s b/src/cmd/link/testdata/autoweak.s new file mode 100644 index 0000000000..2d11330db2 --- /dev/null +++ b/src/cmd/link/testdata/autoweak.s @@ -0,0 +1,30 @@ +// Copyright 2014 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 of go.weak symbols. + +TEXT start(SB),7,$0 + MOVQ $autotab(SB),AX + MOVQ $autoptr(SB),AX + RET + +// go.weak.sym should resolve to sym, because sym is in the binary. +DATA autotab+0(SB)/8, $go·weak·sym(SB) +DATA autotab+8(SB)/8, $sym(SB) + +// go.weak.missingsym should resolve to 0, because missingsym is not in the binary. +DATA autotab+16(SB)/8, $go·weak·missingsym(SB) +DATA autotab+24(SB)/8, $0 + +// go.weak.deadsym should resolve to 0, because deadsym is discarded during dead code removal +DATA autotab+32(SB)/8, $go·weak·deadsym(SB) +DATA autotab+40(SB)/8, $0 + +GLOBL autotab(SB), $48 + +GLOBL sym(SB), $1 + +GLOBL deadsym(SB), $1 + +GLOBL autoptr(SB), $0 diff --git a/src/cmd/link/testdata/layout.6 b/src/cmd/link/testdata/layout.6 Binary files differnew file mode 100644 index 0000000000..b19491efc5 --- /dev/null +++ b/src/cmd/link/testdata/layout.6 diff --git a/src/cmd/link/testdata/layout.s b/src/cmd/link/testdata/layout.s new file mode 100644 index 0000000000..0d492c5af2 --- /dev/null +++ b/src/cmd/link/testdata/layout.s @@ -0,0 +1,29 @@ +// Copyright 2014 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 of section assignment in layout.go. +// Each symbol should end up in the section named by the symbol name prefix (up to the underscore). + +#include "../../ld/textflag.h" + +TEXT text_start(SB),7,$0 + MOVQ $rodata_sym(SB), AX + MOVQ $noptrdata_sym(SB), AX + MOVQ $data_sym(SB), AX + MOVQ $bss_sym(SB), AX + MOVQ $noptrbss_sym(SB), AX + RET + +DATA rodata_sym(SB)/4, $1 +GLOBL rodata_sym(SB), RODATA, $4 + +DATA noptrdata_sym(SB)/4, $1 +GLOBL noptrdata_sym(SB), NOPTR, $4 + +DATA data_sym(SB)/4, $1 +GLOBL data_sym(SB), $4 + +GLOBL bss_sym(SB), $4 + +GLOBL noptrbss_sym(SB), NOPTR, $4 |
