У меня есть следующий код сборки.
Я вижу строковое значение в регистре "% rax" после "lea" - (A)
(gdb) p (char*)0x558efff0a010
$1 = 0x558efff0a010 "abc"
Однако я не вижу значения в стеке после "move""- (B)
(gdb) p (char*)0x7fff2754b2a8
$2 = 0x7fff2754b2a8 "\020\240\360\377\216U"
Я что-то упустил?
код сборки
.data
.L0:
.string "abc"
.text
.global f
f:
push %rbp
mov %rsp, %rbp
sub $8, %rsp
lea .L0(%rip), %rax -- (A)
mov %rax, -8(%rbp) -- (B)
leave
ret
main:
rax 0x558effd095fa 94072665576954
rbp 0x7fff2754b2c0 0x7fff2754b2c0
rsp 0x7fff2754b2c0 0x7fff2754b2c0
--------------|--------------
ADDRESS |VALUE
--------------|--------------
0x7fff2754b2c0| <= rbp, rsp
--------------|--------------
f ()
rax 0x0 0
rbp 0x7fff2754b2c0 0x7fff2754b2c0
rsp 0x7fff2754b2b8 0x7fff2754b2b8
--------------|--------------
ADDRESS |VALUE
--------------|--------------
0x7fff2754b2c0| <= rbp
--------------|--------------
0x7fff2754b2b8| <= rsp
--------------|--------------
push% rbp
rax 0x0 0
rbp 0x7fff2754b2c0 0x7fff2754b2c0
rsp 0x7fff2754b2b0 0x7fff2754b2b0
--------------|--------------
ADDRESS |VALUE
--------------|--------------
0x7fff2754b2c0| <= rbp
--------------|--------------
0x7fff2754b2b8|
--------------|--------------
0x7fff2754b2b0| <= rsp
--------------|--------------
mov% rsp,% rbp
rax 0x0 0
rbp 0x7fff2754b2b0 0x7fff2754b2b0
rsp 0x7fff2754b2b0 0x7fff2754b2b0
--------------|--------------
ADDRESS |VALUE
--------------|--------------
0x7fff2754b2c0|
--------------|--------------
0x7fff2754b2b8|
--------------|--------------
0x7fff2754b2b0| <= rbp, rsp
--------------|--------------
sub $ 8,% rsp
rax 0x0 0
rbp 0x7fff2754b2b0 0x7fff2754b2b0
rsp 0x7fff2754b2a8 0x7fff2754b2a8
--------------|--------------
ADDRESS |VALUE
--------------|--------------
0x7fff2754b2c0|
--------------|--------------
0x7fff2754b2b8|
--------------|--------------
0x7fff2754b2b0| <= rbp
--------------|--------------
0x7fff2754b2a8| <= rsp
--------------|--------------
lea .L0 (% rip),% rax
rax 0x558efff0a010 94072667676688
rbp 0x7fff2754b2b0 0x7fff2754b2b0
rsp 0x7fff2754b2a8 0x7fff2754b2a8
--------------|--------------
ADDRESS |VALUE
--------------|--------------
0x7fff2754b2c0|
--------------|--------------
0x7fff2754b2b8|
--------------|--------------
0x7fff2754b2b0| <= rbp
--------------|--------------
0x7fff2754b2a8| <= rsp
--------------|--------------
(gdb) p (char*)0x558efff0a010
$1 = 0x558efff0a010 "abc"
mov% rax, -8 (% rbp)
rax 0x558efff0a010 94072667676688
rbp 0x7fff2754b2b0 0x7fff2754b2b0
rsp 0x7fff2754b2a8 0x7fff2754b2a8
--------------|--------------
ADDRESS |VALUE
--------------|--------------
0x7fff2754b2c0|
--------------|--------------
0x7fff2754b2b8|
--------------|--------------
0x7fff2754b2b0| <= rbp
--------------|--------------
0x7fff2754b2a8| <= rsp
--------------|--------------
(gdb) p (char*)0x7fff2754b2a8
$2 = 0x7fff2754b2a8 "\020\240\360\377\216U"
Обновление 1
Я пытался (char **)
rax 0x55b1ef3cc010 94222711308304
rsp 0x7ffd7fcd8cc8 0x7ffd7fcd8cc8
(gdb) p (char*)0x55b1ef3cc010
$3 = 0x55b1ef3cc010 "abc"
(gdb) p (char**)0x7ffd7fcd8cc8
$2 = (char **) 0x7ffd7fcd8cc8
Как сказал @Peter Cordes, я обнаружил разницу между LEA и MOV.
В чем разница между MOV и LEA?