PIE is disabled. Absolute addressing when programming asm with gcc on Mac OS X

I wrote this code. I want to compile it gcc on Mac OS X. But it looks like "PIE is disabled. Absolute addressing" when I run gcc.

I googled it, but I can not find a solution. Please advise me.

hello.s

.data
hello: .string "Hello World!\n"

.text
.globl _main

_main:
    push %rbp
    mov %rsp, %rbp
    movabs $hello, %rdi
    call _printf
    leave
    ret

Error

ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in
code signed PIE, but used in _main from /var/folders/xs/4z9kr_n93111fhv9_j1dd9gw0000gn/T/ex2_64-369300.o. 
To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie
+4
source share

All Articles