从我发现的所有文档中,没有提到offset[var+offset2]
英特尔 x86 语法中的语法,但 GCC 具有以下标志
gcc -S hello.c -o - -masm=intel
对于这个程序
#include<stdio.h>
int main(){
char c = 'h';
putchar(c);
return 0;
}
生产
.file "hello.c"
.intel_syntax noprefix
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
push rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
mov rbp, rsp
.cfi_def_cfa_register 6
sub rsp, 16
mov BYTE PTR -1[rbp], 104
movsx eax, BYTE PTR -1[rbp]
mov edi, eax
call putchar@PLT
mov eax, 0
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Arch Linux 9.3.0-1) 9.3.0"
.section .note.GNU-stack,"",@progbits
我想突出显示mov BYTE PTR -1[rbp], 104
偏移量-1
出现在方括号之外的行。TBH,我只是猜测它是一个偏移量,任何人都可以指导我找到一个适当的文档来强调这一点吗?
这是一个类似的问题:来自 IDA 的 x86 asm 中的 Squared Brackets评论确实提到它是一个偏移量,但我真的很想要一个适当的文档参考。