github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/internal/objabi/stack.go (about)

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package objabi
     6  
     7  // For the linkers. Must match Go definitions.
     8  
     9  const (
    10  	STACKSYSTEM = 0
    11  	StackSystem = STACKSYSTEM
    12  	StackBig    = 4096
    13  	StackSmall  = 128
    14  )
    15  
    16  const (
    17  	StackPreempt = -1314 // 0xfff...fade
    18  )
    19  
    20  // Initialize StackGuard and StackLimit according to target system.
    21  var StackGuard = 896*stackGuardMultiplier() + StackSystem
    22  var StackLimit = StackGuard - StackSystem - StackSmall
    23  
    24  // stackGuardMultiplier returns a multiplier to apply to the default
    25  // stack guard size. Larger multipliers are used for non-optimized
    26  // builds that have larger stack frames or for specific targets.
    27  func stackGuardMultiplier() int {
    28  	// On AIX, a larger stack is needed for syscalls.
    29  	if GOOS == "aix" {
    30  		return 2
    31  	}
    32  	return stackGuardMultiplierDefault
    33  }