mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 11:37:46 +00:00
29b4c6723f
Modify the Unix signal handler to redirect execution to a Go sigpanic function instead of printing an error and re-raising the signal. The C signal handler modifies the ucontext to make the faulting instruction appear to have called tinygo_sigpanic, which then calls runtimePanic with the appropriate message. Supported on all architectures TinyGo targets on Linux and Darwin: x86_64, i386, aarch64, ARM, and MIPS. Also registers SIGFPE, which was previously not handled at all.
28 lines
490 B
Go
28 lines
490 B
Go
package runtime
|
|
|
|
const GOARCH = "386"
|
|
|
|
// The bitness of the CPU (e.g. 8, 32, 64).
|
|
const TargetBits = 32
|
|
|
|
const deferExtraRegs = 0
|
|
|
|
const callInstSize = 5 // "call someFunction" is 5 bytes
|
|
|
|
const (
|
|
linux_MAP_ANONYMOUS = 0x20
|
|
linux_SIGBUS = 7
|
|
linux_SIGFPE = 8
|
|
linux_SIGILL = 4
|
|
linux_SIGSEGV = 11
|
|
)
|
|
|
|
// Align on word boundary.
|
|
func align(ptr uintptr) uintptr {
|
|
return (ptr + 15) &^ 15
|
|
}
|
|
|
|
func getCurrentStackPointer() uintptr {
|
|
return uintptr(stacksave())
|
|
}
|