Commit d66f6c2c authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

cmd/link: centralize knowledge of size of fixed part of stack

Shared libraries on ppc64le will require a larger minimum stack frame (because
the ABI mandates that the TOC pointer is available at 24(R1)). Part 2b of
preparing for that is to have all the code in the linker that needs to know
this size of this call a function to find out.

Change-Id: I246363840096db22e44beabbe38b61d60c1f31ad
Reviewed-on: https://go-review.googlesource.com/15675Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent c23c8d58
...@@ -1717,10 +1717,7 @@ func writelines() { ...@@ -1717,10 +1717,7 @@ func writelines() {
case obj.A_PARAM: case obj.A_PARAM:
dt = DW_ABRV_PARAM dt = DW_ABRV_PARAM
offs = int64(a.Aoffset) offs = int64(a.Aoffset) + Ctxt.FixedFrameSize()
if haslinkregister() {
offs += int64(Thearch.Ptrsize)
}
default: default:
continue continue
......
...@@ -1518,7 +1518,7 @@ var morestack *LSym ...@@ -1518,7 +1518,7 @@ var morestack *LSym
// allow stack checks here. // allow stack checks here.
func haslinkregister() bool { func haslinkregister() bool {
return Thearch.Thechar == '5' || Thearch.Thechar == '9' || Thearch.Thechar == '7' return Ctxt.FixedFrameSize() != 0
} }
func callsize() int { func callsize() int {
...@@ -1626,10 +1626,7 @@ func stkcheck(up *Chain, depth int) int { ...@@ -1626,10 +1626,7 @@ func stkcheck(up *Chain, depth int) int {
return 0 return 0
} }
// Raise limit to allow frame. // Raise limit to allow frame.
limit = int(obj.StackLimit + s.Locals) limit = int(obj.StackLimit+s.Locals) + int(Ctxt.FixedFrameSize())
if haslinkregister() {
limit += Thearch.Regsize
}
} }
// Walk through sp adjustments in function, consuming relocs. // Walk through sp adjustments in function, consuming relocs.
......
...@@ -149,6 +149,19 @@ type Link struct { ...@@ -149,6 +149,19 @@ type Link struct {
Moduledata *LSym Moduledata *LSym
} }
// The smallest possible offset from the hardware stack pointer to a local
// variable on the stack. Architectures that use a link register save its value
// on the stack in the function prologue and so always have a pointer between
// the hardware stack pointer and the local variable area.
func (ctxt *Link) FixedFrameSize() int64 {
switch ctxt.Arch.Thechar {
case '6', '8':
return 0
default:
return int64(ctxt.Arch.Ptrsize)
}
}
type LinkArch struct { type LinkArch struct {
ByteOrder binary.ByteOrder ByteOrder binary.ByteOrder
Name string Name string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment