c - .c 文件中的内联 PPC 汇编代码出现 "Error: unsupported relocation against <register>"错误

标签 c gcc assembly powerpc

我有下面的内联汇编代码。但是当我尝试编译它时,它抛出代码片段后提到的错误。

unsigned int func(void)
{
  __asm__ ("mfspr r3, svr;");
}

以下是错误。

{standard input}: Assembler messages:
{standard input}:3349: Error: unsupported relocation against r3
{standard input}:3349: Error: unsupported relocation against svr
{standard input}:3375: Error: unsupported relocation against r3
{standard input}:3375: Error: unsupported relocation against svr
{standard input}:3510: Error: unsupported relocation against r3
{standard input}:3510: Error: unsupported relocation against svr
{standard input}:3517: Error: unsupported relocation against r3
{standard input}:3517: Error: unsupported relocation against svr

谁能帮我解决这些问题?

最佳答案

显然 gas 没有对这些寄存器的内置支持。为了使用它们,您应该自己定义它们或明确使用它们的索引,例如:

mfspr 3, <some_index_here>

或者您可以包括:ppc_asm.tmpl .

如果您的核心是 e500那么 svr 索引将为 1023。

关于c - .c 文件中的内联 PPC 汇编代码出现 "Error: unsupported relocation against <register>"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30253742/

相关文章:

c - 为什么在正确的文件夹 "/lib"和 "/usr/lib"中链接库(如 pthread)?

assembly - 这个汇编程序如何打印 "Hello World"?

c - 具有常量成员的结构的内存分配

C fork和pipe按顺序打印pid

c - 多个目录中的 `dirent.h`

arrays - 使用 C 将一维字符数组复制到二维字符数组

c - 从文件系统读取数据 vs 将数据直接编译到程序中

c++ - 在没有root权限的linux上安装gcc

windows - 汇编:如何更改此代码以请求用户输入

assembly - 使用 GDB 在本地标签处中断 NASM 程序集