0

I have problem with compilation .asm file on macOS can somebody help me?

Here is my repository: https://github.com/ondrej-111/Asm.git

I tried to compile it with this commands:

nasm -f elf -d macho64 asm_io.asm

nasm -f elf prvy.asm

gcc -c driver.c

gcc -o prvy driver.o prvy.o asm_io.o

but I always get the same error:

ld: warning: ld: warning: ignoring file asm_io.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): asm_io.oignoring file prvy.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): prvy.o

Undefined symbols for architecture x86_64: "_asm_main", referenced from: _main in driver.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I searched some similar issues but any one helped me to fix it.( I tried this - How can I run this assembly code on OS X?)

Community
  • 1
  • 1
Ondrej11
  • 53
  • 1
  • 10
  • 4
    macos doesn't use elf format. Try `nasm -f macho64` instead. – Jester Mar 07 '17 at 22:20
  • @Jester since that is the correct answer, please write it as an answer. – JeremyP Mar 08 '17 at 17:35
  • At first I tried nasm -f macho64 wih asm_io.asm and prvy.asm but there was error about instructions not supported in 64-bit mode so then I tried use macho32 flag it worked but after last command(gcc -o prvy driver.o prvy.o asm_io.o) I get error again... Undefined symbols for architecture x86_64: **"_asm_main",= I think that here is the problem with underscope**; referenced from: _main in driver.o – Ondrej11 Mar 08 '17 at 21:05
  • Another one question: is there some easier way to run this project? Maybe install some distribution of Linux or Windows on VM. – Ondrej11 Mar 08 '17 at 21:20

0 Answers0