GDB debugging NASM assembler code syntax

Preparing to Debug version of nasm assembler code is as follows:

section .data
section .text
global main
main:
  ;100001/100
 mov rdx,1
 mov rax,86A1H
 mov rbx,100
 div rbx
 mov rax,60
 syscall

Some programs will use '_start' instead of 'main', but when I used the word _start to test, there will always be:

After entering y sometimes directly executing the launch program, but I want to step through and view the status register Yeah, so direct use of 'main' a word.

Then enter the following command: nasm -f elf64 -o div.0 div.asm

                                 ld -o div div.o

It will prompt a warning, it is because we do not use '_start' words, simply ignore ~~~~~

Then enter gdb div start gdb, enter the start began to run the program

If the above are not the problem, then we started stepping up.

Ni command is used here to step through the program, some attention is n input command blog or next, I found that this input will finish the entire program once in my personal machine.

Info register and then enter the command to check the status register.

Described herein may be used 'main' words, GDB will automatically set a program for the temporary breakpoint.

Next, we enter each time ni, info register command to step through the program and view the status register.

Published 37 original articles · won praise 10 · views 10000 +

Guess you like

Origin blog.csdn.net/OneLinee/article/details/103916620