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

  • SEARCH
  • Home
  • 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 7528119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:17:23+00:00 2026-05-30T04:17:23+00:00

I was reading this article, and at one point it gives me this nasm

  • 0

I was reading this article,
and at one point it gives me this nasm program:

; tiny.asm
BITS 32
GLOBAL main
SECTION .text
main:
              mov     eax, 42
              ret

And tells me to run the following commands:

$ nasm -f elf tiny.asm
$ gcc -Wall -s tiny.o

I got the following error:

ld: warning: option -s is obsolete and being ignored
ld: warning: ignoring file tiny.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

I ventured a guess at what might be the problem, and changed the BITS line to read:

 BITS 64

But then when I run nasm -f elf tiny.asm I get:

tiny.asm:2: error: `64' is not a valid segment size; must be 16 or 32

How do I modify the code to work on my machine?

Edit:

I took Alex’s advice from the comments and downloaded a newer version. However,

./nasm-2.09.10/nasm -f elf tiny.asm

complains

tiny.asm:2: error: elf32 output format does not support 64-bit code

On the other hand,

./nasm-2.09.10/nasm -f elf64 tiny.asm
gcc -Wall -s tiny.o

complains

ld: warning: ignoring file tiny.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
  • 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-30T04:17:24+00:00Added an answer on May 30, 2026 at 4:17 am

    There are OS X-specific adjustments you have to make in order for your example to work:
    The main method is prepended with a _ by the OS X linker:

    ; tiny.asm
    BITS 32
    GLOBAL _main
    SECTION .text
    _main:
        mov     eax, 42
        ret
    

    The second is that you have to use the mach file format:

    nasm -f macho tiny.asm
    

    Now you can link it (using -m32 to indicate a 32 bit object file):

    gcc -m32 tiny.o
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading this article about Double-Checked locking and out of the main topic
After reading this article on thedailywtf.com, I'm not sure that I really got the
After reading this article http://lukast.mediablog.sk/log/?p=155 I decided to use mingw on linux to compile
I just finished reading this article on the advantages and disadvantages of exceptions and
I was reading this article by Brandon Aaron here , about how jquery context
I was reading this article on Coding Horror: http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html I went to the downloads
I was just reading this article and it mentions that some organization had an
just was reading this article http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html And found this nice article http://wiki.apache.org/cassandra/DataModel I just
So , I've been reading this article: http://msdn.microsoft.com/en-us/library/aa290051%28VS.71%29.aspx And I would like to define
I was under the impression, after reading this article that it is better to

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.