Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.6.1 函数调用参数布局图,pseudo SP的值有问题? #615

Open
galaxyzen opened this issue Dec 19, 2022 · 1 comment
Open

3.6.1 函数调用参数布局图,pseudo SP的值有问题? #615

galaxyzen opened this issue Dec 19, 2022 · 1 comment

Comments

@galaxyzen
Copy link

galaxyzen commented Dec 19, 2022

pseudo SP 的值应该是parent return address处,不应该和BP的值相同?

@galaxyzen
Copy link
Author

package main

//go:noinline
func add(a, b int32) (int32, bool) { return a + b, true }

func main() { add(10, 32) }

版本:go1.16.15 amd64

go1.16.15 tool compile -S -N -l main.go 后,add的Go汇编:

"".add STEXT nosplit size=31 args=0x10 locals=0x0 funcid=0x0
        0x0000 00000 (main.go:4)        TEXT    "".add(SB), NOSPLIT|ABIInternal, $0-16
        0x0000 00000 (main.go:4)        FUNCDATA        $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
        0x0000 00000 (main.go:4)        FUNCDATA        $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
        0x0000 00000 (main.go:4)        MOVL    $0, "".~r2+16(SP)
        0x0008 00008 (main.go:4)        MOVB    $0, "".~r3+20(SP)
        0x000d 00013 (main.go:4)        MOVL    "".a+8(SP), AX
        0x0011 00017 (main.go:4)        ADDL    "".b+12(SP), AX
        0x0015 00021 (main.go:4)        MOVL    AX, "".~r2+16(SP)
        0x0019 00025 (main.go:4)        MOVB    $1, "".~r3+20(SP)
        0x001e 00030 (main.go:4)        RET

[pseudo SP + 8]定位到实参a[pseudo SP + 12]定位到实参b,所以pseudo SP的值应该是parent return address的起始位置?

@galaxyzen galaxyzen changed the title 3.6.1 函数调用参数布局图,pseudo SP 3.6.1 函数调用参数布局图,pseudo SP的值有问题? Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant