Skip to content

add showLinuxAbiAAPCS64 to commands/abi.go #241

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

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ view abi details with ret

output includes calling conventions, register volatility and more

for architecture specify one of `x86`, `32`, `x64`, `64` ~ the default is `x64`
for architecture specify one of `x86`, `32`, `x64`, `64`, `arm64`, `aapcs64` ~ the default is `x64`

for os specify one of `linux`, `windows` ~ the default is `linux`

Expand Down
40 changes: 39 additions & 1 deletion commands/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func init() {
func AbiHelp() string {
return "view abi details with ret\n\n" +
"output includes calling conventions, register volatility and more\n\n" +
"for architecture specify one of `x86`, `32`, `x64`, `64` " + theme.ColorGray + "~ the default is `x64`\n\n" + theme.ColorReset +
"for architecture specify one of `x86`, `32`, `x64`, `64`, `arm64`, `aapcs64` " + theme.ColorGray + "~ the default is `x64`\n\n" + theme.ColorReset +
"for os specify one of `linux`, `windows` " + theme.ColorGray + "~ the default is `linux`\n\n" + theme.ColorReset +
"for example:\n" +
"```bash\n" +
Expand Down Expand Up @@ -90,6 +90,40 @@ func showLinuxAbix64() {
fmt.Println(theme.ColorGray + " 128-byte area below the stack pointer see -mno-red-zone" + theme.ColorReset)
}

func showLinuxAbiAAPCS64() {
fmt.Println(theme.ColorPurple + "linux 🐧 " + theme.ColorPurple + "AAPCS64" + theme.ColorReset)

fmt.Println(theme.ColorPurple + " X31 Stack Pointer " + theme.ColorReset + "(" + theme.ColorPurple + "SP" + theme.ColorReset + ") - " + theme.ColorPurple +
"X30 Link Register " + theme.ColorReset + "(" + theme.ColorPurple + "LR" + theme.ColorReset + ") - " + theme.ColorPurple +
"X29 Frame Pointer " + theme.ColorReset + "(" + theme.ColorPurple + "FP" + theme.ColorReset + ")")

fmt.Println(theme.ColorYellow + "\nscratch" + theme.ColorReset + "/" + theme.ColorYellow + "caller-save" + theme.ColorReset + "/" + theme.ColorYellow + "volatile" + theme.ColorReset + ":")

fmt.Println(theme.ColorYellow + " X9 X10 X11 X12 X13 X14 X15" + theme.ColorReset)

fmt.Println(theme.ColorGreen + "\ncallee-save" + theme.ColorReset + "/" + theme.ColorGreen + "non-volatile" + theme.ColorReset + ":")

fmt.Println(theme.ColorGreen + " X19 X20 X21 X22 X23 X24 X25 X26 X27 X28" + theme.ColorReset)

fmt.Println(theme.ColorBlue + "\nintraprocedure" + theme.ColorReset + "/" + theme.ColorBlue + "platform" + theme.ColorReset + ":")

fmt.Println(theme.ColorBlue + " X16 " + theme.ColorReset + "(" + theme.ColorBlue + "IP0" + theme.ColorReset + ") - " + theme.ColorBlue +
"X17 " + theme.ColorReset + "(" + theme.ColorBlue + "IP1" + theme.ColorReset + ") - " + theme.ColorBlue +
"X18 Platform Register " + theme.ColorReset + "(" + theme.ColorBlue + "PR" + theme.ColorReset + ")")

fmt.Println(theme.ColorCyan + "\ncall" + theme.ColorReset + ":")

fmt.Println(theme.ColorCyan + " X0 X1 X2 X3 X4 X5 X6 X7 STACK => X0 X1 X2 X3 X4 X5 X6 X7" + theme.ColorReset)

fmt.Println(theme.ColorGray + " X8 can be used to pass the address location of an indirect result" + theme.ColorReset)

fmt.Println(theme.ColorGray + " arguments on the stack should be sign or zero extended and aligned to 8 bytes" + theme.ColorReset)

fmt.Println(theme.ColorRed + "\nsyscall" + theme.ColorReset + ":" + theme.ColorReset)

fmt.Println(theme.ColorRed + " X8 X0 X1 X2 X3 X4 X5 => X0" + theme.ColorReset)
}

func showWindowsAbix86() {
fmt.Println(theme.ColorBlue + "windows 🪟 " + theme.ColorBlue + "x86" + theme.ColorReset)

Expand Down Expand Up @@ -154,6 +188,10 @@ func Abi(args []string) {
} else {
showWindowsAbix64()
}
case "arm64", "aapcs64":
if opsys == "linux" {
showLinuxAbiAAPCS64()
}
default:
{
log.Fatalf("💥 " + theme.ColorRed + "error" + theme.ColorReset + ": unsupported architecture. use 'x86/32' or 'x64/64'\n" + theme.ColorReset)
Expand Down