Andes Workshop
http://forum.andestech.com/

Error "unsupported relocation type 94" when insert module
http://forum.andestech.com/viewtopic.php?f=10&t=902
Page 1 of 1

Author:  ianfeng [ Wed Dec 03, 2014 6:10 pm ]
Post subject:  Error "unsupported relocation type 94" when insert module

Question: Kernel will hand when insert module built by v3

Platform: XC7 with N1068A+AG101P
Kernel: BSP321 built with nds32le-linux-glibc-v3
Module: ftgpio010

When inserting "ftgpio010.ko" module which is built by nds32le-linux-glibc-v3 toolchain,
kernel will display following message and hand.
ftgpio010: unsupported relocation type 94.

It is OK with module built with v2 or v1 toolchain.

Reason:
It's due to v3 toolchain generate new relocation type and kernel doesn't support this type.

Solution:
Patches for BSP321 kernel source.
Code:
diff --git a/arch/nds32/include/asm/elf.h b/arch/nds32/include/asm/elf.h
index 89ecdc0..ce2296c 100644
--- a/arch/nds32/include/asm/elf.h
+++ b/arch/nds32/include/asm/elf.h
@@ -79,6 +79,7 @@ do {                                    \
#define R_NDS32_DWARF2_OP1_RELA     77
#define R_NDS32_DWARF2_OP2_RELA     78
#define R_NDS32_DWARF2_LEB_RELA     79
+#define R_NDS32_WORD_9_PCREL_RELA   94
#define R_NDS32_RELA_NOP_MIX      192
#define R_NDS32_RELA_NOP_MAX      255

diff --git a/arch/nds32/kernel/module.c b/arch/nds32/kernel/module.c
index 0402edf..4018d90 100755
--- a/arch/nds32/kernel/module.c
+++ b/arch/nds32/kernel/module.c
@@ -260,7 +260,11 @@ apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, unsigned int syminde
               return -ENOEXEC;
            do_reloc32( v - (Elf32_Addr)loc, loc, 0x01ffffff, 1, 0xff000000, 0, NEED_SWAP);
            break;
-
+         case R_NDS32_WORD_9_PCREL_RELA:
+            if(exceed_limit((v - (Elf32_Addr)loc), 0x000000ff, module, rel, relindex, i))
+               return -ENOEXEC;
+            do_reloc32( v - (Elf32_Addr)loc, loc, 0x000001ff, 1, 0xffffff00, 0, NEED_SWAP);
+            break;
         case R_NDS32_SDA15S3_RELA:
         case R_NDS32_SDA15S2_RELA:
         case R_NDS32_SDA15S1_RELA:

Attachment:
reloc_patch.txt [1.16 KiB]
Downloaded 566 times
Commands to patch this file.
Code:
#cd linux2.6
#cp <file location>/reloc_patch.txt .
#patch -p1 < reloc_patch.txt

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/