Skip to content

Commit 6ed2ec4

Browse files
committed
runtime: fix vet complaints for linux/386
Working toward making the tree vet-safe instead of having so many exceptions in cmd/vet/all/whitelist. This CL makes "GOOS=linux GOARCH=386 go vet -unsafeptr=false runtime" happy, while keeping "GO_BUILDER_NAME=misc-vetall go tool dist test" happy too. For #31916. Change-Id: I3e5586a7ff6e359357350d0602c2259493280ded Reviewed-on: https://go-review.googlesource.com/c/go/+/176099 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent cd03664 commit 6ed2ec4

36 files changed

+102
-110
lines changed

src/cmd/vet/all/whitelist/386.txt

-18
This file was deleted.

src/cmd/vet/all/whitelist/amd64.txt

-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,3 @@ runtime/asm_amd64.s: [amd64] morestack: use of 8(SP) points beyond argument fram
1313
// Others use the platform ABI.
1414
// There is no sensible corresponding Go prototype.
1515
runtime/asm_amd64.s: [amd64] aeshashbody: function aeshashbody missing Go declaration
16-
runtime/asm_amd64.s: [amd64] addmoduledata: function addmoduledata missing Go declaration
17-
runtime/duff_amd64.s: [amd64] duffzero: function duffzero missing Go declaration
18-
runtime/duff_amd64.s: [amd64] duffcopy: function duffcopy missing Go declaration

src/cmd/vet/all/whitelist/android_386.txt

-8
This file was deleted.

src/cmd/vet/all/whitelist/arm.txt

-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
// Intentionally missing declarations.
44
runtime/asm_arm.s: [arm] emptyfunc: function emptyfunc missing Go declaration
55
runtime/asm_arm.s: [arm] usplitR0: function usplitR0 missing Go declaration
6-
runtime/asm_arm.s: [arm] addmoduledata: function addmoduledata missing Go declaration
7-
runtime/duff_arm.s: [arm] duffzero: function duffzero missing Go declaration
8-
runtime/duff_arm.s: [arm] duffcopy: function duffcopy missing Go declaration
96
runtime/tls_arm.s: [arm] load_g: function load_g missing Go declaration
107
runtime/tls_arm.s: [arm] _initcgo: function _initcgo missing Go declaration

src/cmd/vet/all/whitelist/arm64.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// arm64-specific vet whitelist. See readme.txt for details.
22

33
// Intentionally missing declarations.
4-
runtime/asm_arm64.s: [arm64] addmoduledata: function addmoduledata missing Go declaration
54
runtime/tls_arm64.s: [arm64] load_g: function load_g missing Go declaration
65
runtime/tls_arm64.s: [arm64] save_g: function save_g missing Go declaration

src/cmd/vet/all/whitelist/darwin_386.txt

-5
This file was deleted.

src/cmd/vet/all/whitelist/freebsd_386.txt

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ runtime/sys_freebsd_386.s: [386] sigtramp: unknown variable signo
55
runtime/sys_freebsd_386.s: [386] sigtramp: unknown variable info
66
runtime/sys_freebsd_386.s: [386] sigtramp: unknown variable context
77
runtime/sys_freebsd_386.s: [386] sigtramp: unknown variable context
8-
runtime/sys_freebsd_386.s: [386] setldt: function setldt missing Go declaration
98
runtime/sys_freebsd_386.s: [386] i386_set_ldt: function i386_set_ldt missing Go declaration
109
syscall/asm_unix_386.s: [386] Syscall: 8(SP) should be a1+4(FP)
1110
syscall/asm_unix_386.s: [386] Syscall: 4(SP) should be trap+0(FP)

src/cmd/vet/all/whitelist/linux_386.txt

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
// linux/amd64-specific vet whitelist. See readme.txt for details.
22

33
runtime/sys_linux_amd64.s: [amd64] settls: function settls missing Go declaration
4-
5-
// Android-specific; stubs missing on other linux platforms.
6-
runtime/sys_linux_amd64.s: [amd64] access: function access missing Go declaration
7-
runtime/sys_linux_amd64.s: [amd64] connect: function connect missing Go declaration
8-
runtime/sys_linux_amd64.s: [amd64] socket: function socket missing Go declaration
-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
// linux/arm-specific vet whitelist. See readme.txt for details.
22

3-
43
// These SP references occur after a stack-altering call. They're fine.
54
runtime/sys_linux_arm.s: [arm] clone: 12(R13) should be stk+4(FP)
65
runtime/sys_linux_arm.s: [arm] clone: 8(R13) should be flags+0(FP)
7-
8-
// Special functions.
9-
runtime/sys_linux_arm.s: [arm] access: function access missing Go declaration
10-
runtime/sys_linux_arm.s: [arm] connect: function connect missing Go declaration
11-
runtime/sys_linux_arm.s: [arm] socket: function socket missing Go declaration

src/cmd/vet/all/whitelist/linux_arm64.txt

-5
This file was deleted.

src/cmd/vet/all/whitelist/nacl_386.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// nacl/386-specific vet whitelist. See readme.txt for details.
22

33
runtime/sys_nacl_386.s: [386] nacl_clock_gettime: function nacl_clock_gettime missing Go declaration
4-
runtime/sys_nacl_386.s: [386] setldt: function setldt missing Go declaration
54
runtime/sys_nacl_386.s: [386] sigtramp: use of 20(SP) points beyond argument frame
65
runtime/sys_nacl_386.s: [386] sigtramp: use of 4(SP) points beyond argument frame
76
runtime/sys_nacl_386.s: [386] sigtramp: unknown variable ctxt

src/cmd/vet/all/whitelist/netbsd_386.txt

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ runtime/sys_netbsd_386.s: [386] sigreturn_tramp: use of 4(SP) points beyond argu
99
runtime/sys_netbsd_386.s: [386] sigtramp: unknown variable signo
1010
runtime/sys_netbsd_386.s: [386] sigtramp: unknown variable info
1111
runtime/sys_netbsd_386.s: [386] sigtramp: unknown variable context
12-
runtime/sys_netbsd_386.s: [386] setldt: function setldt missing Go declaration
13-
runtime/sys_netbsd_386.s: [386] setldt: use of 16(SP) points beyond argument frame
1412

1513
syscall/asm_unix_386.s: [386] Syscall: 8(SP) should be a1+4(FP)
1614
syscall/asm_unix_386.s: [386] Syscall: 4(SP) should be trap+0(FP)

src/cmd/vet/all/whitelist/openbsd_386.txt

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
runtime/sys_openbsd_386.s: [386] sigtramp: unknown variable signo
44
runtime/sys_openbsd_386.s: [386] sigtramp: unknown variable info
55
runtime/sys_openbsd_386.s: [386] sigtramp: unknown variable context
6-
runtime/sys_openbsd_386.s: [386] setldt: function setldt missing Go declaration
76
runtime/sys_openbsd_386.s: [386] settls: function settls missing Go declaration
87
syscall/asm_unix_386.s: [386] Syscall: 8(SP) should be a1+4(FP)
98
syscall/asm_unix_386.s: [386] Syscall: 4(SP) should be trap+0(FP)

src/cmd/vet/all/whitelist/plan9_386.txt

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
// plan9/amd64-specific vet whitelist. See readme.txt for details.
22

3-
runtime/sys_plan9_amd64.s: [amd64] setldt: function setldt missing Go declaration
43
runtime/sys_plan9_amd64.s: [amd64] settls: function settls missing Go declaration

src/cmd/vet/all/whitelist/windows_386.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
runtime/sys_windows_386.s: [386] profileloop: use of 4(SP) points beyond argument frame
44
runtime/sys_windows_386.s: [386] ctrlhandler: 4(SP) should be _type+0(FP)
5-
runtime/sys_windows_386.s: [386] setldt: function setldt missing Go declaration
65
runtime/sys_windows_386.s: [386] callbackasm1+0: function callbackasm1+0 missing Go declaration
76
runtime/sys_windows_386.s: [386] tstart: function tstart missing Go declaration
87
runtime/sys_windows_386.s: [386] tstart_stdcall: RET without writing to 4-byte ret+4(FP)

src/runtime/asm_386.s

+7-6
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ GLOBL _rt0_386_lib_argc<>(SB),NOPTR, $4
8989
DATA _rt0_386_lib_argv<>(SB)/4, $0
9090
GLOBL _rt0_386_lib_argv<>(SB),NOPTR, $4
9191

92-
TEXT runtime·rt0_go(SB),NOSPLIT,$0
92+
TEXT runtime·rt0_go(SB),NOSPLIT|NOFRAME,$0
9393
// Copy arguments forward on an even stack.
9494
// Users of this function jump to it, they don't call it.
9595
MOVL 0(SP), AX
@@ -209,7 +209,7 @@ needtls:
209209
#endif
210210

211211
// set up %gs
212-
CALL runtime·ldt0setup(SB)
212+
CALL ldt0setup<>(SB)
213213

214214
// store through it, to make sure it works
215215
get_tls(BX)
@@ -453,6 +453,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0
453453

454454
// Called from f.
455455
// Set m->morebuf to f's caller.
456+
NOP SP // tell vet SP changed - stop checking offsets
456457
MOVL 4(SP), DI // f's caller's PC
457458
MOVL DI, (m_morebuf+gobuf_pc)(BX)
458459
LEAL 8(SP), CX // f's caller's SP
@@ -895,7 +896,7 @@ done:
895896
MOVL DX, ret_hi+4(FP)
896897
RET
897898

898-
TEXT runtime·ldt0setup(SB),NOSPLIT,$16-0
899+
TEXT ldt0setup<>(SB),NOSPLIT,$16-0
899900
// set up ldt 7 to point at m0.tls
900901
// ldt 1 would be fine on Linux, but on OS X, 7 is as low as we can go.
901902
// the entry number is just a hint. setldt will set up GS with what it used.
@@ -914,19 +915,19 @@ TEXT runtime·aeshash(SB),NOSPLIT,$0-16
914915
MOVL p+0(FP), AX // ptr to data
915916
MOVL s+8(FP), BX // size
916917
LEAL ret+12(FP), DX
917-
JMP runtime·aeshashbody(SB)
918+
JMP aeshashbody<>(SB)
918919

919920
TEXT runtime·aeshashstr(SB),NOSPLIT,$0-12
920921
MOVL p+0(FP), AX // ptr to string object
921922
MOVL 4(AX), BX // length of string
922923
MOVL (AX), AX // string data
923924
LEAL ret+8(FP), DX
924-
JMP runtime·aeshashbody(SB)
925+
JMP aeshashbody<>(SB)
925926

926927
// AX: data
927928
// BX: length
928929
// DX: address to put return value
929-
TEXT runtime·aeshashbody(SB),NOSPLIT,$0-0
930+
TEXT aeshashbody<>(SB),NOSPLIT,$0-0
930931
MOVL h+4(FP), X0 // 32 bits of per-table hash seed
931932
PINSRW $4, BX, X0 // 16 bits of length
932933
PSHUFHW $0, X0, X0 // replace size with its low 2 bytes repeated 4 times

src/runtime/asm_arm.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ TEXT runtime·usplitR0(SB),NOSPLIT,$0
893893

894894
#ifndef GOOS_nacl
895895
// This is called from .init_array and follows the platform, not Go, ABI.
896-
TEXT runtime·addmoduledata(SB),NOSPLIT,$0-8
896+
TEXT runtime·addmoduledata(SB),NOSPLIT,$0-0
897897
MOVW R9, saver9-4(SP) // The access to global variables below implicitly uses R9, which is callee-save
898898
MOVW R11, saver11-8(SP) // Likewise, R11 is the temp register, but callee-save in C ABI
899899
MOVW runtime·lastmoduledatap(SB), R1

src/runtime/duff_mips64x.s

+3
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,6 @@ TEXT runtime·duffzero(SB), NOSPLIT|NOFRAME, $0-0
266266
RET
267267

268268
// TODO: Implement runtime·duffcopy.
269+
TEXT runtime·duffcopy(SB),NOSPLIT|NOFRAME,$0-0
270+
MOVV R0, 2(R0)
271+
RET

src/runtime/duff_ppc64x.s

+3
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,6 @@ TEXT runtime·duffzero(SB), NOSPLIT|NOFRAME, $0-0
138138
RET
139139

140140
// TODO: Implement runtime·duffcopy.
141+
TEXT runtime·duffcopy(SB),NOSPLIT|NOFRAME,$0-0
142+
MOVD R0, 0(R0)
143+
RET

src/runtime/stubs.go

+5
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,8 @@ func abort()
319319

320320
// Called from compiled code; declared for vet; do NOT call from Go.
321321
func gcWriteBarrier()
322+
func duffzero()
323+
func duffcopy()
324+
325+
// Called from linker-generated .initarray; declared for go vet; do NOT call from Go.
326+
func addmoduledata()

src/runtime/stubs_386.go

+6
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44

55
package runtime
66

7+
import "unsafe"
8+
79
func float64touint32(a float64) uint32
810
func uint32tofloat64(a uint32) float64
11+
12+
// Called from assembly only; declared for go vet.
13+
func setldt(slot uintptr, base unsafe.Pointer, size uintptr)
14+
func emptyfunc()

src/runtime/stubs_android.go

-16
This file was deleted.

src/runtime/stubs_linux.go

+10
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,14 @@
66

77
package runtime
88

9+
import "unsafe"
10+
911
func sbrk0() uintptr
12+
13+
// Called from write_err_android.go only, but defined in sys_linux_*.s;
14+
// declared here (instead of in write_err_android.go) for go vet on non-android builds.
15+
// The return value is the raw syscall result, which may encode an error number.
16+
//go:noescape
17+
func access(name *byte, mode int32) int32
18+
func connect(fd int32, addr unsafe.Pointer, len int32) int32
19+
func socket(domain int32, typ int32, prot int32) int32

src/runtime/sys_freebsd_386.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ int i386_set_ldt(int, const union ldt_entry *, int);
295295

296296
// setldt(int entry, int address, int limit)
297297
TEXT runtime·setldt(SB),NOSPLIT,$32
298-
MOVL address+4(FP), BX // aka base
298+
MOVL base+4(FP), BX
299299
// see comment in sys_linux_386.s; freebsd is similar
300300
ADDL $0x4, BX
301301

src/runtime/sys_linux_386.s

+2-1
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ TEXT runtime·clone(SB),NOSPLIT,$0
474474
RET
475475

476476
// Paranoia: check that SP is as we expect.
477+
NOP SP // tell vet SP changed - stop checking offsets
477478
MOVL 12(SP), BP
478479
CMPL BP, $1234
479480
JEQ 2(PC)
@@ -572,7 +573,7 @@ GLOBL runtime·tls_entry_number(SB), NOPTR, $4
572573
// The name, setldt, is a misnomer, although we leave this name as it is for
573574
// the compatibility with other platforms.
574575
TEXT runtime·setldt(SB),NOSPLIT,$32
575-
MOVL address+4(FP), DX // base address
576+
MOVL base+4(FP), DX
576577

577578
#ifdef GOOS_android
578579
// Android stores the TLS offset in runtime·tls_g.

src/runtime/sys_linux_mips64x.s

+15
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,18 @@ TEXT runtime·sbrk0(SB),NOSPLIT|NOFRAME,$0-8
462462
SYSCALL
463463
MOVV R2, ret+0(FP)
464464
RET
465+
466+
TEXT runtime·access(SB),$0-20
467+
MOVV R0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
468+
MOVW R0, ret+16(FP) // for vet
469+
RET
470+
471+
TEXT runtime·connect(SB),$0-28
472+
MOVV R0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
473+
MOVW R0, ret+24(FP) // for vet
474+
RET
475+
476+
TEXT runtime·socket(SB),$0-20
477+
MOVV R0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
478+
MOVW R0, ret+16(FP) // for vet
479+
RET

src/runtime/sys_linux_mipsx.s

+15
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,18 @@ TEXT runtime·sbrk0(SB),NOSPLIT,$0-4
492492
SYSCALL
493493
MOVW R2, ret+0(FP)
494494
RET
495+
496+
TEXT runtime·access(SB),$0-12
497+
BREAK // unimplemented, only needed for android; declared in stubs_linux.go
498+
MOVW R0, ret+8(FP) // for vet
499+
RET
500+
501+
TEXT runtime·connect(SB),$0-16
502+
BREAK // unimplemented, only needed for android; declared in stubs_linux.go
503+
MOVW R0, ret+12(FP) // for vet
504+
RET
505+
506+
TEXT runtime·socket(SB),$0-16
507+
BREAK // unimplemented, only needed for android; declared in stubs_linux.go
508+
MOVW R0, ret+12(FP) // for vet
509+
RET

src/runtime/sys_linux_ppc64x.s

+15
Original file line numberDiff line numberDiff line change
@@ -616,3 +616,18 @@ TEXT runtime·sbrk0(SB),NOSPLIT|NOFRAME,$0
616616
SYSCALL $SYS_brk
617617
MOVD R3, ret+0(FP)
618618
RET
619+
620+
TEXT runtime·access(SB),$0-20
621+
MOVD R0, 0(R0) // unimplemented, only needed for android; declared in stubs_linux.go
622+
MOVW R0, ret+16(FP) // for vet
623+
RET
624+
625+
TEXT runtime·connect(SB),$0-28
626+
MOVD R0, 0(R0) // unimplemented, only needed for android; declared in stubs_linux.go
627+
MOVW R0, ret+24(FP) // for vet
628+
RET
629+
630+
TEXT runtime·socket(SB),$0-20
631+
MOVD R0, 0(R0) // unimplemented, only needed for android; declared in stubs_linux.go
632+
MOVW R0, ret+16(FP) // for vet
633+
RET

src/runtime/sys_linux_s390x.s

+15
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,18 @@ TEXT runtime·sbrk0(SB),NOSPLIT|NOFRAME,$0-8
446446
SYSCALL
447447
MOVD R2, ret+0(FP)
448448
RET
449+
450+
TEXT runtime·access(SB),$0-20
451+
MOVD $0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
452+
MOVW R0, ret+16(FP)
453+
RET
454+
455+
TEXT runtime·connect(SB),$0-28
456+
MOVD $0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
457+
MOVW R0, ret+24(FP)
458+
RET
459+
460+
TEXT runtime·socket(SB),$0-20
461+
MOVD $0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
462+
MOVW R0, ret+16(FP)
463+
RET

src/runtime/sys_nacl_386.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ TEXT runtime·nanotime(SB),NOSPLIT,$20
287287
RET
288288

289289
TEXT runtime·setldt(SB),NOSPLIT,$8
290-
MOVL addr+4(FP), BX // aka base
290+
MOVL base+4(FP), BX
291291
ADDL $0x8, BX
292292
MOVL BX, 0(SP)
293293
NACL_SYSCALL(SYS_tls_init)

0 commit comments

Comments
 (0)