我最近自學電腦系統。我不明白二進制彈子實驗室階段2的代碼。我輸入1 2 3 4 5 6作爲輸入-0x20混亂(%ebp)
這些通道是幹什麼的? 這個-0x20是怎麼來的?它的目的是什麼?
0x08048bab <+7>: lea -0x20(%ebp),%eax
0x08048bae <+10>: mov %eax,0x4(%esp)
這些代碼來自
Dump of assembler code for function phase_2:
0x08048ba4 <+0>: push %ebp
0x08048ba5 <+1>: mov %esp,%ebp
0x08048ba7 <+3>: push %ebx
0x08048ba8 <+4>: sub $0x34,%esp
0x08048bab <+7>: lea -0x20(%ebp),%eax
0x08048bae <+10>: mov %eax,0x4(%esp)
0x08048bb2 <+14>: mov 0x8(%ebp),%eax
0x08048bb5 <+17>: mov %eax,(%esp)
0x08048bb8 <+20>: call 0x804928d <read_six_numbers>
0x08048bbd <+25>: cmpl $0x0,-0x20(%ebp)
0x08048bc1 <+29>: jns 0x8048be3 <phase_2+63>
0x08048bc3 <+31>: call 0x804924b <explode_bomb>
0x08048bc8 <+36>: jmp 0x8048be3 <phase_2+63>
0x08048bca <+38>: mov %ebx,%eax
0x08048bcc <+40>: add -0x24(%ebp,%ebx,4),%eax
0x08048bd0 <+44>: cmp %eax,-0x20(%ebp,%ebx,4)
0x08048bd4 <+48>: je 0x8048bdb <phase_2+55>
0x08048bd6 <+50>: call 0x804924b <explode_bomb>
0x08048bdb <+55>: inc %ebx
0x08048bdc <+56>: cmp $0x6,%ebx
0x08048bdf <+59>: jne 0x8048bca <phase_2+38>
0x08048be1 <+61>: jmp 0x8048bea <phase_2+70>
2.
我覺得
mov 0xc(%ebp),%eax
越來越投入。
我試過x/s $ ebp + oxc,它打印這個字符串\ 350 \ 366 \ 377 \ 277 \ b \ 367 \ 377 \ 277> \ 223 \ 004 \ b {\ 246 \ 004 \ b。 那是什麼?我真的很難理解這是幹什麼的?我試圖在每個內存地址中打印出價值,但沒有幫助。
當我試圖在cmp $ 0x5,%eax之前打印出x/d $ eax時,它顯示無法訪問地址爲0x0的內存。
Dump of assembler code for function read_six_numbers:
0x0804928d <+0>: push %ebp
0x0804928e <+1>: mov %esp,%ebp
0x08049290 <+3>: sub $0x28,%esp
0x08049293 <+6>: mov 0xc(%ebp),%eax
0x08049296 <+9>: lea 0x14(%eax),%edx
0x08049299 <+12>: mov %edx,0x1c(%esp)
0x0804929d <+16>: lea 0x10(%eax),%edx
0x080492a0 <+19>: mov %edx,0x18(%esp)
0x080492a4 <+23>: lea 0xc(%eax),%edx
0x080492a7 <+26>: mov %edx,0x14(%esp)
0x080492ab <+30>: lea 0x8(%eax),%edx
0x080492ae <+33>: mov %edx,0x10(%esp)
0x080492b2 <+37>: lea 0x4(%eax),%edx
0x080492b5 <+40>: mov %edx,0xc(%esp)
0x080492b9 <+44>: mov %eax,0x8(%esp)
0x080492bd <+48>: movl $0x804a64b,0x4(%esp)
0x080492c5 <+56>: mov 0x8(%ebp),%eax
0x080492c8 <+59>: mov %eax,(%esp)
0x080492cb <+62>: call 0x8048860 <[email protected]>
0x080492d0 <+67>: cmp $0x5,%eax
0x080492d3 <+70>: jg 0x80492da <read_six_numbers+77>
0x080492d5 <+72>: call 0x804924b <explode_bomb>
'sub $ 0x34,%esp'指令在堆棧上創建了一些像局部變量這樣的東西。 'lea -0x20(%ebp),%eax'指令將這個暫存空間中一個位置的地址加載到'eax'中。 –