Skip to content

Commit d149547

Browse files
authored
Merge pull request #241 from dmur1/abi-command-arm-#194
add showLinuxAbiAAPCS64 to commands/abi.go
2 parents cd29c46 + 13bc09c commit d149547

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ view abi details with ret
7070

7171
output includes calling conventions, register volatility and more
7272

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

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

commands/abi.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func init() {
3232
func AbiHelp() string {
3333
return "view abi details with ret\n\n" +
3434
"output includes calling conventions, register volatility and more\n\n" +
35-
"for architecture specify one of `x86`, `32`, `x64`, `64` " + theme.ColorGray + "~ the default is `x64`\n\n" + theme.ColorReset +
35+
"for architecture specify one of `x86`, `32`, `x64`, `64`, `arm64`, `aapcs64` " + theme.ColorGray + "~ the default is `x64`\n\n" + theme.ColorReset +
3636
"for os specify one of `linux`, `windows` " + theme.ColorGray + "~ the default is `linux`\n\n" + theme.ColorReset +
3737
"for example:\n" +
3838
"```bash\n" +
@@ -90,6 +90,40 @@ func showLinuxAbix64() {
9090
fmt.Println(theme.ColorGray + " 128-byte area below the stack pointer see -mno-red-zone" + theme.ColorReset)
9191
}
9292

93+
func showLinuxAbiAAPCS64() {
94+
fmt.Println(theme.ColorPurple + "linux 🐧 " + theme.ColorPurple + "AAPCS64" + theme.ColorReset)
95+
96+
fmt.Println(theme.ColorPurple + " X31 Stack Pointer " + theme.ColorReset + "(" + theme.ColorPurple + "SP" + theme.ColorReset + ") - " + theme.ColorPurple +
97+
"X30 Link Register " + theme.ColorReset + "(" + theme.ColorPurple + "LR" + theme.ColorReset + ") - " + theme.ColorPurple +
98+
"X29 Frame Pointer " + theme.ColorReset + "(" + theme.ColorPurple + "FP" + theme.ColorReset + ")")
99+
100+
fmt.Println(theme.ColorYellow + "\nscratch" + theme.ColorReset + "/" + theme.ColorYellow + "caller-save" + theme.ColorReset + "/" + theme.ColorYellow + "volatile" + theme.ColorReset + ":")
101+
102+
fmt.Println(theme.ColorYellow + " X9 X10 X11 X12 X13 X14 X15" + theme.ColorReset)
103+
104+
fmt.Println(theme.ColorGreen + "\ncallee-save" + theme.ColorReset + "/" + theme.ColorGreen + "non-volatile" + theme.ColorReset + ":")
105+
106+
fmt.Println(theme.ColorGreen + " X19 X20 X21 X22 X23 X24 X25 X26 X27 X28" + theme.ColorReset)
107+
108+
fmt.Println(theme.ColorBlue + "\nintraprocedure" + theme.ColorReset + "/" + theme.ColorBlue + "platform" + theme.ColorReset + ":")
109+
110+
fmt.Println(theme.ColorBlue + " X16 " + theme.ColorReset + "(" + theme.ColorBlue + "IP0" + theme.ColorReset + ") - " + theme.ColorBlue +
111+
"X17 " + theme.ColorReset + "(" + theme.ColorBlue + "IP1" + theme.ColorReset + ") - " + theme.ColorBlue +
112+
"X18 Platform Register " + theme.ColorReset + "(" + theme.ColorBlue + "PR" + theme.ColorReset + ")")
113+
114+
fmt.Println(theme.ColorCyan + "\ncall" + theme.ColorReset + ":")
115+
116+
fmt.Println(theme.ColorCyan + " X0 X1 X2 X3 X4 X5 X6 X7 STACK => X0 X1 X2 X3 X4 X5 X6 X7" + theme.ColorReset)
117+
118+
fmt.Println(theme.ColorGray + " X8 can be used to pass the address location of an indirect result" + theme.ColorReset)
119+
120+
fmt.Println(theme.ColorGray + " arguments on the stack should be sign or zero extended and aligned to 8 bytes" + theme.ColorReset)
121+
122+
fmt.Println(theme.ColorRed + "\nsyscall" + theme.ColorReset + ":" + theme.ColorReset)
123+
124+
fmt.Println(theme.ColorRed + " X8 X0 X1 X2 X3 X4 X5 => X0" + theme.ColorReset)
125+
}
126+
93127
func showWindowsAbix86() {
94128
fmt.Println(theme.ColorBlue + "windows 🪟 " + theme.ColorBlue + "x86" + theme.ColorReset)
95129

@@ -154,6 +188,10 @@ func Abi(args []string) {
154188
} else {
155189
showWindowsAbix64()
156190
}
191+
case "arm64", "aapcs64":
192+
if opsys == "linux" {
193+
showLinuxAbiAAPCS64()
194+
}
157195
default:
158196
{
159197
log.Fatalf("💥 " + theme.ColorRed + "error" + theme.ColorReset + ": unsupported architecture. use 'x86/32' or 'x64/64'\n" + theme.ColorReset)

0 commit comments

Comments
 (0)