1

I'm using a Macbook pro with Yosemite. Can't get the printf to work. Here's my code:

extern _printf
global _main

section .data

msg:    db      "Hello World"

section .text

_main:
    push        msg
    call        _printf
    add         esp, 4
    ret

Using:

nasm -f macho test.s && gcc -arch i386 -e _main test.o && ./a.out

Output:

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

I'd really appreciate any help.

1 Answers1

1

This answered my question perfectly! How to print argv[0] in NASM?

Community
  • 1
  • 1