]> Cypherpunks repositories - gostls13.git/commit
cmd/cc, cmd/ld, runtime: disallow conservative data/bss objects
authorRuss Cox <rsc@golang.org>
Wed, 24 Sep 2014 20:55:26 +0000 (16:55 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 24 Sep 2014 20:55:26 +0000 (16:55 -0400)
commit193daab9889708f7a20ff46efe0fa4b2bf0468d3
tree356ce59a8267353dc7436190562a76b897893ea2
parent5917692b98695b606744f638224a82a2472bfeaa
cmd/cc, cmd/ld, runtime: disallow conservative data/bss objects

In linker, refuse to write conservative (array of pointers) as the
garbage collection type for any variable in the data/bss GC program.

In the linker, attach the Go type to an already-read C declaration
during dedup. This gives us Go types for C globals for free as long
as the cmd/dist-generated Go code contains the declaration.
(Most runtime C declarations have a corresponding Go declaration.
Both are bss declarations and so the linker dedups them.)

In cmd/dist, add a few more C files to the auto-Go-declaration list
in order to get Go type information for the C declarations into the linker.

In C compiler, mark all non-pointer-containing global declarations
and all string data as NOPTR. This allows them to exist in C files
without any corresponding Go declaration. Count C function pointers
as "non-pointer-containing", since we have no heap-allocated C functions.

In runtime, add NOPTR to the remaining pointer-containing declarations,
none of which refer to Go heap objects.

In runtime, also move os.Args and syscall.envs data into runtime-owned
variables. Otherwise, in programs that do not import os or syscall, the
runtime variables named os.Args and syscall.envs will be missing type
information.

I believe that this CL eliminates the final source of conservative GC scanning
in non-SWIG Go programs, and therefore...

Fixes #909.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/149770043
32 files changed:
src/cmd/cc/dcl.c
src/cmd/cc/lex.c
src/cmd/cgo/out.go
src/cmd/dist/buildruntime.c
src/cmd/ld/data.c
src/liblink/objfile.c
src/os/proc.go
src/runtime/asm_386.s
src/runtime/asm_amd64.s
src/runtime/asm_amd64p32.s
src/runtime/heapdump.c
src/runtime/malloc.c
src/runtime/malloc.h
src/runtime/mcache.c
src/runtime/mgc0.c
src/runtime/os_windows.c
src/runtime/proc.c
src/runtime/proc.go
src/runtime/runtime.c
src/runtime/runtime.go
src/runtime/signals_darwin.h
src/runtime/signals_dragonfly.h
src/runtime/signals_freebsd.h
src/runtime/signals_linux.h
src/runtime/signals_nacl.h
src/runtime/signals_netbsd.h
src/runtime/signals_openbsd.h
src/runtime/signals_plan9.h
src/runtime/signals_solaris.h
src/runtime/stack.c
src/runtime/thunk.s
src/syscall/env_unix.go