You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Clang交叉编译ppc64时生成的目标文件缺失函数符号

Clang交叉编译ppc64架构时函数符号缺失问题

我在使用Clang交叉编译ppc64架构时遇到了符号缺失的问题,具体情况如下:

测试代码

给定简单C文件test.c:

// test.c
int foobar(int v) {
   return v+1;
}

ppc64架构编译结果

执行编译及反汇编命令:

$ clang --target=ppc64 -c test.c -o test.ppc64.o
$ llvm-objdump -d test.ppc64.o

test.ppc64.o:   file format elf64-powerpc

Disassembly of section .text:

0000000000000000 <.text>:
       0: 90 61 ff f4   stw 3, -12(1)
       4: 80 61 ff f4   lwz 3, -12(1)
       8: 38 63 00 01   addi 3, 3, 1
       c: 7c 63 07 b4   extsw 3, 3
      10: 4e 80 00 20   blr
                ...

可以看到,虽然代码已生成,但foobar函数的符号元数据缺失,这会严重影响链接器工作。

ppc64le架构编译结果(对比)

同样的代码编译为ppc64le架构:

$ clang --target=ppc64le -c test.c -o test.ppc64le.o
$ llvm-objdump -d test.ppc64le.o

test.ppc64le.o: file format elf64-powerpcle

Disassembly of section .text:

0000000000000000 <foobar>:
       0: f4 ff 61 90   stw 3, -12(1)
       4: f4 ff 61 80   lwz 3, -12(1)
       8: 01 00 63 38   addi 3, 3, 1
       c: b4 07 63 7c   extsw 3, 3
      10: 20 00 80 4e   blr
                ...

此处foobar符号正常存在。

我测试了多个Clang版本(包括21版),均存在该问题,请问这是什么原因?


内容的提问来源于stack exchange,提问作者paleozogt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 10:25:06