当前位置: 首页 > 工具软件 > DoubleH OS > 使用案例 >

mac os X 下用nasm大杂烩

曹君墨
2023-12-01
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

 类似资料: