mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +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.
30 lines
611 B
Go
30 lines
611 B
Go
package runtime
|
|
|
|
const GOARCH = "amd64"
|
|
|
|
// The bitness of the CPU (e.g. 8, 32, 64).
|
|
const TargetBits = 64
|
|
|
|
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 a pointer.
|
|
// Note that some amd64 instructions (like movaps) expect 16-byte aligned
|
|
// memory, thus the result must be 16-byte aligned.
|
|
func align(ptr uintptr) uintptr {
|
|
return (ptr + 15) &^ 15
|
|
}
|
|
|
|
func getCurrentStackPointer() uintptr {
|
|
return uintptr(stacksave())
|
|
}
|