NASM & GDB: loss of the first team

I study assembler and found some of the following are amazing. I essentially copied some kind of hello world code somewhere on the internet

section .text
    global  _start

_start:
    mov edx,len
    mov ecx,msg
    mov ebx,1
    mov eax,4
    int 0x80        ; interrupt for calling kernel

    mov eax,1
    int 0x80

section .data

msg db  'Hello, world!',0xa
len equ $ - msg

I will compile and link this to nasm -f elf -g hellow.asm, ld hellow.o -o hellow. If I upload it to gdb now, I can list the code and run it just fine. If I put a breakpoint on the first mov command, the program will not stop there. Running ndisasm (ndisasm -b32 hellow) in the resulting file that I get (the part that seems relevant to me):

0000007D  0000              add [eax],al
0000007F  00BA0E000000      add [edx+0xe],bh
00000085  B9A0900408        mov ecx,0x80490a0
0000008A  BB01000000        mov ebx,0x1
0000008F  B804000000        mov eax,0x4
00000094  CD80              int 0x80
00000096  B801000000        mov eax,0x1
0000009B  CD80              int 0x80

Therefore, the instruction does not appear.

I really appreciate the hint of what is happening, or where you can find out what is happening.

+3
source share
1 answer

, , - , . x86 , . :

00000080  BA0E000000      mov edx,0xe ; I think
00000085  B9A0900408      mov ecx,0x80490a0
...

gdb, , , , (, , gdb , ).

+1

Source: https://habr.com/ru/post/1776274/


All Articles