1

Given the following code:

SECTION .DATA
hello:     db 'Hello world!',10
helloLen:  equ $-hello

; Code goes in the text section
SECTION .TEXT
;GLOBAL _start
GLOBAL main

;_start:
main:
mov eax,4            ; 'write' system call = 4
mov ebx,1            ; file descriptor 1 = STDOUT
mov ecx,hello        ; string to write
mov edx,helloLen     ; length of string to write
int 80h              ; call the kernel

; Terminate program
mov eax,1            ; 'exit' system call
mov ebx,0            ; exit with error code 0
int 80h              ; call the kernel

Compiled with: nasm -f elf64 hello.asm -g -F stabs

Then linked with: gcc -o hello hello.o -g.

GDB still reports Reading symbols from /home/work/code/nasm/hello...(no debugging symbols found)...done and the breakpoint that I set did not work

d-cubed
  • 1,034
  • 5
  • 30
  • 58
  • my command: nasm -f elf64 hello.asm -g -F stabs;gcc -o hello hello.o -g.The gdb still gave me "Reading symbols from /home/work/code/nasm/hello...(no debugging symbols found)...done" and the breakpoint i set did not work – kimlon zhang Feb 11 '18 at 03:07
  • try `-F dwarf` instead od stabs – Michael Petch Feb 11 '18 at 06:34
  • 2
    You should also use `.text` and `.data` instead of the upper case versions (you use .TEXT and .DATAwhich are not the same) – Michael Petch Feb 11 '18 at 06:38
  • 1
    Also place `-g -F dwarf` before all other options – Michael Petch Feb 11 '18 at 06:41
  • In 64-bit code you should consider the 64-bit method of doing system calls via the `syscall` instruction. Ryan Chapman's Blog is a good starting point: http://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/ – Michael Petch Feb 11 '18 at 09:36
  • related: [What happens if you use the 32-bit int 0x80 Linux ABI in 64-bit code?](https://stackoverflow.com/questions/46087730/what-happens-if-you-use-the-32-bit-int-0x80-linux-abi-in-64-bit-code) – Peter Cordes Feb 11 '18 at 10:13

0 Answers0