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 8719885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:54:18+00:00 2026-06-13T06:54:18+00:00

I want to compile and execute a very simple program in 64 bit. section

  • 0

I want to compile and execute a very simple program in 64 bit.

section .text 
global _start 
_start: 
   mov     rdx,len 
   mov     rcx,msg 
   mov     rbx,1 
   mov     rax,4 
   int     0x80 
   mov    rbx,0 
   mov     rax,1 
   int     0x80 
section .data 
msg     db      "Hello, world!",0xa 
len     equ     $ - msg 

The line to compile it:

yasm -f elf64 -g dwarf2 example.asm

$ yasm --version
yasm 1.2.0

also tried with another format macho[|32|64], elf[|32] bin none of them succeed.

The line to link it:

gcc -o example example.o

ld: warning: ignoring file example.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 2 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): example.o
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

$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

also tried with some options for gcc such as -m64 -arch x86_64.

  • 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-06-13T06:54:19+00:00Added an answer on June 13, 2026 at 6:54 am

    You have a few problems here:

    1) ELF is not supported on OS X, only Mach-O.

    2) Your linker is looking for an x86_64 architecture Mach-O and not finding it.

    ld: warning: ignoring file example.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 2 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): example.o

    Make sure you’re assembling for x86_64 or else try passing -m32 to GCC to use x86.

    3) Your linker is trying to include the C runtime library crt1.10.6.o, which doesn’t look like what you want since you didn’t define a _main function. Perhaps you should call the linker directly instead of invoking it via GCC, or else find the right combination of flags to pass to the linker to avoid this.

    If I was you, I’d start with the following steps:

    a) Write hello world in C, have clang output an assembly file (-s), and then see if you can assemble and link that using just clang. This should be pretty straightforward.

    b) Once that works, use file and otool to determine what your object file should look like and try to produce that with yasm.

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

Sidebar

Related Questions

I want to compile and execute a set of java programs one after the
Generally I need some online compiler that can compile and execute provided program and
I made a program using Eclipse, but I want to learn to compile it
I want compile some GUI into a Windows standalone application ( *.exe ). The
when i want compile my app with the Distribution or Release method i get
I want to compile my .java's (several) into one .jar that are compatible with
I want to compile a plugin for an application as a dynamic library. Usually,
I want to compile the data for reporting purpose, using php communicating with postgres,
I want to compile the Rigi source code but I get some error while
I want to compile php sqlite3 with custom compile option. to do that I

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.