2

I am trying to debug some Assembly using gdb and I am having some issues. Once I enter gdb, I am unable to add breakpoints, and the file command doesn't seem to work. The exact outputs are at the bottom. I've tried searching for answers but none seem to work. I am running Ubuntu 17.10

main.asm

section .text
global _start
_start:
    mov ecx, string
    call printStr
    exit:
    mov eax, 1
    mov ebx, 0
    int 0x80

    printStr:
    pusha
    cmp byte [ecx], 0
    je breakPrintStr
    mov eax, 4
    mov ebx, 2
    mov edx, 1
    int 0x80
    add ecx, 1
    jmp printStr
    breakPrintStr:
    popa
    ret
section .data
    string db 'Hello, World!',0xa,0

Makefile

file = main
compile: $(file).asm Makefile
    nasm -g -f elf -F dwarf $(file).asm
    ld -m elf_i386 -s -o $(file) $(file).o
    rm $(file).o
    chmod +x $(file)

Then I launch gdb using

gdb main

(gdb) file main

Results in

Reading symbols from main...(no debugging symbols found)...done.

And

(gdb) b _global

Results in

No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n])

1 Answer 1

2

After searching I finally figured it out. The Corrected makefile is as follows:

file = main
compile: $(file).asm Makefile
    nasm  -g -f elf -F dwarf $(file).asm
    ld -m elf_i386 -o $(file) $(file).o
    rm $(file).o
    chmod +x $(file)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.