s3c2410+linux2.6.25.20+armlinuxgcc4.3.3 模块加载出现错误

[内核补丁] 解决2.6.29内核上加载模块出现"unknown relocation: 40"

我使用s3c2410+linux2.6.25.20+arm-linux-gcc4.3.3(使用过其它较低版本3.4.5则不会出现这个问题)加载fat.ko等fat文件系统模块时候会报错,并不是全部都报错,某些简单的如led.ko不会。

1.修改 include/asm-arm/elf.h  文件

添加定义:
#define R_ARM_V4BX    40

 

2.arch/arm/kernel/module.c

int
apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
           unsigned int relindex, struct module *module)
{

...

case R_ARM_V4BX:   //added
        /* Preserve Rm and the condition code. Alter           
        * other bits to re-code instruction as
        * MOV PC,Rm.
        */
           *(u32 *)loc &= 0xf000000f;
           *(u32 *)loc |= 0x01a0f000;
           break;

    default:
        printk(KERN_ERR "%s: unknown relocation: %u\n",
               module->name, ELF32_R_TYPE(rel->r_info));
        return -ENOEXEC;

...

原文地址:https://www.cnblogs.com/leaven/p/1847701.html