Andes Workshop

It is currently Mon Oct 14, 2024 1:44 am

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Error "unsupported relocation type 94" when insert module
PostPosted: Wed Dec 03, 2014 6:10 pm 
Offline

Joined: Wed Apr 13, 2011 7:44 pm
Posts: 23
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 1483 times
Commands to patch this file.
Code:
#cd linux2.6
#cp <file location>/reloc_patch.txt .
#patch -p1 < reloc_patch.txt


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group