如何修复“危险的重定位:不支持的重定位”错误

6

我正在编译Linux-4.19(gcc-8.2 bintutils-2.31),但总是出现错误,例如:

aarch64-oe-linux-ld.bfd: drivers/platform/gsi/gsi.o: relocation R_AARCH64_ABS32 against `__crc_gsi_write_channel_scratch' can not be used when making a shared object
aarch64-oe-linux-ld.bfd: drivers/platform/gsi/gsi.o:/usr/src/kernel/drivers/platform/gsi/gsi.c:4383:(.data+0x0): dangerous relocation: unsupported relocation
aarch64-oe-linux-ld.bfd: drivers/platform/gsi/gsi.o:(.data+0x28): dangerous relocation: unsupported relocation
aarch64-oe-linux-ld.bfd: drivers/platform/gsi/gsi.o:(.data+0x50): dangerous relocation: unsupported relocation
aarch64-oe-linux-ld.bfd: drivers/platform/gsi/gsi.o:(__verbose+0x0): dangerous relocation: unsupported relocation
aarch64-oe-linux-ld.bfd: drivers/platform/gsi/gsi.o:(__verbose+0x8): dangerous relocation: unsupported relocation

我已尝试以下解决方案,但这些都没有起作用。

  1. -fPIC标志添加到驱动程序中
  2. 使用gcc-7.3(binutils-2.31)
  3. 使用binutils-2.33(gcc-8.2)

将“-fpie”添加到LDFLAGS中,会失败并提示“-r和-shared不能一起使用”。 - jason
1个回答

3
问题不在于迁移,而是以下警告(应该出现在错误之前)。
WARNING: EXPORT symbol "gsi_write_channel_scratch" [vmlinux] version generation failed, symbol will not be versioned.

如果您阅读更多关于genksyms这里的内容,您会了解到它抱怨无法解析在其抱怨位置之前的某些内容。在这种特殊情况下,问题是__packed返回类型(它不理解)。只有在声明结构体和联合体时,__packed才有用。我想函数参数作为文档是有道理的,但这并非必要。

因此,只需从先前的函数__gsi_update_mhi_channel_scratch的返回类型中删除__packed,然后就可以了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接