section .data msg db 'This is a test', 10, 0 ; something stupid here ft db 'addr is %x',10,0 section .text global _main extern _printf extern _exit _main: push rbp mov rbp, rsp ;xor al, al mov rdi, ft ;lea rdi,[rel ft] mov rsi,rdi call _printf ;xor rax,rax ;mov [rax],rax xor rdi,rdi call _exit ;mov rsp, rbp ;pop rbp ret
mac OS X 10.8.3:
nasm -f macho x.asm
gcc -o x x.o
会出现警告:
ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _main from a.o. To fix this warning, don't compile