【问题标题】:Segmentation fault call printf NASM分段错误调用 printf NASM
【发布时间】:2014-12-27 03:52:33
【问题描述】:

我正在使用带有 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

非常感谢任何帮助。

【问题讨论】:

    标签: macos gcc segmentation-fault printf nasm


    【解决方案1】:

    这完美地回答了我的问题! How to print argv[0] in NASM?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-07
      • 1970-01-01
      • 2021-10-16
      • 2016-09-10
      • 2014-01-31
      相关资源
      最近更新 更多