2013-03-19 11:40:29 -06:00
|
|
|
// Copyright 2011 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.
|
|
|
|
|
2014-11-21 11:39:01 -07:00
|
|
|
package runtime
|
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
2014-09-24 14:55:26 -06:00
|
|
|
|
2014-11-21 11:39:01 -07:00
|
|
|
type sigTabT struct {
|
|
|
|
flags int
|
2015-02-12 20:09:12 -07:00
|
|
|
name string
|
2014-11-21 11:39:01 -07:00
|
|
|
}
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// Incoming notes are compared against this table using strncmp, so the
|
|
|
|
// order matters: longer patterns must appear before their prefixes.
|
2014-11-21 11:39:01 -07:00
|
|
|
// There are _SIG constants in os2_plan9.go for the table index of some
|
|
|
|
// of these.
|
2014-03-13 10:00:12 -06:00
|
|
|
//
|
|
|
|
// If you add entries to this table, you must respect the prefix ordering
|
2014-11-21 11:39:01 -07:00
|
|
|
// and also update the constant values is os2_plan9.go.
|
|
|
|
var sigtable = [...]sigTabT{
|
2014-03-13 10:00:12 -06:00
|
|
|
// Traps that we cannot be recovered.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigThrow, "sys: trap: debug exception"},
|
|
|
|
{_SigThrow, "sys: trap: invalid opcode"},
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// We can recover from some memory errors in runtime·sigpanic.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigPanic, "sys: trap: fault read addr"}, // SIGRFAULT
|
|
|
|
{_SigPanic, "sys: trap: fault write addr"}, // SIGWFAULT
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// We can also recover from math errors.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigPanic, "sys: trap: divide error"}, // SIGINTDIV
|
|
|
|
{_SigPanic, "sys: fp:"}, // SIGFLOAT
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// All other traps are normally handled as if they were marked SigThrow.
|
|
|
|
// We mark them SigPanic here so that debug.SetPanicOnFault will work.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigPanic, "sys: trap:"}, // SIGTRAP
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// Writes to a closed pipe can be handled if desired, otherwise they're ignored.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigNotify, "sys: write on closed pipe"},
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// Other system notes are more serious and cannot be recovered.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigThrow, "sys:"},
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// Issued to all other procs when calling runtime·exit.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigGoExit, "go: exit "},
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// Kill is sent by external programs to cause an exit.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigKill, "kill"},
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// Interrupts can be handled if desired, otherwise they cause an exit.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigNotify + _SigKill, "interrupt"},
|
|
|
|
{_SigNotify + _SigKill, "hangup"},
|
2014-03-13 10:00:12 -06:00
|
|
|
|
|
|
|
// Alarms can be handled if desired, otherwise they're ignored.
|
2015-02-12 20:09:12 -07:00
|
|
|
{_SigNotify, "alarm"},
|
2014-11-21 11:39:01 -07:00
|
|
|
}
|