'GDB: No symbol files found in NASM assembled file
Forgive me as I'm pretty new here, but I am trying to debug the x86 assembly with gdb.
ex10.asm
global main
extern printf
section .data
msg db "Testing %i...", 0x0a, 0x00
main:
push ebp
mov ebp, esp
push 123
push msg
call printf
mov eax, 0
mov esp, ebp
pop ebp
ret
compiled and linked with below:
nasm -f elf32 -F dwarf -g ex10.asm -o ex10.o
gcc -m32 -gdwarf ex10.o -o ex10
ex10.o appears to have debug symbols
$ objdump --syms ./ex10.o | grep debug
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_line 00000000 .debug_line
ex10 appears to have no debug symbols
$ objdump --syms ./ex10 | grep debug
----returns nothing----
gdb ./ex10 returns below
$ gdb ./ex10
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
This GDB was configured as "x86_64-linux-gnu".
Reading symbols from ./ex10...
(No debugging symbols found in ./ex10)
After this, I'm not quite sure to look.Any suggestions or info i should provide?
also, nasm version
$ apt list --installed | grep nasm
nasm/focal,now 2.14.02-1 amd64 [installed]
Solution 1:[1]
Reproduced with NASM version 2.15.05.
Without section .text (suggested by ssbssa):
readelf -w ex10.o
Section '.debug_aranges' has no debugging data.
Section '.debug_pubnames' has no debugging data.
Section '.debug_info' has no debugging data.
Section '.debug_abbrev' has no debugging data.
Section '.debug_line' has no debugging data.
Section '.debug_frame' has no debugging data.
Section '.debug_loc' has no debugging data.
so naturally you get nothing in the final link output.
Adding section .text before main solves the problem.
Note: you are expecting output from objdump --syms ./ex10 | grep debug, but that is the wrong thing to expect:
- there are no symbols named
*debug*in your file - you should ~never look at ELF files with
objdump. Usereadelfinstead.
If you insist on using objdump, do this:
objdump -g ex10 | grep debug
Contents of the .debug_aranges section (loaded from ex10):
Offset into .debug_info: 0x0
Contents of the .debug_info section (loaded from ex10):
Contents of the .debug_abbrev section (loaded from ex10):
Raw dump of debug contents of section .debug_line (loaded from ex10):
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Employed Russian |
