4ad/go.arm64

runtime: systemstack should align stack on 16-bytes

4ad opened this issue · 13 comments

4ad commented

All stacks must be 16-byte aligned, but newsysmon gets called with SP%16=8.

:crying:

On Thu, Feb 5, 2015 at 9:07 AM, Aram Hăvărneanu notifications@github.com
wrote:

All stacks must be 16-byte aligned, but newsysmon gets called with SP%16=8.


Reply to this email directly or view it on GitHub
https://github.com/4ad/go/issues/100.

Doesn't 6g have this restriction, amd64 stacks and function calls should be
16 byte aligned, yes ?

On Thu, Feb 5, 2015 at 10:43 AM, Dave Cheney dave@cheney.net wrote:

:crying:

On Thu, Feb 5, 2015 at 9:07 AM, Aram Hăvărneanu notifications@github.com
wrote:

All stacks must be 16-byte aligned, but newsysmon gets called with
SP%16=8.


Reply to this email directly or view it on GitHub
https://github.com/4ad/go/issues/100.

4ad commented

Liblink properly aligns everything if we do the right thing (e.g. have proper framesizes), it fails only for $0 functions which modify the stack pointer themselves.

It's trivial to fix all these places, though I am not sure how that impacts stack traces. Can gotraceback deal with this?

4ad commented

This might be a problem then. I don't think the fix is too hard though.

4ad commented

Yes, you get a SIGBUS if the stack is not aligned.

4ad commented

(Not only stack, but any kind of indirect reference through SP too, e.g. 16(SP) crashes if SP%16=8).

4ad commented

Not really. I think everything is mostly correct now, apart from assembly functions that modify the stack pointer manually in an incorrect way. The way liblink works now is that if you ask for a non-aligned frame size, it will align it for you by making it bigger. In other words, it will always generate correct code.

I think this is good and better than if we just require the user of liblink (assemblers, compiler) to specify correct framesize, because the passed framesize, or the framesize set in assembly always matches what the human user would expect, so it's easy to verify, and also makes go vet just work without significant changes.

I think this has been fully fixed, no?

4ad commented

I think so, yes.