diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go index 41d820dc153fcd90365ce73355dc1e202b3ec7d6..dcfd6a8e347f4555ac57f14b89659dbaff38e554 100644 --- a/src/cmd/link/internal/ld/dwarf.go +++ b/src/cmd/link/internal/ld/dwarf.go @@ -1717,10 +1717,7 @@ func writelines() { case obj.A_PARAM: dt = DW_ABRV_PARAM - offs = int64(a.Aoffset) - if haslinkregister() { - offs += int64(Thearch.Ptrsize) - } + offs = int64(a.Aoffset) + Ctxt.FixedFrameSize() default: continue diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 764f610bcd33263f511538403c8749cb6ba3605c..5977bee7f108a687e43f6e374c8b3a2bc07b972b 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1518,7 +1518,7 @@ var morestack *LSym // allow stack checks here. func haslinkregister() bool { - return Thearch.Thechar == '5' || Thearch.Thechar == '9' || Thearch.Thechar == '7' + return Ctxt.FixedFrameSize() != 0 } func callsize() int { @@ -1626,10 +1626,7 @@ func stkcheck(up *Chain, depth int) int { return 0 } // Raise limit to allow frame. - limit = int(obj.StackLimit + s.Locals) - if haslinkregister() { - limit += Thearch.Regsize - } + limit = int(obj.StackLimit+s.Locals) + int(Ctxt.FixedFrameSize()) } // Walk through sp adjustments in function, consuming relocs. diff --git a/src/cmd/link/internal/ld/link.go b/src/cmd/link/internal/ld/link.go index 7a2c1fa296a28571cdaa4fa33f81932302d218b2..a384b9508da031451196324a53339fb339ffa60e 100644 --- a/src/cmd/link/internal/ld/link.go +++ b/src/cmd/link/internal/ld/link.go @@ -149,6 +149,19 @@ type Link struct { 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 { ByteOrder binary.ByteOrder Name string