I am attempting to run the following code in terminal on my Mac:
.section, .data
format_string:
.asciz "My favorite number is %d!"
number:
.long 786
.section, .text
.globl main
main:
pushl number
pushl $format_string
call printf
addl $8, %esp
pushl $0
call exit
This code is in a file named favorite.s
I used the command "gcc favorite.s -m32" and am seeing the following message:
Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.10.6.o
"exit", referenced from:
main in ccUKdD8O.o
"printf", referenced from:
main in ccUKdD8O.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
What am I doing wrong here? Thanks.
Symbols have an underscore prepended to them on Mac OS X. Add a _ in front of main, exit, and printf in your program and try again!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With