首页 > 解决方案 > 如何解决“危险搬迁:不支持的搬迁”

问题描述

我正在编译 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)

标签: clinuxgcc

解决方案


问题不是重定位,是下面的警告(应该出现在错误之前)

WARNING: EXPORT symbol "gsi_write_channel_scratch" [vmlinux] version generation failed, symbol will not be versioned.

如果您在此处阅读有关 genksyms的更多信息,您将了解它会抱怨,因为它无法在抱怨的地方之前解析某些内容。在这种特殊情况下,问题是__packed返回类型(它不理解)。__packed仅在声明结构和联合时有用。我想将函数参数用作文档是有意义的,但这不是必需的。

__packed因此,只需从先前的函数__gsi_update_mhi_channel_scratch返回类型中删除即可。


推荐阅读