How Do I Run the Assembly in OS X 10.11

Asked 1 months ago, Updated 1 months ago, 3 views

How do I run the assembly on OS X 10.11?
GCC seems to be able to assemble normally (gcc-o hello world hello world.s).
What should I do with clang?

Add

I understood that there was a command in OS X called as, which seems to be a command for assembling.

Additional 2

as-arch x86_64-o helloworld helloworld.s generated a file called hellowworld, but I cannot successfully ld after that.
I tried ld-macosx_version_min 10.11 helloworld.
I get the following error

ld:warning:-macosx_version_min not specified,assuming 10.10
ld: warning: object file (helloworld) was built for newer OSX version (10.11) than being linked (10.10)
ld —dynamic main executables must link with libSystem.dylib for referred architecture x86_64

# original: http://dustin.schultz.io/blog/2010/11/15/mac-os-x-64-bit-assembly-system-calls/

# # https://gist.github.com/h2so5/d429d0aec527482f6209

.data
hello_world:.asciz "Hello world!\n"

.text
.globl_main

_main:
mov$0x2000004,%rax
US>mov$1,%rdi
lea hello_world(%rip), %rsi
mov $14,%rdx
syscall
mov$0x2000001,%rax
mov $0,%rdi
syscall

assembly-language

2022-09-30 13:51

1 Answers

How cc(1) runs ld(1) is

cc-v-o hello world hello world.s

You can check it by specifying the -v option.(Check the online documentation in ld(1) for the meaning of the individual options listed.)

Also, the resulting object files that are assembled in as(1) are usually

 as-arch x86_64-o helloworld.o helloworld.s

and .o filenames.


2022-09-30 13:51

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.