我刚开始在VMware的Kali Linux学习汇编语言,我的CPU是Ryzen 5。在下面的代码片段中,有一些我不理解的东西。
- <main + 17>处的
lea rax, [rip ± 0xeb3]
是什么意思?我知道lea
的作用,但±表示什么? - 更新后RDI的目的是什么?
(gdb) list
1 #include<stdio.h>
2
3 int main(){
4 int i;
5 for(i = 0 ; i < 10 ; i++){
6 printf("Hello World!\n");
7 }
8 return 0;
9 }
(gdb) disassemble main
Dump of assembler code for function main:
0x0000000000001139 <+0>: push rbp
0x000000000000113a <+1>: mov rbp,rsp
0x000000000000113d <+4>: sub rsp,0x10
0x0000000000001141 <+8>: mov DWORD PTR [rbp-0x4],0x0
0x0000000000001148 <+15>: jmp 0x115d <main+36>
0x000000000000114a <+17>: lea rax,[rip±0xeb3] # 0x2004
0x0000000000001151 <+24>: mov rdi,rax
0x0000000000001154 <+27>: call 0x1030 <puts@plt>
0x0000000000001159 <+32>: add DWORD PTR [rbp-0x4],0x1
0x000000000000115d <+36>: cmp DWORD PTR [rbp-0x4],0x9
0x0000000000001161 <+40>: jle 0x114a <main+17>
0x0000000000001163 <+42>: mov eax,0x0
0x0000000000001168 <+47>: leave
0x0000000000001169 <+48>: ret
End of assembler dump.
(gdb)
编辑:
gdb -v
GNU gdb (Debian 12.1-3) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
disassemble
命令(gdb/disassemble.c
)将这些标记转换为终端转义字符。 - Margaret Bloomset style disassembler enabled off
命令来禁用反汇编样式,这将解决格式问题。 - Andrew