【发布时间】:2020-04-27 22:54:39
【问题描述】:
我有一个简单的 NASM 代码,如下所示。我想将值 43(这是 trx 数组中的 +3 偏移量)设置为值 99。
section .data
trx db 25,21,17,43
section .text
global _start
_start:
mov [trx+3], byte 99
last:
mov rax, 60
mov rdi, 0
syscall
当我调试并且 _start 函数通过时,它可以工作。值 43 更改为 99。
(gdb) i var
All defined variables:
Non-debugging symbols:
0x00000000006000c4 trx
0x00000000006000c8 __bss_start
0x00000000006000c8 _edata
0x00000000006000c8 _end
(gdb) x/4b &trx
0x6000c4: 25 21 17 43
(gdb) break _start
Breakpoint 1 at 0x4000b0
(gdb) run
Starting program: /home/hexdemsion/Desktop/asm/exec
Breakpoint 1, 0x00000000004000b0 in _start ()
(gdb) stepi
0x00000000004000b8 in last ()
(gdb) x/4b &trx
0x6000c4: 25 21 17 99
现在如何直接在 GDB 中设置该值?我在 GDB 中试过这个命令,但还是不行。
(gdb) set 0x00000000006000c4+3 = 99
Left operand of assignment is not an lvalue.
(gdb) set {int}0x00000000006000c4+3 = 99
Left operand of assignment is not an lvalue.
(gdb) set {b}0x00000000006000c4+3 = 99
No symbol table is loaded. Use the "file" command.
另外,我没有在汇编时提供任何调试信息。
nasm -f elf64 -o obj.o source.asm; ld -o exec obj.o
【问题讨论】: