分支重定位中不受支持的符号修饰符:“调用printf @ PLT”

问题描述 投票:0回答:1

我正在跟踪C compiler writing journeygenerate assembly code以评估二进制表达式值。

这里是输出汇编代码(保存在文件“ out.s”中):

    .text
LC0:
    .string "%d\n"
_printint:
    pushq   %rbp
    movq    %rsp, %rbp
    subq    $16, %rsp
    movl    %edi, -4(%rbp)
    movl    -4(%rbp), %eax
    movl    %eax, %esi
    leaq    LC0(%rip), %rdi
    movl    $0, %eax
    call    printf@PLT
    nop
    leave
    ret

    .globl  _main
_main:
    pushq   %rbp
    movq    %rsp, %rbp
    movq    $2, %r8
    movq    $3, %r9
    movq    $5, %r10
    imulq   %r9, %r10
    addq    %r8, %r10
    movq    $8, %r8
    movq    $3, %r9
    movq    %r8,%rax
    cqo
    idivq   %r9
    movq    %rax,%r8
    subq    %r8, %r10
    movq    %r10, %rdi
    call    _printint
    movl    $0, %eax
    popq    %rbp
    ret

与...一起运行时

cc -o out out.s

,它抱怨

out.s:13:2: error: unsupported symbol modifier in branch relocation
 call printf@PLT
 ^

错误如何发生以及如何解决?

提前感谢!

PS:

  1. 我正在使用macOS Catalina 10.15.2
  2. 抄送版本为
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  1. 源代码使用cc -o comp1 -g cg.c expr.c gen.c main.c scan.c tree.c
macos assembly compiler-errors clang mach-o
1个回答
0
投票

call _printf有效。谢谢@PeterCordes。

尽管想知道抄送的错误提示。

© www.soinside.com 2019 - 2024. All rights reserved.