Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6801233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:04:30+00:00 2026-05-26T19:04:30+00:00

I am trying to get a simple example working from an assembly book I

  • 0

I am trying to get a simple example working from an assembly book I am reading. I am trying to get gdb to work with my simple assembly program that I am assembling with the NASM assembler. Below is the code, and the object file in elf format.

; Version         : 1.0
; Created Date    : 11/12/2011
; Last Update     : 11/12/2011
; Author          : Jeff Duntemann
; Description     : A simple assembly app for Linux, using NASM 2.05, 
;                   demonstrating the use of Linux INT 80H syscalls
;                   to display text.
; Build using these commands:
;   nasm -f elf -g -F stabs eatsyscall.asm
;   ld -o eatsyscall eatsyscall.o
;

SECTION .data                    ; Section containing initialized data
EatMsg: db "Eat at Joe's!",10
EatLen: equ $-EatMsg

SECTION .bss                     ; Section containing uninitialized data

SECTION .txt                     ; Section containing code


global _start                    ; Linker needs this to find the entry point!

_start:
    nop                          ; This no_op keeps gdb happy (see text)
    mov eax,4                    ; Specify sys_write syscall
    mov ebx,1                    ; Specify File Descriptor 1: Standard Output
    mov ecx,EatMsg               ; Pass offset of the message
    mov edx,EatLen               ; Pass the length of the mesage
    int 80H                      ; Make syscall to output the text to stdout

    mov eax,1                    ; Specify Exit syscall
    mov ebx,0                    ; Return a code of zero
    int 80H                      ; Make syscall to terminate the program

and

mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$ objdump -s ./eatsyscall.o

./eatsyscall.o:     file format elf32-i386

Contents of section .data:
 0000 45617420 6174204a 6f652773 210a      Eat at Joe's!.  
Contents of section .txt:
 0000 90b80400 0000bb01 000000b9 00000000  ................
 0010 ba0e0000 00cd80b8 01000000 bb000000  ................
 0020 00cd80                               ...             
Contents of section .stab:
 0000 00000000 64000100 00000000           ....d.......    
Contents of section .stabstr:
 0000 00  

I am using the following command to assemble:

nasm -f elf -g -F stabs eatsyscall.asm

and I am using the following command to link:

ld -o eatsyscall eatsyscall.o

When I run GDB on the executable I get the following:

mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$ gdb eatsyscall 
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/mehoggan/Code/AsmWork/eatsyscall/eatsyscall...Can't find any code sections in symbol file
(gdb) quit

What do I need to do in addition to what I am doing above to get gdb to read the debug symbols specified to NASM with the -g flag?

FYI

mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION="Ubuntu 11.10"
mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$ uname -a
Linux mehoggan 3.0.0-12-generic-pae #20-Ubuntu SMP Fri Oct 7 16:37:17 UTC 2011 i686 i686 i386 GNU/Linux
mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$

–Update–

Even if I take the 64 bit route with the following commands I am still having no success:

mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$ nasm -f elf64 -g -F stabs eatsyscall.asm
mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$ ld -o eatsyscall eatsyscall.o -melf_x86_64
mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$ ./eatsyscall
bash: ./eatsyscall: cannot execute binary file
mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$ objdump -s eatsyscall.o

eatsyscall.o: file format elf64-x86-64

Contents of section .data:
0000 45617420 6174204a 6f652773 210a Eat at Joe’s!.
Contents of section .txt:
0000 9048b804 00000000 00000048 bb010000 .H………H….
0010 00000000 0048b900 00000000 00000048 …..H………H
0020 ba0e0000 00000000 00cd8048 b8010000 ………..H….
0030 00000000 0048bb00 00000000 000000cd …..H……….
0040 80 .
Contents of section .stab:
0000 00000000 64000100 00000000 ….d…….
Contents of section .stabstr:
0000 00 .
mehoggan@mehoggan:~/Code/AsmWork/eatsyscall$

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:04:30+00:00Added an answer on May 26, 2026 at 7:04 pm

    How about using section .text istead of section .txt ?`

    That is:

    SECTION .data                    ; Section containing initialized data
    EatMsg: db "Eat at Joe's!",10
    EatLen: equ $-EatMsg
    
    SECTION .bss                     ; Section containing uninitialized data
    
    SECTION .text                    ; instead of .txt
    

    Should work just fine afterwards in gdb and if you are on a x64 architecture, use the x64 flags.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the following simple Delegate example working. According to a book
I'm trying to get this simple program to work on windows, but it crashes:
I'm trying to get a simple example working using gSoap, for VS2008. I've done
I'm trying to get a simple send and receive UDP program working, but I'm
I'm trying to get a simple bookmarklet working with Rails that creates a form
I am trying to get a simple example of the Quartz scheduler working in
I'm trying to get this simple PowerShell script working, but I think something is
I'm trying to get a simple search form working in my RoR site. I've
I am trying to get a simple demo started with ActiveMQ that will demonstrate
So i am trying to get a simple system working where i have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.