我正在使用Yosemite的Macbook Pro。无法使printf正常工作。这是我的代码:
extern _printf
global _main
section .data
msg: db "Hello World"
section .text
_main:
push msg
call _printf
add esp, 4
ret
使用:
nasm -f macho test.s && gcc -arch i386 -e _main test.o && ./a.out
输出:
ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _main from test.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie
Segmentation fault: 11
我真的很感激任何帮助。